J
jzx
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么formhide只执行一次就不在执行了?
代码:
procedure wmmytrayiconcallback(var Msg : TMessage); //处理点击托盘图标的事件
message WM_MYTRAYICONCALLBACK;
procedure FormHide(Sender : TObject);//当用户单击最小化按钮的处理过程
......
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMinimize := FormHide;
end;
procedure TForm1.wmmytrayiconcallback(var Msg: TMessage);
//处理点击托盘图标的事件,根据 WM_MOUSEMOVE 消息的不同情况产生不同的回应
var
CursorPos : TPoint;
begin
Form1.WindowState :=wsNormal;
PopupMenu1.AutoPopup:=False;
case Msg.lParam of
//左键双击
WM_LBUTTONDBLCLK : begin
Application.ShowMainForm := True;
SetForegroundWindow(Application.Handle);
end;
//右键按下
WM_RBUTTONDOWN : begin
GetCursorPos(CursorPos);
PopupMenu1.Popup(CursorPos.x,CursorPos.y);
end;
end//case
end;
procedure TForm1.FormHide(Sender: TObject);
begin
Perform(WM_MYTRAYICONCALLBACK,0,WM_LBUTTONDBLCLK);
inherited;
end;
代码:
procedure wmmytrayiconcallback(var Msg : TMessage); //处理点击托盘图标的事件
message WM_MYTRAYICONCALLBACK;
procedure FormHide(Sender : TObject);//当用户单击最小化按钮的处理过程
......
procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMinimize := FormHide;
end;
procedure TForm1.wmmytrayiconcallback(var Msg: TMessage);
//处理点击托盘图标的事件,根据 WM_MOUSEMOVE 消息的不同情况产生不同的回应
var
CursorPos : TPoint;
begin
Form1.WindowState :=wsNormal;
PopupMenu1.AutoPopup:=False;
case Msg.lParam of
//左键双击
WM_LBUTTONDBLCLK : begin
Application.ShowMainForm := True;
SetForegroundWindow(Application.Handle);
end;
//右键按下
WM_RBUTTONDOWN : begin
GetCursorPos(CursorPos);
PopupMenu1.Popup(CursorPos.x,CursorPos.y);
end;
end//case
end;
procedure TForm1.FormHide(Sender: TObject);
begin
Perform(WM_MYTRAYICONCALLBACK,0,WM_LBUTTONDBLCLK);
inherited;
end;