先看源码后帮忙 ( 积分: 26 )

  • 主题发起人 主题发起人 delphi0808
  • 开始时间 开始时间
D

delphi0808

Unregistered / Unconfirmed
GUEST, unregistred user!
function TApplication.ProcessMessage(var Msg: TMsg): Boolean;
var
Handled: Boolean;
begin
Result := False;
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then//查询消息队列中有无消息等待处理,参数PM_REMOVE使消息在处理完后会被删除。
begin
Result := True;
if Msg.Message <> WM_QUIT then//如果是WM_QUIT,终止进程,否则执行下面的代码
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);//将记录Msg传递给Windows进行转换
DispatchMessage(Msg);//将记录Msg回传给Windows
end;
end
else
FTerminate := True;
end;
end;

======================
1.为什么过滤掉下面的消息?
IsHintMsg(Msg) IsMDIMsg(Msg) IsKeyMsg(Msg) IsDlgMsg(Msg)
2。这些被过滤的消息最终是如何被处理的?
 
看一下Is**Msg的源码就知道了, 就在这些function中处理这些Msg的
 
能否贴一下它们的源码?或者在哪个单元中找到?
 
按住ctrl然后点 Is**Msg 就知道了。
 
查DELPHI的帮助吧
 
看了一下源码,没看懂
能说一下IsKeyMsg(Msg)的大概用途吗?
 
function TApplication.IsKeyMsg(var Msg: TMsg): Boolean;
var
Wnd: HWND;
begin
Result := False;
with Msg do
if (Message >= WM_KEYFIRST) and (Message <= WM_KEYLAST) then
begin
Wnd := GetCapture;
if Wnd = 0 then
begin
Wnd := HWnd;
if (MainForm <> nil) and (Wnd = MainForm.ClientHandle) then
Wnd := MainForm.Handle
else
begin
// Find the nearest VCL component. Non-VCL windows wont know what
// to do with CN_BASE offset messages anyway.
// TOleControl.WndProc needs this for TranslateAccelerator
while (FindControl(Wnd) = nil) and (Wnd <> 0) do
Wnd := GetParent(Wnd);
if Wnd = 0 then Wnd := HWnd;
end;
if SendMessage(Wnd, CN_BASE + Message, WParam, LParam) <> 0 then
Result := True;
end
else if (LongWord(GetWindowLong(Wnd, GWL_HINSTANCE)) = HInstance) then
begin
if SendMessage(Wnd, CN_BASE + Message, WParam, LParam) <> 0 then
Result := True;
end;
end;
end;
 

Similar threads

后退
顶部