欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

C# SetWindowPos窗口置頂使用說(shuō)明

 更新時(shí)間:2012年12月20日 11:46:52   作者:  
就是有時(shí)候窗口不能夠成功置頂,這時(shí)需要重新切換下標(biāo)簽,就可以置頂了,本文介紹C# SetWindowPos實(shí)現(xiàn)窗口置頂?shù)姆椒?/div>
復(fù)制代碼 代碼如下:

[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>
/// 得到當(dāng)前活動(dòng)的窗口
/// </summary>
/// <returns></returns>
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern System.IntPtr GetForegroundWindow();

哪個(gè)窗體想要置頂,在Form_Load中加上

SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2); //最后參數(shù)也有用1 | 4 
具體說(shuō)明,看API函數(shù)說(shuō)明
如果是用點(diǎn)擊一個(gè)按鈕后彈出新窗體,并置頂,則:
復(fù)制代碼 代碼如下:

Form2 frm = new Form2();
frm.Show();
SetWindowPos(GetForegroundWindow(), -1, 0, 0, 0, 0, 1 | 2);

這樣,新打開(kāi)的窗體就是置頂了
您可能感興趣的文章:

相關(guān)文章

最新評(píng)論