系统托盘的问题?
我在程序运行时生成了一个托盘,可是我在程序里改变窗体的BorderIcons属性时,托盘就没有了,有什么方法可以让托盘图标不消失?

解决方案 »

  1.   

    >>>可是我在程序里改变窗体的BorderIcons属性时,托盘就没有了,
    那就再生成一次。
      

  2.   

    改变BorderIcons属性应该不会使托盘的图标消失,我这里是没有的,win200+d7
    去掉图标也是用Shell_NotifyIcon,只不过第一个参数是NIM_DELETE;建议先看看这个函数的帮助
      

  3.   

    不知道你改BorderIcons属性的代码是怎么写的,我写了个简单的例子给你
    var
      nid: TNotifyIconData;
    begin
      nid.cbSize:=sizeof(nid);
      nid.uID:=1;
      nid.Wnd:=handle;
      Shell_NotifyIcon(NIM_DELETE,@nid); {这里要先删除,再改BorderIcons属性,不然有假象}
      application.ProcessMessages;
      if checklistbox1.Checked[0] then frmMain.BorderIcons:=frmMain.BorderIcons+[bisystemMenu];
      if checklistbox1.Checked[1] then frmMain.BorderIcons:=frmMain.BorderIcons+[biMinimize];
      if checklistbox1.Checked[2] then frmMain.BorderIcons:=frmMain.BorderIcons+[biMaximize];
      if checklistbox1.Checked[3] then frmMain.BorderIcons:=frmMain.BorderIcons+[biHelp];
      nid.szTip:='';
      nid.cbSize := sizeof(nid);
      nid.Wnd := Handle;
      nid.uID := 1;
      nid.hIcon := Application.Icon.Handle;
      nid.uCallbackMessage := MSG_SERVER;
      nid.uFlags := NIF_ICON or NIF_TIP or NIF_MESSAGE;
      if not Shell_NotifyIcon(NIM_ADD, @nid) then
      begin
        ShowMessage('Failed!');
        Application.Terminate;
      end;