熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#SetWindowPos窗口置頂

2013-11-13 10:40:02  來源: .NET編程 

  [DllImport("userdll" CharSet = CharSetAuto)]
private static extern int SetWindowPos(IntPtr hWnd int hWndInsertAfter int x int y int Width int Height int flags);
/// <summary>
/// 得到當前活動的窗口
/// </summary>
/// <returns></returns>
[DllImport("userdll" CharSet = CharSetAuto)]
private static extern SystemIntPtr GetForegroundWindow();

  哪個窗體想要置頂在Form_Load中加上

  SetWindowPos(thisHandle | ); //最後參數也有用 |  
具體說明看API函數說明
如果是用點擊一個按鈕後彈出新窗體並置頂

  Form frm = new Form();
frmShow();
SetWindowPos(GetForegroundWindow() | );


From:http://tw.wingwit.com/Article/program/net/201311/14257.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.