我创建了一个Form1窗体,在Form1里添加了一个notifyIcon1和contextMenuStrip1,把notifyIcon1的属性设为:
notifyIcon1.ContextMenuStrip=contextMenuStrip1;
我在notifyIcon1的MouseClick事件里写了下面的代码
        private void notifyIcon1_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                contextMenuStrip1.Show(Cursor.Position);
                
            }
        }
但是在弹出快捷菜单后,在任务栏里出现了一个没有程序名的小方块,如图:怎么才能把这个小方块去掉不让它在任务栏里显示呢?和右键弹出的菜单一模一样呢?

解决方案 »

  1.   

    当最小化程序窗口事件发生的时候
    把ShowInTaskbar=false;
      

  2.   

    在点击左键时模拟点击右键: private readonly int MOUSEEVENTF_RightDown = 0x0008; 
            private readonly int MOUSEEVENTF_RightUp = 0x0010; 
            [DllImport("user32")] 
            public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);         private void notifyIcon1_MouseClick(object sender, MouseEventArgs e) 
            { 
                if (e.Button == MouseButtons.Left) 
                { 
                    mouse_event(MOUSEEVENTF_RightDown, e.X, e.Y, 0, 0); 
                    mouse_event(MOUSEEVENTF_RightUp, e.X, e.Y, 0, 0); 
                } 
            }
    http://topic.csdn.net/u/20081010/09/07b3b1d8-f1d9-427d-81fd-3c08bdb22588.html