Delphi 메시지 메커니즘 탐색 2
12799 단어 직장Delphi레저의 메시지 메커니즘 탐색 2
, TWinControl ( ), Windows TWinControl . FObjectInstance, FObjectInstance TWinControl . MainWndProc 。 VCL Windows 。 , ,Windows HWND 。 Delphi TWinControl . Handle ( protected WindowHandle) 。Windows TMessage Result。 , DispatchMessage TWinControl . MainWndProc ( FObjectInstance . Code ): DispatchMessage(&Msg) // Application.Run DispatchMessage // Windows Windows TWinControl . FObjectInstance : push LPARAM push WPARAM push UINT push HWND push (eip . Next) ; Windows ; jmp FObjectInstance . Code ; TWinControl . FObjectInstance FObjectInstance . Code call : call ObjectInstance . offset push eip . Next jmp InstanceBlock . Code ; InstanceBlock . Code InstanceBlock . Code: pop ecx ; eip . Next ecx, ; @MainWndProc Self jmp StdWndProc ; StdWndProc StdWndProc : function StdWndProc(Window: HWND; Message, WParam: Longint ; LParam: Longint ): Longint ; stdcall; assembler; asm push ebp mov ebp, esp XOR EAX,EAX xor eax, eax PUSH EAX push eax ; Message . Result := 0 PUSH LParam ; Borland push dword ptr [ebp+ $14 ] ; push ? PUSH WParam ; TMessage Result push dword ptr [ebp+ $10 ] ; , HWND PUSH Message ; , 。 push dword ptr [ebp+ $0c ] MOV EDX,ESP mov edx, esp ; Message ; MainWndProc MOV EAX,[ECX]. Longint [ 4 ] mov eax, [ecx+ $04 ] ; Self MainWndProc CALL [ECX]. Pointer call dword ptr [ecx] : TWinControl . MainWndProc(Self, ; @Message) ADD ESP, 12 add esp, $0c POP EAX pop eax end ; pop ebp ret $0010 mov eax, eax , 。 =============================================================================== ⊙ :TWndMethod =============================================================================== MakeObjectInstance(MainWndProc) MakeObjectInstance。 TWndMethod VCL 。 TWndMethod = procedure ( var Message: TMessage) of object ; :TWndMethod , TMessage , , ( object related) 。TWndMethod , 8 。TWndMethod 。 : var SomeMethod: TWndMethod; begin SomeMethod := Form1 . MainWndProc; // 。 SomeMethod MainWndProc // Form1 , SomeMethod(Msg) // 。 SomeMethod := TForm . MainWndProc; // ! 。 end ; TWndMethod ? : var SomeMethod: TWndMethod; begin SomeMethod := Form1 . WndProc; // TForm.WndProc end ; , SomeMethod Form1 WndProc Form1 。 。 SomeMethod(Message) Form1 . WndProc(Message)。 , ( function ), ( procedure )。 , TWndMethod , 。 =============================================================================== ⊙ VCL TWinControl . MainWndProc =============================================================================== Application . Run、TWinControl . Create、TWinControl . Handle TWinControl . CreateWnd , VCL 。VCL TWinControl . MainWndProc 。( , 。) MainWndProc ( ): procedure TWinControl . MainWndProc( var Message: TMessage); begin WindowProc(Message); end ; TWinControl . MainWndProc ( ) TMessage ,TMessage ( WParam、LParam、Result HiWord LoWord , , ): TMessage = packed record Msg: Cardinal ; WParam: Longint ; LParam: Longint ; Result: Longint ); end ; TMessage , TWinControl . Handle 。TMessage . Msg ID , Windows 、 VCL Control 。WParam LParam Windows wParam lParam ,Result Windows 。 MainWndProc , TWinControl 。( : Borland MainWndProc ?) MainWndProc , , 。 WindowProc(Message)。WindowProc TControl( TWinControl) ( property ): property WindowProc: TWndMethod read FWindowProc write FWindowProc; WindowProc TWndMethod, ( TWndMethod )。 TControl . Create FWindowProc WndProc。 WndProc TControl , TWinControl . MainWndProc : procedure TControl . WndProc( var Message: TMessage); virtual; MainWndProc , TControl . WndProc 。 Borland FWindowProc WndProc , WndProc ? 。 TWndMethod ? TWndMethod , , 。 WndProc ( “ / ” “ / ” ), WndProc , TControl WndProc WindowProc , WindowProc , 。 =============================================================================== ⊙ TWinControl . WndProc =============================================================================== , VCL :WndProc 。 ,TWinControl . MainWndProc , WindowProc 。 WindowProc WndProc , WndProc VCL , WindowProc 。 WndProc , TControl , TWinControl 。Borland WndProc , 。 : inherited , , , TWinControl TComponent . Create -> TControl . Create -> TWinControl . Create。 WndProc , WndProc 。 TWinControl . WndProc -> TControl . WndProc。 , , WndProc , WndProc 。 TWinControl , WndProc , VCL 。 TWinControl . WndProc 、 、 , ,TWinControl . WndProc , TControl . WndProc 。 TWinControl . WndProc : WM_KEYFIRST .. WM_KEYLAST: if Dragging then Exit; // : Exit : , 。
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
양식 제출 후 제출 버튼 비활성화텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.