关于postmessage的参数问题(100分)

  • 主题发起人 主题发起人 xiewenrui
  • 开始时间 开始时间
X

xiewenrui

Unregistered / Unconfirmed
GUEST, unregistred user!
各位同仁:<br>&nbsp; &nbsp;本人写了一个消息映射的问题,在delphi5下运行是没有问题,但是在delphi7下<br>当调用函数postMessage时,却报说参数不够,不知是什么原因。程序如下:<br><br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls;<br><br>const<br>&nbsp; &nbsp; &nbsp; WM_MYMESSAGE = WM_USER + $100;<br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Button1: TButton;<br>&nbsp; &nbsp; procedure Button1Click(Sender: TObject);<br><br>&nbsp; private<br>&nbsp; &nbsp; procedure ShowMe(var Msg: TMessage);message WM_MYMESSAGE;<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.ShowMe(var Msg: TMessage);<br>BEGIN<br>&nbsp; ShowMessage('Right');<br>END;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; postmessage(self.Handle,ShowMe,0,0);<br>end;<br><br>end.<br>
 
&gt;&gt;postmessage(self.Handle,ShowMe,0,0);<br>ShowMe,ShowMe,ShowMe??能这么用吗?为什么要这么用啊?
 
好像应该这样吧,说错了,别打我[:D]<br>postmessage(self.Handle,WM_MYMESSAGE,0,0);
 
postmessage(self.Handle,WM_MYMESSAGE ,0,0);
 
postmessage(self.Handle,WM_MYMESSAGE ,0,0);<br>
 
同意楼上<br>另外:<br>Self.Perform(WM_MYMESSAGE,0,0) ;<br>不是更省事
 
对于贴主的情况,Carson_zzd说得对,但Perform是绕过了Windows的消息循环的,只是VCL的消息循环,<br>这一点是要注意的。
 
后退
顶部