C 滑鼠拖拉移動窗體控制項

2021-07-23 15:04:04 字數 820 閱讀 8422

窗體控制項的拖拉

///滑鼠左鍵按下移動控制項的實現

///本例子新建兩個panel1和panel2

///panel1為父級容器

///panel2為panel1的控制項

/// /// panel1的滑鼠移動事件

///

///

///

public bool move = false;

public int tempx;

public int tempy;

[dllimport("user32.dll")]

public static extern bool releasecapture();

[dllimport("user32.dll")]

public static extern intptr setcapture(intptr h);

private void panel1_mousemove(object sender, mouseeventargs e)

}/// /// panel2的滑鼠按鈕按下

///

///

///

private void panel2_mousedown(object sender, mouseeventargs e)

else

}/// /// panel1的滑鼠按鈕彈起

///

///

///

private void panel1_mouseup(object sender, mouseeventargs e)

c 移動窗體和控制項

在winform程式裡面,有時候我們需要移動沒有標題欄窗體或是窗體內的控制項,用幾個事件如滑鼠單擊,移動,等再加上座標的計算可以完成這一功能,但是最近發現了乙個api函式,可以非常簡單方便的完成這個功能。如下 dllimportattribute user32.dll private extern ...

Qt 圓角控制項,圓角窗體,滑鼠拖動窗體

1.設定圓角控制項 connectpb setstylesheet border 2px groove gray border radius 10px padding 2px 4px 設定圓角按鍵 2.設定圓角窗體 setwindowflags qt framelesswindowhint qbit...

vb 點選控制項移動窗體

新增模組 如下 public declare function sendmessage lib user32 alias sendmessagea byval hwnd as long,byval wmsg as long,byval wparam as long,lparam as any as ...