请问! 处理Form移动消息,如何屏蔽掉其他消息?(50分)

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

dcjlin

Unregistered / Unconfirmed
GUEST, unregistred user!
如题。即如何截获消息,只有在对窗体移动的消息才处理,其他消息不做任何事情。<br><br>谢谢。
 
用GetMessage当碰到其他的消息的时候直接过滤应该就可以吧!~
 
消息截获啊,给你个思路<br>&nbsp; private<br>&nbsp; &nbsp;Procedure OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);<br><br>Procedure TForm1.OnMouseWheel(Var Msg :TMsg;var Handled:Boolean);<br>begin<br>&nbsp; if Msg.message = WM_MouseWheel then<br>&nbsp; begin<br>&nbsp; &nbsp; if Msg.wParam &gt; 0 then<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;if DGTitle.Focused then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(DGTitle.Handle,WM_KEYDOWN,VK_UP,0);<br>&nbsp; &nbsp; &nbsp;end<br>&nbsp; &nbsp; else<br>&nbsp; &nbsp; &nbsp;begin<br>&nbsp; &nbsp; &nbsp; &nbsp;if DGTitle.Focused then<br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;SendMessage(DGTitle.Handle,WM_KEYDOWN,VK_DOWN,0);<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; Handled:= false;//<br>&nbsp; end;<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>&nbsp;Application.OnMessage:=OnMouseWheel; // 截获鼠标滚动事件<br>end;
 
The WM_MOVING message is sent to a window that the user is moving. <br>The WM_MOVE message is sent after a window has been moved.
 
重载PROCEDURE WNDPROC(VAR MESSAGE:TMESSAGE);OVERRIDE;消息,如果是窗体移动消息就退出不作处理,其它消息INHERITED就OK了
 
To xmcccc:<br>我要的意思正好和你说的相反: 是窗体移动消息就处理,其他消息就不处理。<br>按上述说明重载PROCEDURE WNDPROC(VAR MESSAGE:TMESSAGE);OVERRIDE;<br>一运行就出现错误:A Call to an OS function failed!<br>procedure TForm1.WndProc(var Message: TMessage);<br>begin<br>&nbsp; if message.Msg &lt;&gt; WM_Move then &nbsp;Exit;<br>&nbsp; inherited WndProc(Message);<br>end;
 
你到以下地址去找找,可能找得到你需要的答案。<br>http://iinsnian.cnblogs.com/<br>这个地址里介绍了很多DELPHI的技巧,不知道你的运气好不好。
 
后退
顶部