How to keep window always on top

前端 未结 3 1564
自闭症患者
自闭症患者 2021-01-16 06:35

How I can keep my window staying always on top even if there is a window of another application with Topmost = true option activated and trying to stay in front

3条回答
  •  失恋的感觉
    2021-01-16 06:55

    You can do a platform invoke on BringWindowToTop to achieve this:

    [DllImport("user32.dll", SetLastError=true)]
    static extern bool BringWindowToTop(IntPtr hWnd);
    
    [DllImport("user32.dll", SetLastError=true)]
    static extern bool BringWindowToTop(HandleRef hWnd);
    

    And call to it when the FocusLost event fires.

提交回复
热议问题