procedure TFScanner.FormCreate(Sender: TObject); var Nid: TNotifyIconData; begin MyThread := TScanThread.Create(False); Nid.cbSize := sizeof(Nid); Nid.Wnd := Self.Handle; Nid.uID := 0; Nid.hIcon := Application.Icon.Handle; Nid.szTip := 'LigSms监测程序'; Nid.uCallbackMessage := MY_MESSAGE; Nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE; if not Shell_NotifyIcon(NIM_ADD,@Nid) then begin MessageBox(handle,'程序初始化失败,请重新启动','程序错误',MB_OK or MB_ICONERROR); Exit; end; end. 老早做的程序了
这两个程序示例我都有,呵呵,你找对人了,给我发消息,将Email发给我,我给你发过来
const WM_TrayMessage=WM_User+100; .............. procedure AppMinimized(Sender: TObject); procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage; private ......... var NID:TNotifyIconData; ........... procedure TForm1.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 TForm1.AppMinimized(Sender:TObject); begin NID.cbSize:=SizeOf(TNotifyIconData); NID.hIcon:=Application.Icon.Handle; NID.szTip:= 'test'; 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 TForm1.FormCreate(Sender: TObject); begin Application.OnMinimize:=AppMinimized; AppMinimized(nil); Application.Title := 'test'; Application.OnMinimize:=AppMinimized; AppMinimized(nil); form1.WindowState:=wsMinimized; end;
const WM_TrayMessage=WM_User+100; .............. procedure AppMinimized(Sender: TObject); procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage; private ......... var NID:TNotifyIconData; ........... procedure TForm1.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 TForm1.AppMinimized(Sender:TObject); begin NID.cbSize:=SizeOf(TNotifyIconData); NID.hIcon:=Application.Icon.Handle; NID.szTip:= 'test'; 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 TForm1.FormCreate(Sender: TObject); begin Application.OnMinimize:=AppMinimized; AppMinimized(nil); Application.Title := 'test'; Application.OnMinimize:=AppMinimized; AppMinimized(nil); form1.WindowState:=wsMinimized; end;
const WM_TrayMessage=WM_User+100; .............. procedure AppMinimized(Sender: TObject); procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage; private ......... var NID:TNotifyIconData; ........... procedure TForm1.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 TForm1.AppMinimized(Sender:TObject); begin NID.cbSize:=SizeOf(TNotifyIconData); NID.hIcon:=Application.Icon.Handle; NID.szTip:= 'test'; 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 TForm1.FormCreate(Sender: TObject); begin Application.OnMinimize:=AppMinimized; AppMinimized(nil); Application.Title := 'test'; Application.OnMinimize:=AppMinimized; AppMinimized(nil); form1.WindowState:=wsMinimized; end;
var
Nid: TNotifyIconData;
begin
MyThread := TScanThread.Create(False);
Nid.cbSize := sizeof(Nid);
Nid.Wnd := Self.Handle;
Nid.uID := 0;
Nid.hIcon := Application.Icon.Handle;
Nid.szTip := 'LigSms监测程序';
Nid.uCallbackMessage := MY_MESSAGE;
Nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
if not Shell_NotifyIcon(NIM_ADD,@Nid) then
begin
MessageBox(handle,'程序初始化失败,请重新启动','程序错误',MB_OK or MB_ICONERROR);
Exit;
end;
end.
老早做的程序了
WM_TrayMessage=WM_User+100;
..............
procedure AppMinimized(Sender: TObject);
procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage;
private
.........
var
NID:TNotifyIconData;
...........
procedure TForm1.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 TForm1.AppMinimized(Sender:TObject);
begin
NID.cbSize:=SizeOf(TNotifyIconData);
NID.hIcon:=Application.Icon.Handle;
NID.szTip:= 'test';
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 TForm1.FormCreate(Sender: TObject);
begin
Application.OnMinimize:=AppMinimized;
AppMinimized(nil);
Application.Title := 'test';
Application.OnMinimize:=AppMinimized;
AppMinimized(nil);
form1.WindowState:=wsMinimized;
end;
WM_TrayMessage=WM_User+100;
..............
procedure AppMinimized(Sender: TObject);
procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage;
private
.........
var
NID:TNotifyIconData;
...........
procedure TForm1.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 TForm1.AppMinimized(Sender:TObject);
begin
NID.cbSize:=SizeOf(TNotifyIconData);
NID.hIcon:=Application.Icon.Handle;
NID.szTip:= 'test';
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 TForm1.FormCreate(Sender: TObject);
begin
Application.OnMinimize:=AppMinimized;
AppMinimized(nil);
Application.Title := 'test';
Application.OnMinimize:=AppMinimized;
AppMinimized(nil);
form1.WindowState:=wsMinimized;
end;
WM_TrayMessage=WM_User+100;
..............
procedure AppMinimized(Sender: TObject);
procedure WMTrayMessage(var msg:TMessage);message WM_TrayMessage;
private
.........
var
NID:TNotifyIconData;
...........
procedure TForm1.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 TForm1.AppMinimized(Sender:TObject);
begin
NID.cbSize:=SizeOf(TNotifyIconData);
NID.hIcon:=Application.Icon.Handle;
NID.szTip:= 'test';
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 TForm1.FormCreate(Sender: TObject);
begin
Application.OnMinimize:=AppMinimized;
AppMinimized(nil);
Application.Title := 'test';
Application.OnMinimize:=AppMinimized;
AppMinimized(nil);
form1.WindowState:=wsMinimized;
end;