托盘源码(200分)

  • 主题发起人 主题发起人 shihongtai
  • 开始时间 开始时间
S

shihongtai

Unregistered / Unconfirmed
GUEST, unregistred user!
请给我一个托盘源码?
 
我这有一个带源码的,一会发给你
 
好的!我看看
谢谢
 
我已发给你了
 

到playicq.com下载一个控件,源码可以慢慢看。
 
http://www.tommstudio.com/newclub30/d_viewdownload.asp?type=programs&id=17
这个例子非常简单,演示了如何使用托盘.
http://www.tommstudio.com/newclub30/
 
uses
...,ShellAPI.

const WM_NOTIFYICON=WM_USER+1;



implementation
type
TMainForm = class(TForm)
......
private
IconData:TNotifyIconData;

procedure AddIcon;
procedure RemoveIcon;
procedure windowhide;
procedure windowshow;
procedure OnNotifyicon(var Message:Tmessage);Message WM_NOTIFYICON;

procedure TMainForm.OnNotifyicon(var Message: Tmessage);
var
mypoint:Tpoint;
begin
if Message.LParam = WM_RBUTTONDOWN then
begin
GetCursorPos(mypoint);
setforegroundwindow(application.Handle);
application.ProcessMessages;
PopupMenuTry.popup(mypoint.x,mypoint.y);
end
else if Message.LParam = WM_LBUTTONDBLCLK THEN
Begin
WindowShow;
end;

end;


procedure TMainForm.windowshow;
begin
self.Show;
self.WindowState:=wsNormal;
Application.ShowHint := True;
self.RemoveIcon;
end;

procedure TMainForm.windowhide;
begin

self.WindowState:=wsMinimized;
self.Hide;
Application.HideHint;
self.addicon;
end;


procedure TMainForm.RemoveIcon;
begin
shell_notifyicon(NIM_DELETE,@ICONDATA);
end;


procedure TMainForm.AddIcon;
begin
IconData.cbSize:=sizeof(IconData);
IconData.Wnd:=handle;
IconData.uID:=1000;
IconData.uFlags:=NIF_MESSAGE+NIF_ICON+NIF_TIP;
IconData.uCallbackMessage:=WM_USER+1;
IconData.hIcon:=application.icon.Handle;
IconData.szTip:='Happy';
Shell_NotifyIcon(NIM_ADD,@IconData);
end;
 
后退
顶部