delphi的消息处理的相关函数
TWinControl.MainWndProc
TControl.WndProc
TObject.Dispatch
TObject.DefaultHandler
TWinControl.MainWndProc
procedure TWinControl.MainWndProc(var Message: TMessage);
begin
try
try
WindowProc(Message);
finally
FreeDeviceContexts;
FreeMemoryContexts;
end;
except
Application.HandleException(Self);
end;
end;
property WindowProc: TWndMethod read FWindowProc write FWindowProc;
TWndMethod = procedure(var Message: TMessage) of object;
TControl.WndProc
procedure WndProc(var Message: TMessage); virtual;
procedure TControl.WndProc(var Message: TMessage);
var
Form: TCustomForm;
begin
if (csDesigning in ComponentState) then
begin
Form := GetParentForm(Self);
if (Form <> nil) and (Form.Designer <> nil) and
Form.Designer.IsDesignMsg(Self, Message) then Exit;
end
else if (Message.Msg >= WM_KEYFIRST) and (Message.Msg <= WM_KEYLAST) then
begin
Form := GetParentForm(Self);
if (Form <> nil) and Form.WantChildKey(Self, Message) then Exit;
end
else if (Message.Msg >= WM_MOUSEFIRST) and (Message.Msg <= WM_MOUSELAST) then
begin
if not (csDoubleClicks in ControlStyle) then
case Message.Msg of
WM_LBUTTONDBLCLK, WM_RBUTTONDBLCLK, WM_MBUTTONDBLCLK:
Dec(Message.Msg, WM_LBUTTONDBLCLK - WM_LBUTTONDOWN);
end;
case Message.Msg of
WM_MOUSEMOVE: Application.HintMouseMessage(Self, Message);
WM_LBUTTONDOWN, WM_LBUTTONDBLCLK:
begin
if FDragMode = dmAutomatic then
begin
BeginAutoDrag;
Exit;
end;
Include(FControlState, csLButtonDown);
end;
WM_LBUTTONUP:
Exclude(FControlState, csLButtonDown);
end;
end
else if Message.Msg = CM_VISIBLECHANGED then
with Message do
SendDockNotification(Msg, WParam, LParam);
Dispatch(Message);
end;
TObject.Dispatch
procedure TObject.Dispatch(var Message);
asm
PUSH EBX
MOV BX,[EDX]
OR BX,BX
JE @@default
CMP BX,0C000H
JAE @@default
PUSH EAX
MOV EAX,[EAX]
CALL GetDynaMethod
POP EAX
JE @@default
MOV ECX,EBX
POP EBX
JMP ECX
@@default:
POP EBX
MOV ECX,[EAX]
JMP dword ptr [ECX].vmtDefaultHandler
end;
TObject.DefaultHandler
procedure DefaultHandler(var Message); virtual;
procedure TObject.DefaultHandler(var Message);
begin
end;
本文详细介绍了Delphi中用于消息处理的关键函数,包括TWinControl.MainWndProc、TControl.WndProc、TObject.Dispatch和TObject.DefaultHandler。通过这些函数,开发者可以了解Delphi应用程序如何接收、分发和处理各种Windows消息。
1245

被折叠的 条评论
为什么被折叠?



