关于托盘的问题,请看我的代码。(50分)

  • 主题发起人 主题发起人 zlyanyan
  • 开始时间 开始时间
Z

zlyanyan

Unregistered / Unconfirmed
GUEST, unregistred user!
我想我的程序运行后在系统托盘处显示,要求无论实双击托盘弹出程序还实最小化程序,都可以在托盘处看到我的程序图标,我现在的代码只是在最小化的时候才会出现在托盘区,如果要在最大化程序时也在托盘区显示图标,该怎么做呀。<br>procedure TBoxForm.WMSysCommand(var Message:TMessage);<br>var<br>&nbsp; &nbsp;lpData:PNotifyIconData;<br>begin<br>&nbsp; if (Message.WParam = SC_MINIMIZE ) then<br>&nbsp; begin<br>&nbsp; &nbsp; &nbsp;//如果用户最小化窗口则将窗口隐藏并在任务栏上添加图标<br>&nbsp; &nbsp; &nbsp;//定义托盘图标结构。<br>&nbsp; &nbsp; &nbsp;lpData := new(PNotifyIconDataA);<br>&nbsp; &nbsp; &nbsp;//lpData变量字节数。<br>&nbsp; &nbsp; &nbsp;lpData.cbSize := 88;<br>&nbsp; &nbsp; &nbsp;//SizeOf(PNotifyIconDataA);<br>&nbsp; &nbsp; &nbsp;lpData.Wnd := self.Handle;<br>&nbsp; &nbsp; &nbsp;//要加入的图标句柄,可任意指定,此处为在Tform中Icon属性中指定的图标。<br>&nbsp; &nbsp; &nbsp;lpData.hIcon := Application.Icon.Handle;<br>&nbsp; &nbsp; &nbsp;//回调函数消息 。<br>&nbsp; &nbsp; &nbsp;lpData.uCallbackMessage := WM_BARICON;<br>&nbsp; &nbsp; &nbsp;//内部标识,可设为任意数。<br>&nbsp; &nbsp; &nbsp;lpData.uID :=0;<br>&nbsp; &nbsp; &nbsp;//托盘信息。<br>&nbsp; &nbsp; &nbsp;lpData.szTip := 'FWS版本升级程序';<br>&nbsp; &nbsp; &nbsp;//指明那些消息有效。<br>&nbsp; &nbsp; &nbsp;lpData.uFlags := NIF_ICON or NIF_MESSAGE &nbsp;or NIF_TIP;<br>&nbsp; &nbsp; &nbsp;//将程序的窗口样式设为TOOL窗口,可避免在任务条上出现<br>&nbsp; &nbsp; &nbsp;SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);<br>&nbsp; &nbsp; &nbsp;//向托盘中添加图标。<br>&nbsp; &nbsp; &nbsp;Shell_NotifyIcon(NIM_ADD,lpData);<br>&nbsp; &nbsp; &nbsp;//释放。<br>&nbsp; &nbsp; &nbsp;dispose(lpData);<br>&nbsp; &nbsp; &nbsp;//设置隐藏。<br>&nbsp; &nbsp; &nbsp;ShowWindow(self.Handle, SW_HIDE);<br>&nbsp; &nbsp; &nbsp;Application.ShowMainForm := false;<br>&nbsp; end<br>&nbsp; else<br>&nbsp; begin<br>&nbsp; &nbsp; //如果是其它的SystemCommand消息则调用系统缺省处理函数处理之。<br>&nbsp; &nbsp; DefWindowProc(self.Handle,Message.Msg,Message.WParam,Message.LParam);<br>&nbsp; end;<br>end;
 
在Additional组件页有一个ApplicationEvents<br><br>它有OnMinimize和OnRestore事件知道怎么做了吧
 
能不能在我的这段程序里写些代码呀。
 
我做完了,还是谢谢你提供的思路。
 
后退
顶部