用C#写了个小winform系统
我让它托盘了
可是点击显示时不能像有的应用程序一样显示在最前面
我要的不是像TopMost那样,点击显示窗体其他窗体都不能点了托盘图标点击事件这样写的
  if (this.Visible)
            {
            
                this.Hide();
               this.Visible = false;
                this.WindowState = FormWindowState.Minimized;
                this.MyNotifyIcon.Visible = true;                //this.ShowInTaskbar = false; 
            }
            else
            {
                          this.Visible = true;
              this.WindowState = FormWindowState.Maximized;
              this.MyNotifyIcon.Visible = true;
             
              //this.ShowInTaskbar = true; 
              //this.Show();
                   
            }

解决方案 »

  1.   

    SetForegroundWindow
     [DllImport("user32.dll", CharSet = CharSet.Auto)]
      private static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags);
    //设置顶层窗口
      SetWindowPos( Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE||SWP_NOSIZE);  
      

  2.   

     [DllImport("user32.dll")]
            public static extern int SetForegroundWindow(IntPtr hwnd);...............else
      {
          this.Visible = true;
      this.WindowState = FormWindowState.Maximized;
      this.MyNotifyIcon.Visible = true;
       SetForegroundWindow(this.Handle) 
      //this.ShowInTaskbar = true;  
      //this.Show();
        
      }