N
newboy123
Unregistered / Unconfirmed
GUEST, unregistred user!
发现菜单弹出后会阻断消息,<br>下面是个试验程序.<br><br>新建程序,在主窗口放 2个label 1个timer 1个popupmenu, popupmenu设为主窗口右键菜单.<br>菜单弹出后,label2就停了<br>哪位帮忙看看, 谢谢!<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, ExtCtrls, StdCtrls, Menus;<br><br>type<br> TForm1 = class(TForm)<br> Label1: TLabel;<br> Label2: TLabel;<br> Timer1: TTimer;<br> PopupMenu1: TPopupMenu;<br> N11111: TMenuItem;<br> N22221: TMenuItem;<br> procedure Timer1Timer(Sender: TObject);<br> procedure FormCreate(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> procedure AppMsg(var msg:TMsg;var hdl:Boolean);<br> end;<br><br>var<br> Form1: TForm1;<br> cnt1:Integer=0;<br> cnt2:Integer=0;<br> msgc:UInt=WM_USER+$1000;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.AppMsg(var msg:TMsg;var hdl:Boolean);<br>begin<br> if msg.message=msgc then<br> begin<br> Inc(cnt2);<br> Label2.Caption := IntToStr(cnt2);<br> hdl := True;<br> end;<br> <br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br> Application.OnMessage := AppMsg;<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>begin<br> Inc(cnt1);<br> Label1.Caption := IntToStr(cnt1);<br> PostMessage(Application.Handle,msgc,0,0);<br>end;<br><br>end.