C#SetWindowPos窗口置顶
生活随笔
收集整理的這篇文章主要介紹了
C#SetWindowPos窗口置顶
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
C#SetWindowPos窗口置頂
[DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags); /// <summary> /// 得到當前活動的窗口 /// </summary> /// <returns></returns> [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern System.IntPtr GetForegroundWindow();哪個窗體想要置頂,在Form_Load中加上
SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2); //最后參數(shù)也有用1 | 4
具體說明,看API函數(shù)說明
如果是用點擊一個按鈕后彈出新窗體,并置頂,則:
?
?
這樣,新打開的窗體就是置頂了
總結(jié)
以上是生活随笔為你收集整理的C#SetWindowPos窗口置顶的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: U-Net Pytorch实现
- 下一篇: Keras实现LeNet-5网络,与可视