var
FpNotify : PNotifyIconDataA;New(FpNotify);
with FpNotify^ do
begin
Wnd := Handle;
uID := 0;
uFlags := NIF_ICON + NIF_MESSAGE + NIF_TIP;
hIcon := Icon.Handle;
uCallbackMessage := c_nTaskIcoMsg;
szTip := 'My program';
end;
Shell_NotifyIcon(NIM_ADD, FpNotify);
FpNotify : PNotifyIconDataA;New(FpNotify);
with FpNotify^ do
begin
Wnd := Handle;
uID := 0;
uFlags := NIF_ICON + NIF_MESSAGE + NIF_TIP;
hIcon := Icon.Handle;
uCallbackMessage := c_nTaskIcoMsg;
szTip := 'My program';
end;
Shell_NotifyIcon(NIM_ADD, FpNotify);
解决方案 »
- 救助。如何分辨字符,并转化
- 单击label使得label控件能够进行编辑,这要怎么做???
- 请问各位大哥,大姐们,扩展名为Rwx的报表文件用什么软件做的啊?有没有知道啊?高分求解啊
- 如何做一个comboboxtreeview的组件?怎么做?最好有代码!!!
- 用simpledataset组件连接sql server数据库为何不让我对表中得数据进行修改,提示“Field value required"是什么意思????
- cdkogh(xp++)请到这里来
- 如何限制inputbox函数的输入位数?
- 如何随机地选取任意几条数据
- Borland終於售出CodeGear
- 我想实现程序象OICQ一样最小化时放在右下角,并且图标也可以控制一闪一闪的,如何做,最好有DEMO,谢谢
- 谁教我什么是包,马上送出60分,先道先得
- help,help,小弟求救!
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ShellAPI, Menus;
const
WM_TRAYICON=WM_APP+0;
type
TForm1 = class(TForm)
btnadd: TButton;
btndelete: TButton;
tryMenu: TPopupMenu;
Hello1: TMenuItem;
Exit1: TMenuItem;
procedure btnaddClick(Sender: TObject);
procedure WMTTRAYICON(var message:Tmessage);message WM_TRAYICON;
procedure FormCreate(Sender: TObject);
procedure btndeleteClick(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure Hello1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
Nidata:TNotifyIconData;
implementation{$R *.dfm}procedure TForm1.btnaddClick(Sender: TObject);begin Shell_NotifyIcon(NIM_ADD,@Nidata);
end;procedure Tform1.WMTTRAYICON(var message:Tmessage);
var
MousePos:TPoint;
begin
if message.LParam=WM_RBUTTONDOWN then
begin
setactiveWindow(form1.Handle);
Getcursorpos(MousePos);
TryMenu.Popup(MousePos.X,MousePos.Y);
end;
if message.LParam=WM_LBUTTONDBLCLK then
begin
setactiveWindow(form1.Handle);
messagebox(form1.Handle,'hello','hello',0);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with Nidata do
begin
cbsize:=sizeof(TNotifyIconData);
uID:=0;
uFlags:=NIF_MESSAGE or NIF_ICON or NIF_TIP;
wnd:=form1.Handle;
uCallbackMessage:=WM_TRAYICON;
hIcon:=Application.Icon.Handle;
StrPCopy(szTip,'hello!');
end;
end;procedure TForm1.btndeleteClick(Sender: TObject);
begin
Shell_NotifyIcon(NIM_DELETE,@Nidata);
end;procedure TForm1.Exit1Click(Sender: TObject);
begin
application.Terminate;
end;procedure TForm1.Hello1Click(Sender: TObject);
begin
messagebox(form1.Handle,'successful!','warning',2);
end;end.
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;