不用標題欄拖動視窗最簡單的方法

2021-04-01 17:49:25 字數 600 閱讀 8217

csdn上看到的方法,自己整理了一下。

按任意位置都能拖動:

procedure tform1.formmousedown(sender: tobject; button: tmousebutton;

shift: tshiftstate; x, y: integer);

begin

if button=mbleft then

begin

releasecapture;

form1.perform(wm_syscommand, $f012, 0);

end;

end;

按固定位置拖動:

procedure tform1.image1mousedown(sender: tobject; button: tmousebutton;

shift: tshiftstate; x, y: integer);

begin

if button=mbleft then

begin

releasecapture;

form1.perform(wm_syscommand, $f012, 0);

end;

end;

拖動無標題欄窗體

遇到這個問題,解決如下 1.引入名稱空間 using system.runtime.interopservices 2.dllimport user32.dll public static extern bool releasecapture dllimport user32.dll public ...

移動無標題欄視窗

一般情況下,移動一個窗體需要將滑鼠放置在標題欄上才能拖動窗體,為 什麼非要使用標題欄呢?其實我們可以使用一個巧妙的方法來實現將滑鼠放置 在窗體上按下就可拖動窗體,下面先看實現 在form1的 private 部分宣告過程 在private部分加入下列 procedure wmnchittest va...

PB去掉視窗標題欄

setwindowpos函式把視窗的顯示層次修改為hwnd topmost,就可使指定視窗永遠不會被其它視窗覆蓋,該函式宣告為 function long setwindowpos long hwnd,long ord,long x,long y,long dx,long dy,long uflag...

關於去除視窗標題欄

用vs2010在xp下寫的一個程式,在xp中執行正常 螢幕鋪滿 放到win7下就出現介面底部與windows工作列之間有一條空白。尋之最終發現與 ws caption 視窗風格有關。之前去除標題欄的 如下 lresult cmainframe oncreate uint umsg,wparam wp...

QT 去掉標題欄和去掉標題欄後移動視窗

在用qt編寫介面時,去掉標題欄方法比較簡單,就一行 this setwindowflags qt framelesswindowhint 去掉以後又發現一個問題,就是不能移動視窗了,於是我就重寫了三個滑鼠事件,大致 如下 h檔案的 include protected void mousepresse...