C# Win API

變更指定視窗的位置與大小

 函式:MoveWindow

參數型態及說明:
hwnd:Long 要移動或是改變大小的視窗代碼(Handle)
x:Long 視窗左上方的新 X 座標
y:Long 視窗左上方的新 Y 座標
nWidth:Long 調整後視窗的寬
nHeight:Long 調整後視窗的高
bRepaint:Long 調整後視窗是否重繪,若要重繪則設為 True;反之則設為 False

回傳值:
Long 呼叫成功的話,將會回傳非零的數值;若呼叫失敗的話,則回傳 0



//C#的宣告
[DllImport("user32")]
public static extern bool MoveWindow(
 IntPtr hwnd, 
 int x, 
 int y, 
 int nWidth, 
 int nHeight, 
 bool bRepaint
 );
 
bool rtvl;
 
//移動目前執行視窗到(500, 50)的位置,並改變其寬高為500
rtvl = MoveWindow(this.Handle, 500, 50, 500, 500, true);
 
----------------------------------------------------------------------
 
 

留言

這個網誌中的熱門文章