我为程序做了一个菜单,希望能够让用户选择是否有系统托盘,但是不知道具体怎么实现?
往高手来帮忙。procedure TMain.N14Click(Sender: TObject);
begin
if (sender as TMenuITem).Checked then
begin
//Main.Destroy;
//Main.Create(Application);
Shell_NotifyIcon(NIM_ADD,@nid);
//SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
ShowWindow(Application.Handle,SW_Hide);
if not Shell_NotifyIcon(NIM_ADD, @nid) then
begin
ShowMessage('Failed!');
Application.Terminate;
end;
end
else
nid.cbSize := sizeof(nid);
nid.uID :=0;
nid.Wnd := Handle;
Shell_NotifyIcon(NIM_DELETE,@nid);
(sender as TMenuITem).Checked :=not (sender as TMenuITem).Checked ;
我现在写的程序就是这样,没有实现,TNotifyIconData的实例结构我我已经在FormCreate声明了。
往高手来帮忙。procedure TMain.N14Click(Sender: TObject);
begin
if (sender as TMenuITem).Checked then
begin
//Main.Destroy;
//Main.Create(Application);
Shell_NotifyIcon(NIM_ADD,@nid);
//SetWindowLong(Application.Handle, GWL_EXSTYLE, WS_EX_TOOLWINDOW);
ShowWindow(Application.Handle,SW_Hide);
if not Shell_NotifyIcon(NIM_ADD, @nid) then
begin
ShowMessage('Failed!');
Application.Terminate;
end;
end
else
nid.cbSize := sizeof(nid);
nid.uID :=0;
nid.Wnd := Handle;
Shell_NotifyIcon(NIM_DELETE,@nid);
(sender as TMenuITem).Checked :=not (sender as TMenuITem).Checked ;
我现在写的程序就是这样,没有实现,TNotifyIconData的实例结构我我已经在FormCreate声明了。
const
mymsg=Wm_user+1;
var nid:tnotifyicondata;
procedure TForm1.N2Click(Sender: TObject);
begin
N2.Checked:=not N2.Checked;
if N2.Checked then
begin
nid.cbSize:=sizeof(tnotifyicondata);
nid.Wnd:=handle;
nid.uID:=0;
nid.uFlags:=nif_message or nif_icon or nif_tip;
nid.uCallbackMessage:=mymsg;
nid.szTip:='ÄýÁ¦Èí¼þ¿¼ÇÚϵͳ';
nid.hIcon:=form1.Icon.Handle;
shell_notifyicon(nim_add,@nid);
end
else
begin
shell_notifyicon(nim_delete,@nid);
end;
end;
ly_liuyang(Liu Yang) 也谢谢你,但是如果能自己用代码实现,我想还是尽量不要用其他人的组件。