C
cemer815
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ShellApi,ImgList, Menus;
const wm_command=wm_user+1000;
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
guan1: TMenuItem;
haoren1: TMenuItem;
kai1: TMenuItem;
procedure FormCreate(Sender: TObject);
// procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
NID:TNotifyIconData;
public
{ Public declarations }
procedure IconTray(var Msg:TMessage); Message wm_command; //托盘
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
self.Caption :='冰自动';
nid.cbSize :=sizeof(nid);
nid.Wnd :=self.Handle;
nid.uID :=1;
nid.uCallbackMessage := wm_command;
nid.hIcon :=Application.Icon.Handle;
nid.szTip :='冰自动';
nid.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
shell_NotifyIcon(NiM_Add,@nid);
end;
procedure TForm1.IconTray(var msg: TMessage);
var
pt: TPoint;
begin
if Msg.LParam=wm_rbuttondown then //鼠标右键
begin
SetForeGroundWindow(Form1.Handle);
GetCursorPos(pt);
// PopupEx(Self, PopupMenu1, PT.x, PT.y);
PopupMenu1.Popup(pt.x,pt.y);
end;
if Msg.LParam=WM_LBUTTONDBLCLK then //鼠标左键双击
begin
Form1.Show;
SetForeGroundWindow(form1.Handle);
end;
//inherited; //将消息传给祖先对象的处理过程;
end;
end.
大家帮看看
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ShellApi,ImgList, Menus;
const wm_command=wm_user+1000;
type
TForm1 = class(TForm)
PopupMenu1: TPopupMenu;
guan1: TMenuItem;
haoren1: TMenuItem;
kai1: TMenuItem;
procedure FormCreate(Sender: TObject);
// procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
NID:TNotifyIconData;
public
{ Public declarations }
procedure IconTray(var Msg:TMessage); Message wm_command; //托盘
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
self.Caption :='冰自动';
nid.cbSize :=sizeof(nid);
nid.Wnd :=self.Handle;
nid.uID :=1;
nid.uCallbackMessage := wm_command;
nid.hIcon :=Application.Icon.Handle;
nid.szTip :='冰自动';
nid.uFlags := NIF_ICON or NIF_MESSAGE or NIF_TIP;
shell_NotifyIcon(NiM_Add,@nid);
end;
procedure TForm1.IconTray(var msg: TMessage);
var
pt: TPoint;
begin
if Msg.LParam=wm_rbuttondown then //鼠标右键
begin
SetForeGroundWindow(Form1.Handle);
GetCursorPos(pt);
// PopupEx(Self, PopupMenu1, PT.x, PT.y);
PopupMenu1.Popup(pt.x,pt.y);
end;
if Msg.LParam=WM_LBUTTONDBLCLK then //鼠标左键双击
begin
Form1.Show;
SetForeGroundWindow(form1.Handle);
end;
//inherited; //将消息传给祖先对象的处理过程;
end;
end.
大家帮看看