你要响应消息才行。自定义一个消息,如:WM_USER_TRAYICON为一个整数。增加时加上NIF_MESSAGE标志,IconData.uFlags := IconData.uFlags or NIF_MESSAGE;然后响应WM_USER_TRAYICON消息:判断参数:
if msg.LParam=WM_RBUTTONDOWN then
begin
GetCursorPos( p );
SetForegroundWindow( Handle );
PopupMenu1.Popup( p.x, p.y );
end
else if msg.LParam=WM_LBUTTONDBLCLK then
默认菜单项.Click;别的看API帮助吧。
if msg.LParam=WM_RBUTTONDOWN then
begin
GetCursorPos( p );
SetForegroundWindow( Handle );
PopupMenu1.Popup( p.x, p.y );
end
else if msg.LParam=WM_LBUTTONDBLCLK then
默认菜单项.Click;别的看API帮助吧。
解决方案 »
- 请问如何将提取出的像数点保存在TXT文件里面,现在是以窗口的形式显示的。请说清楚,我还是个新手。谢谢
- MainMeun 菜单 许多子项目的时候 点的时候子菜单会上移。
- 双网卡不用代理软件怎么设置双机上网?
- 控制 modem 拨打手机号码,(在线等)
- 如何生成DBF文件
- 很简单的问题:用adoquery添加数据时,如何避免某个字段值重复,好像是什么eof,bof,忘了,多谢帮助
- 初次使用dephi.像高手请教关于stringgrid 的问题。能否在stringgrid中插入图片?
- ★★★请关注基于Delphi的强大三层框架,目前已经形成了一个活跃的用户群体
- 大家过来看看...
- 关闭应用程序总是提示“access violation at address XXXXXX in module *.ocx read of address FFFFFFF” 是怎么回事?各位大虾帮帮小弟。^-^
- 在delphi中如何学习api??
- 请问copy(longid,4,3)怎样解释?
WM_TrayMessage=WM_User+100; protected
procedure AppMinimized(Sender: TObject);
procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage;uses ShellApivar
NID:TNotifyIconData{点击了任务栏的图标}
procedure TMainForm.WMTrayMessage(var msg:TMessage);
var
p:TPoint;
begin
if msg.LParam=WM_LButtonDown then
begin
ShowWindow(Application.Handle,SW_Show);
Application.Restore;
end
else if msg.LParam=WM_RButtonDown then
begin
GetCursorPos(p);
pmTray.Popup(p.x,p.y);
end;
end;{应用程序最小化时图标显示在任务栏}
procedure TMainForm.AppMinimized(Sender:TObject);
begin
NID.cbSize:=SizeOf(TNotifyIconData);
NID.hIcon:=Application.Icon.Handle;
NID.szTip:= '彩虹2.0 Beta ';
NID.uCallbackMessage:=WM_TrayMessage;
NID.uFlags:=NIF_ICON or NIF_MESSAGE or NIF_TIP;
NID.uID:=0;
NID.Wnd:=Handle;
Shell_NotifyIcon(NIM_ADD,@NID);
ShowWindow(Application.Handle,SW_Hide);
end;procedure TMainForm.FormCreate(Sender: TObject);
begin
Application.OnMinimize:=AppMinimized;
AppMinimized(nil);
end;procedure TMainForm.FormDestroy(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@NID);
end;
IconData.uCallbackMessage := WM_USER_TRAYICON;