从窗体中移除焦点

问题描述:

我开发了一个Windows应用程序。每隔5分钟显示窗口右下角的通知表单。如果通知表单打开时,我在记事本/ Excel中工作,焦点自动转移到Windows窗体。我想阻止这种形式的焦点。有没有解决方法?从窗体中移除焦点

+0

因此出现弹出窗口,但您不希望焦点切换到该位置,而是保持原位? – Dave

+0

您使用Show/Hide的方法是什么? – Prasanna

+0

简写为this.visible = true。 – watraplion

下面的代码工作正常..谢谢大家..

函数[DllImport( “User32.dll中”) 公众的extern静态INT的ShowWindow(IntPtr的的HWND,的Int32 cmdShow);

const Int32 SW_SHOWNOACTIVATE = 4; 
    const Int32 SWP_NOACTIVATE = 0x0010; 
    const Int32 HWND_TOPMOST = -1; 

    [DllImport("User32.dll")] 
    public extern static bool SetWindowPos(
     IntPtr hWnd, // handle to window 
     Int32 hWndInsertAfter, // placement-order handle 
     Int32 X, // horizontal position 
     Int32 Y, // vertical position 
     Int32 cx, // width 
     Int32 cy, // height 
     Int32 uFlags // window-positioning options 
     ); 

,当你显示弹出呼叫以下方法:

的ShowWindow(this.Handle,SW_SHOWNOACTIVATE);