你说的是系统通告栏吧,放到任务栏应该不会吧??
如果是系统通知栏,可以这样做:
unit1
uses shellapi,...;
....
const WM_NOTIFYICON=WM_USER+1;
private
NotifyData:TNotifyIconData;
procedure AddIcon;
procedure RemoveIcon;
protected
Procedure OnNotifyIcon (Var Message : TMessage);Message WN_NOTIFYICON;
procedure TForm1.AddIcon;
begin
NotifyData.cbSize:=Sizeof(NotifyData);
With NotifyData do
begin
Wnd:=Handle;
uID:=1;
uFlags:=NIF_TIP OR NIF_ICON OR NIF_MESSAGE;
hIcon:=Application.Icon.Handle;
szTip:='我的程序'
uCallbackMessage:=WM_NOTIFYICON
end;
Shell_NotifyIcon(NIM_ADD,@NotifyData);
end;procedure TForm1.RemoveIcon;
begin
NotifyIcon.uID:=1;
Shell_NotifyIcon(NIM_DELETE,@NotifyData);
end;procedure TForm1.Button1Click(Sender:TObject);
begin
AddIcon;
end;procedure TForm2.Button2Click(Sender:TObject);
begin
RemoveIcon;
end;
给分吧^_^
如果是系统通知栏,可以这样做:
unit1
uses shellapi,...;
....
const WM_NOTIFYICON=WM_USER+1;
private
NotifyData:TNotifyIconData;
procedure AddIcon;
procedure RemoveIcon;
protected
Procedure OnNotifyIcon (Var Message : TMessage);Message WN_NOTIFYICON;
procedure TForm1.AddIcon;
begin
NotifyData.cbSize:=Sizeof(NotifyData);
With NotifyData do
begin
Wnd:=Handle;
uID:=1;
uFlags:=NIF_TIP OR NIF_ICON OR NIF_MESSAGE;
hIcon:=Application.Icon.Handle;
szTip:='我的程序'
uCallbackMessage:=WM_NOTIFYICON
end;
Shell_NotifyIcon(NIM_ADD,@NotifyData);
end;procedure TForm1.RemoveIcon;
begin
NotifyIcon.uID:=1;
Shell_NotifyIcon(NIM_DELETE,@NotifyData);
end;procedure TForm1.Button1Click(Sender:TObject);
begin
AddIcon;
end;procedure TForm2.Button2Click(Sender:TObject);
begin
RemoveIcon;
end;
给分吧^_^
procedure TForm1.OnNotifyIcon(var Message: TMessage);
Var MousePos:TPoint;
begin
if Message.LParam=WM_LBUTTONDBLCLK then
ShowMessage('呵呵')
else
if (Message.LParam=WM_RBUTTONDOWN) then
begin
GetCursorpos(MousePos);
SetforegroundWindow(Application.Handle);
Application.ProcessMessages;
PopMenu.Popup(MousePos.x,MousePos.y);
end;
end;