2

我开发了一个 Windows 应用程序。在哪个通知表单中每隔 5 分钟显示一次窗口的右下角。如果在我使用记事本/excel 时打开通知表单,焦点会自动转移到 Windows 表单。我想防止这种形式的焦点。有什么解决办法吗?

4

1 回答 1

0

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

[DllImport("User32.dll")] public extern static 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);

于 2012-09-17T13:13:30.967 回答