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;
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
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end
else
FTerminate := True; // 看到我们刚才提高的这个标志了吗
end;
end;
请问DispatchMessage(Msg);之后应该转到procedure TApplication.WndProc(var Message: TMessage);那么什么时候执行窗体的mainWndProc
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;
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
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end
else
FTerminate := True; // 看到我们刚才提高的这个标志了吗
end;
end;
请问DispatchMessage(Msg);之后应该转到procedure TApplication.WndProc(var Message: TMessage);那么什么时候执行窗体的mainWndProc
wndproc是在Tcontrol类中定义的一个虚拟方法。这就意味着可以覆盖它。提供自定义的消息处理过程。最好调用继承,让父类代为处理你不处理的消息。 它调用disptch方法来进行消息分配。类似于DispatchMessage 其参数是记录类型
http://blog.csdn.net/linzhengqun/archive/2006/12/20/1451088.aspx
Application.CreateForm(TForm1, Form1);
Application.Run;对了,在还没进Application.Run的消息循环前,Application.Initialize;
Application.CreateForm(TForm1, Form1); 的过程中产生的消息谁处理的。
所以在Run之前的消息都放在消息队列中。
当然还有一种情况是操作系统直接调用程序的窗口过程。其实这些东西在Windows程序设计中都有讲的,你最好看一下这本书,然后再读VCL,这样会顺理成章得多。回家咯。