2010-01-28 56 views

回答

8

由于提出了这个问题,我一直在研究这个问题,并且遇到了一个很好的例子,说明如何通过p /在'user32.dll'中调用SetWindowPos来达到这个目的。如果这有效,我会回来接受这个答案。

[DllImport("user32.dll")] 
    static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); 

    static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); 

    const UInt32 SWP_NOSIZE = 0x0001; 
    const UInt32 SWP_NOMOVE = 0x0002; 
    const UInt32 TOPMOST_FLAGS = SWP_NOMOVE | SWP_NOSIZE; 

    public static void MakeTopMost (IntPtr hWnd) 
    { 
     SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, TOPMOST_FLAGS); 
    } 
相关问题