哎。。(10分)

  • 主题发起人 主题发起人 pllink_qyd
  • 开始时间 开始时间
P

pllink_qyd

Unregistered / Unconfirmed
GUEST, unregistred user!
怎麼做得跟QQ,MSN一樣,最下化的時候,顯示在右下角的狀態欄上,出現的是個小圖標。而不是個最小化窗口阿。。是調用API嗎?誰能告訴怎麼做阿?THANKS!
 
各位幫幫忙阿。。。
 
托盘图标
 
THS,但怎麼實現阿??
 
unit Unit1;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, ShellAPI, Menus, StdCtrls, ExtCtrls;<br><br>const<br> &nbsp;WM_BARICON = WM_USER + 200;<br><br>type<br> &nbsp;TForm1 = class(TForm)<br> &nbsp; &nbsp;PopupMenu1: TPopupMenu;<br> &nbsp; &nbsp;show1: TMenuItem;<br> &nbsp; &nbsp;Timer1: TTimer;<br> &nbsp; &nbsp;Label1: TLabel;<br> &nbsp; &nbsp;exit1: TMenuItem;<br> &nbsp; &nbsp;procedure show1Click(Sender: TObject);<br> &nbsp; &nbsp;procedure FormShow(Sender: TObject);<br> &nbsp; &nbsp;procedure Timer1Timer(Sender: TObject);<br> &nbsp; &nbsp;procedure FormClose(Sender: TObject; var Action: TCloseAction);<br> &nbsp; &nbsp;procedure exit1Click(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;lpData: PNotifyIconData;<br> &nbsp; &nbsp;procedure WMSysCommand(var Message: TMessage); message WM_SYSCOMMAND;<br> &nbsp; &nbsp;procedure WMBarIcon(var Message: TMessage); message WM_BARICON;<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br><br>var<br> &nbsp;Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.WMSysCommand(var Message: TMessage);<br>begin<br> &nbsp;if Message.WParam = SC_ICON then<br> &nbsp;begin<br> &nbsp; &nbsp; //如果用户最小化窗口则将窗口隐藏并在任务栏上添加图标<br> &nbsp; &nbsp; lpData := New(PNotifyIconDataA);<br> &nbsp; &nbsp; lpData.cbSize := 88;<br> &nbsp; &nbsp; lpData.Wnd := Form1.Handle;<br> &nbsp; &nbsp; lpData.hIcon := application.Icon.Handle;<br> &nbsp; &nbsp; lpData.uCallbackMessage := WM_BARICON;<br> &nbsp; &nbsp; lpData.uID :=0;<br> &nbsp; &nbsp; lpData.szTip := 'Samples';<br> &nbsp; &nbsp; lpData.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;<br> &nbsp; &nbsp; Shell_NotifyIcon(NIM_ADD,lpData);<br> &nbsp; &nbsp; dispose(lpData);<br> &nbsp; &nbsp; Form1.Visible := False;<br> &nbsp;end<br> &nbsp;else<br> &nbsp;begin<br> &nbsp; &nbsp; //如果是其它的SystemCommand消息则调用系统缺省处理函数处理之。<br> &nbsp; &nbsp; DefWindowProc(Form1.Handle, Message.Msg, Message.WParam, Message.LParam);<br> &nbsp;end;<br>end;<br><br>procedure TForm1.WMBarIcon(var Message: TMessage);<br>begin<br> &nbsp; if (Message.LParam = WM_RBUTTONDOWN) then<br> &nbsp; begin<br> &nbsp; &nbsp; PopupMenu1.Popup(Mouse.CursorPos.X, Mouse.CursorPos.Y);<br> &nbsp; end;<br>end;<br><br>procedure TForm1.show1Click(Sender: TObject);<br>begin<br> &nbsp; //如果用户点击任务栏图标则将图标删除并回复窗口。<br> &nbsp; lpData := new(PNotifyIconDataA);<br> &nbsp; lpData.cbSize := 88;//SizeOf(PNotifyIconDataA);<br> &nbsp; lpData.Wnd := Form1.Handle;<br> &nbsp; lpData.hIcon := Form1.Icon.Handle;<br> &nbsp; lpData.uCallbackMessage := WM_BARICON;<br> &nbsp; lpData.uID :=0;<br> &nbsp; lpData.szTip := 'Samples';<br> &nbsp; lpData.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;<br> &nbsp; Shell_NotifyIcon(NIM_DELETE,lpData);<br> &nbsp; dispose(lpData);<br> &nbsp; Form1.Visible := True;<br>end;<br><br>procedure TForm1.FormShow(Sender: TObject);<br>begin<br> &nbsp;ShowWindow(application.Handle, sw_hide);<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var<br> &nbsp;MeMsg: TMessage;<br>begin<br> &nbsp;Timer1.Enabled := False;<br> &nbsp;MeMsg.WParam := SC_ICON;<br> &nbsp;WMSysCommand(MeMsg);<br>end;<br><br>procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> &nbsp;action := cafree;<br>end;<br><br>procedure TForm1.exit1Click(Sender: TObject);<br>begin<br> &nbsp;show1Click(sender);<br> &nbsp;application.Terminate;<br>end;<br><br>end.
 
不好意思,我剛學Delphi,菜了點。請問show1: TMenuItem;其中TMenuItem是怎麼產生的?是控件對象嗎?為什麼我沒有阿?
 
cooltray4.3
 
Tmenuitem 是delphi定义的一个菜单子项的类<br>delphi中有个菜单控件,他的每项都是一个Tmenuitem类型的子项
 
哦。我知道了。。呵呵。。太菜的問題了。見笑了。。結貼了。。感謝大家。。
 
后退
顶部