Delphi 메시지 메커니즘 탐색 1
16155 단어 직장Delphi레저의 메시지 메커니즘 탐색 1
12 《Inside VCL》。 , Delphi。 12 , , , VCL 。 TObject、TPersistant TComponent , Delphi 。 Delphi , ( book523 )。 Delphi VCL 。 《Delphi 》, , Delphi VCL 。 , , 。 Delphi VCL , , Delphi VCL ( )。 , , 。 VCL , TObject、TControl TWinControl。 ( TForm) , 。 VCL 。 , 。 , : Win32 TObject、TControl TWinControl Delphi : Win32 SDK Delphi Delphi : 《Delphi 》 http: //www.codelphi.com/ 《VCL , MFC 》 http: //www.delphibbs.com/delphibbs/dispq.asp?lid=584889 《Delphi 》 http: //www.delphibbs.com/delphibbs/dispq.asp?LID=2390131 : ; 80 ; 。 ( , 。) =============================================================================== ⊙ GUI Application : ⊙ TWinControl . Create、 ⊙ :TWndMethod ⊙ VCL TWinControl . MainWndProc ⊙ TWinControl . WndProc ⊙ TControl . WndProc ⊙ TObject . Dispatch ⊙ TWinControl . DefaultHandler ⊙ TControl . Perform TWinControl . Broadcast ⊙ TWinControl . WMPaint ⊙ TWinControl =============================================================================== =============================================================================== ⊙ GUI Application : =============================================================================== Win32 GUI 。 C Win32 GUI , : while (GetMessage(&msg, NULL, 0 , 0 )) // GetMessage NULL, // { TranslateMessage(&msg); // DispatchMessage(&msg); // msg lpfnWndProc } lpfnWndProc Win32 API , : int __stdcall WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); Windows (callback function ) (window procedure ), , 。 GetMessage 。 , TranslateMessage。TranslateMessage , 。 DispatchMessage(&msg)。DispatchMessage(&msg) msg (WndClass . lpfnWndProc)。lpfnWndProc 。 GetMessage WM_QUIT ,GetMessage False , , 。 Win32 API , Delphi VCL , 。 ,Delphi , Win32 , , VCL 。 ,Delphi ( Self), Delphi Windows 。Delphi VCL Windows 。 Delphi Application , Delphi 。 program Project1; begin Application . Initialize; Application . CreateForm(TForm1, Form1); Application . Run; end . Project1 Application . Initialize ,Delphi : SysInit . _InitExe。_InitExe HInstance 。 _InitExe System . _StartExe。System . _StartExe System . InitUnit;System . InitUnit Initialization ; Controls . Initialization , 。 Mouse、Screen Application 。 Application . Create Application . CreateHandle。Application . CreateHandle , Application . WndProc ( MakeObjectInstance , )。Application . WndProc 。 Application , SysInit . _InitExe 。 , , F7 。 Project1 1 : Application . Initialize; : if InitProc nil then TProcedure(InitProc); , InitProc 。( Application . Initialize Initliazation ? : , Initialization [ Application ], 。) Project1 2 : Application . CreateForm(TForm1, Form1); TForm1 , Application . MainForm TForm1。 Project1 3 : Application . Run; TApplication . Run TApplication . HandleMessage 。Application . HandleMessage : if not ProcessMessage(Msg) then Idle(Msg); TApplication . ProcessMessage 。ProcessMessage PeekMessage API GetMessage 。 PeekMessage PeekMessage , HandleMessage Idle(Msg) 。 ProcessMessage HintMsg、MDIMsg、KeyMsg、DlgMsg , Delphi Win32 SDK Dialog Window、MDI Window , TForm ( Win32 SDK Dialog Microsoft , )。 function TApplication . ProcessMessage( var Msg: TMsg): Boolean ; var Handled: Boolean ; begin Result := False ; if PeekMessage(Msg, 0 , 0 , 0 , PM_REMOVE) then // begin Result := True ; if Msg . Message WM_QUIT then begin Handled := False ; // Handled Application.OnMessage // 。 // Application.OnMessage , // Application.OnMessage if Assigned(FOnMessage) then FOnMessage(Msg, Handled); if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then // :not Handled ? begin TranslateMessage(Msg); // DispatchMessage(Msg); // WndClass.lpfnWndProc end ; end else FTerminate := True ; // WM_QUIT // ( ) end ; end ; ,Delphi Win32 C 。 Delphi , C Win32 API 。 =============================================================================== ⊙ TWinControl . Create、 =============================================================================== Application , Delphi 。 , 。 Delphi VCL : TObject TPersistent TComponent Delphi Form Designer TControl TWinControl Delphi TWinControl 。 , , HWND。TWinControl FHandle , TWinControl . Handle 。 TWinControl . Create , CreateWindow API , TWinControl Windows 。 TWinControl . Create(Application) , Handle ? TWinControl . GetHandle ,Handle : property TWinControl . Handle: HWnd read GetHandle; TWinControl . GetHandle : FHandle ,TWinControl . HandleNeeded 。HandleNeeded TWinControl . FHandle 0 ( ? )。 FHandle 0 , FHandle; FHandle 0 , , HandleNeeded TWinControl . CreateHandle Handle。 CreateHandle , TWinControl . CreateWnd , VCL Control ( )。CreateWnd , TWinControl . CreateParams 。(CreateParams , , 。) CreateWnd TWinControl . CreateWindowHandle。CreateWindowHandle CreateWindowEx API 。 , Borland , Borland 。 TWinControl , 。 。 Parent ( TControl ) 。 Parent ,TControl . SetParent TWinControl . RemoveControl TWinControl . InsertControl 。InsertControl TWinControl . UpdateControlState。UpdateControlState TWinControl . Showing TWinControl . UpdateShowing。UpdateShowing , TWinControl . CreateHandle 。 , , 。 , , 。 Delphi ( ), 。 cheka 《VCL , MFC 》 VCL , :http: //www.delphibbs.com/delphibbs/dispq.asp?lid=584889 VCL : TWinControl . Create , inherited , FObjectInstance := Classes . MakeObjectInstance(MainWndProc); , cheka , 。 MakeObjectInstance , : MakeObjectInstance , 。 , MainWndProc , Self ( )。 Self TWinControl . MainWndProc 。 MakeObjectInstance , TWinControl . FObjectInstance 。 ,TWinControl . FObjectInstance 。 TWinControl TWinControl . FObjectInstance ( RegisterClass API), 。 FObjectInstance ( Self), 。TWinControl . CreateWnd CreateParams , Controls . pas InitWndProc 。InitWndProc Windows 。InitWndProc ( ) TWinControl . FObjectInstance ( Windows subclassing ), SetProp , Delphi ( Controls . pas FindControl )。 ,TWinControl . FObjectInstance 。
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
양식 제출 후 제출 버튼 비활성화텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.