将程序缩到“托盘”后,为什么死活就是弹不出菜单呢??? 将程序缩到“托盘”后,为什么死活就是弹不出菜单呢???而且我做了消息处理程序,不过好像这段代码是孤立的就这么一个过程,应该跟那里关联一下啊 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 const ID_MAIN = 100;wm_traynotify=wm_user+1000;//这是消息代码把//添加托盘 function TThreadSortForm.AddIcon(h_hwnd: HWND): Boolean;begin nid.cbSize := sizeof(NOTIFYICONDATA); nid.Wnd:= h_hwnd; nid.uID := ID_MAIN; nid.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP; nid.uCallbackMessage := WM_Notify; nid.hIcon := LoadIcon(hInstance, 'MAINICON'); strCopy(nid.szTip, '1111'); AddIcon := Shell_NotifyIcon(NIM_ADD, @nid);end;//接受消息方式一procedure TThreadSortForm.OnNotify(var Msg: TMessage);var Pt: TPoint;begin case msg.LParam of WM_RBUTTONDOWN: begin SetForeGroundWindow(nid.wnd); GetCursorPos(Pt); //Popupmenu.Popup(pt.x, pt.y); popupmenu1.Popup(pt.X,pt.Y); end; WM_LBUTTONDBLCLK: begin Action1Execute(self) end ; //end;end;//接受消息方式二procedure TThreadSortForm.OnNotify(var Msg: TMessage);var Pt: TPoint;begin case msg.LParam of WM_RBUTTONDOWN: begin SetForeGroundWindow(nid.wnd); GetCursorPos(Pt); //Popupmenu.Popup(pt.x, pt.y); popupmenu1.Popup(pt.X,pt.Y); end; WM_LBUTTONDBLCLK: begin Action1Execute(self) end ; //end;end;//这些代码是我在网上找的,原来的程序是可以的,但是跑我这里就不行了55555555555555 程序运行正常,但就是不弹出托盘菜单郁闷ing!!!! const MYMESSAGE=WM_USER+100;{自定义消息,当小图标捕捉到鼠标事件时Windows向回调函数发送此消息}private MyTrayIcon:TNotifyIconData;//定义托盘图标结构 procedure MyTrayMessage(var msg:TMessage); message MYMESSAGE;//托盘消息处理事件procedure Tledform.FormCreate(Sender:TObject);begin {---------------------------} MyTrayIcon.cbSize:=sizeof(MyTrayIcon); MyTrayIcon.Wnd:=Handle; MyTrayIcon.uID:=100;//内部标识,可设为任意数 MyTrayIcon.hIcon:=application.Icon.Handle; MyTrayIcon.uCallbackMessage:=MYMESSAGE;//回调函数消息 MyTrayIcon.szTip:='监控系统'; MyTrayIcon.uFlags:=NIF_ICON or NIF_TIP or NIF_MESSAGE;//指明哪些字段有效 //将程序的窗口样式设为TOOL窗口,可避免在任务条上出现} //SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW); //向托盘中添加图标 Shell_NotifyIcon(NIM_ADD,@MyTrayIcon); {---------------------------}procedure Tledform.MyTrayMessage(var msg:TMessage);var CursorPos:tpoint;begin case msg.lParam of WM_LBUTTONDOWN: begin ShowHidePro; end; WM_RBUTTONDOWN: begin GetCursorPos(CursorPos);//取得光标当前位置 SetForegroundWindow(Handle);//此句作用是当程序失去焦点时,弹出菜单也随之消失。 application.ProcessMessages; PopupMenuLED.Popup(CursorPos.X,CursorPos.Y); PostMessage(application.MainForm.Handle,WM_NULL,0,0); end; end;end;Shell_NotifyIcon(NIM_DELETE,@MyTrayIcon);//系统退出时删除托盘图标 Delphi2007+Dev开发中的一个奇怪问题,请使用过的朋友帮帮忙! tdbchart 中给曲线设置结点是在哪里设置的 谁说说关于本地数据库的全文检索的思路,或介绍介绍资料? 这种DLL是怎么写的? 有dsp开发高手吗(南京的) ASK: Delphi中调用COM接口时发现许多"I"开头的接口都没有, 怎么回事儿? 请教局域网上的问题,在线求助! 显示密码编辑框中的密码 再提:报错 :list index out of bound(0) 请问如何编程控制启动和停止一个2000的服务程序 stack overflow 如何适应不同的分辨率(1280或1440)?
const ID_MAIN = 100;wm_traynotify=wm_user+1000;//这是消息代码把
//添加托盘
function TThreadSortForm.AddIcon(h_hwnd: HWND): Boolean;
begin
nid.cbSize := sizeof(NOTIFYICONDATA);
nid.Wnd:= h_hwnd;
nid.uID := ID_MAIN;
nid.uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
nid.uCallbackMessage := WM_Notify;
nid.hIcon := LoadIcon(hInstance, 'MAINICON');
strCopy(nid.szTip, '1111');
AddIcon := Shell_NotifyIcon(NIM_ADD, @nid);
end;//接受消息方式一procedure TThreadSortForm.OnNotify(var Msg: TMessage);
var
Pt: TPoint;
begin
case msg.LParam of
WM_RBUTTONDOWN:
begin
SetForeGroundWindow(nid.wnd);
GetCursorPos(Pt);
//Popupmenu.Popup(pt.x, pt.y);
popupmenu1.Popup(pt.X,pt.Y);
end; WM_LBUTTONDBLCLK:
begin
Action1Execute(self)
end ;
//end;
end;
//接受消息方式二procedure TThreadSortForm.OnNotify(var Msg: TMessage);
var
Pt: TPoint;
begin
case msg.LParam of
WM_RBUTTONDOWN:
begin
SetForeGroundWindow(nid.wnd);
GetCursorPos(Pt);
//Popupmenu.Popup(pt.x, pt.y);
popupmenu1.Popup(pt.X,pt.Y);
end; WM_LBUTTONDBLCLK:
begin
Action1Execute(self)
end ;
//end;
end;
//这些代码是我在网上找的,原来的程序是可以的,但是跑我这里就不行了
55555555555555
郁闷ing!!!!
const
MYMESSAGE=WM_USER+100;{自定义消息,当小图标捕捉到鼠标事件时Windows向回调函数发送此消息}private
MyTrayIcon:TNotifyIconData;//定义托盘图标结构
procedure MyTrayMessage(var msg:TMessage); message MYMESSAGE;//托盘消息处理事件
procedure Tledform.FormCreate(Sender:TObject);
begin
{---------------------------}
MyTrayIcon.cbSize:=sizeof(MyTrayIcon);
MyTrayIcon.Wnd:=Handle;
MyTrayIcon.uID:=100;//内部标识,可设为任意数
MyTrayIcon.hIcon:=application.Icon.Handle;
MyTrayIcon.uCallbackMessage:=MYMESSAGE;//回调函数消息
MyTrayIcon.szTip:='监控系统';
MyTrayIcon.uFlags:=NIF_ICON or NIF_TIP or NIF_MESSAGE;//指明哪些字段有效
//将程序的窗口样式设为TOOL窗口,可避免在任务条上出现}
//SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
//向托盘中添加图标
Shell_NotifyIcon(NIM_ADD,@MyTrayIcon);
{---------------------------}procedure Tledform.MyTrayMessage(var msg:TMessage);
var
CursorPos:tpoint;
begin
case msg.lParam of
WM_LBUTTONDOWN:
begin
ShowHidePro;
end;
WM_RBUTTONDOWN:
begin
GetCursorPos(CursorPos);//取得光标当前位置
SetForegroundWindow(Handle);//此句作用是当程序失去焦点时,弹出菜单也随之消失。
application.ProcessMessages;
PopupMenuLED.Popup(CursorPos.X,CursorPos.Y);
PostMessage(application.MainForm.Handle,WM_NULL,0,0);
end;
end;
end;Shell_NotifyIcon(NIM_DELETE,@MyTrayIcon);//系统退出时删除托盘图标