帮我看看这段代码为什么不能实现???(20分)

  • 主题发起人 主题发起人 superbenben2001
  • 开始时间 开始时间
S

superbenben2001

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.NotifyIconMessage(var Message: TMessage);
var
MousePoint:TPoint;
begin
Case Message.LParam of
WM_LButtonDBLclk:
begin
ShowWindow(handle,SW_SHOW);
end;
WM_RButtonDown:
begin
GetCurSorPos(MousePoint);
Popupmenu1.Popup(MousePoint.X,MousePoint.Y);
Popupmenu2.AutoPopup:=false;
end;
WM_LButtonDown:
begin
GetCurSorPos(MousePoint);
Popupmenu2.Popup(MousePoint.X,MousePoint.Y);
Popupmenu1.AutoPopup:=false;
end;
end;
我设置Popupmenu1和Popmenu2两个弹出菜单.
当按书标左键时弹出Popmenu2, 当按书标右键时弹出Popmenu1 ??
可是却出现了一个问题??
当按书标左键时弹出Popmenu2, 但是再书标右键时,Popmenu1没有弹出??Popmenu2应该消失? 反之也是这样??

应该怎么做?
 
这个问题有点意思。
 
这个问题,说起来比较复杂,
原因就是你接受了消息没有返回。
WM_RButtonDown:
begin
GetCurSorPos(MousePoint);
Popupmenu1.Popup(MousePoint.X,MousePoint.Y);//会挂在这里,
Popupmenu2.AutoPopup:=false;
end;
解决的办法就是让菜单弹出的过程异步执行,让NotifyIconMessage返回。
 
呵呵,好象不是木子说的那样,改成如下就行了:
procedure TForm1.NotifyIconMessage(var Message: TMessage);
var
MousePoint:TPoint;
begin
SetForegroundWindow(Handle); //关键
Case Message.LParam of
WM_LButtonDBLclk:
begin
ShowWindow(handle,SW_SHOW);
end;
WM_RButtonDown:
begin
GetCurSorPos(MousePoint);
Popupmenu1.Popup(MousePoint.X,MousePoint.Y);
end;
WM_LButtonDown:
begin
GetCurSorPos(MousePoint);
Popupmenu2.Popup(MousePoint.X,MousePoint.Y);
end;
end;
 
接受答案了.
 
后退
顶部