procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if Button =mbLeft then
begin ReleaseCapture;
Perform(WM_NCLBUTTONDOWN, HTCAPTION, 0);
end;end;
Shift: TShiftState; X, Y: Integer);
begin
if Button =mbLeft then
begin ReleaseCapture;
Perform(WM_NCLBUTTONDOWN, HTCAPTION, 0);
end;end;
解决方案 »
- C++ 这段头文件里的代码那位高手帮忙翻译成pascal
- 请问民航在线售票系统是用什么语言/数据库开发的?
- 数据库表的复制问题!!
- 【请高人救命!猛料中的LZW压缩单元使用出错,请得道高人赐教!感激涕零!!!】
- 一个公司如何保护原代码?
- 问题 ???
- 为什么我的用户名不好使?
- 没办法,自己解答不出,只好再提一次。谁能帮我?
- 大哥、大嫂,救小弟:用‘select sum(数字字段)’怎么样设定才将值null变为0
- 如果TQUICKREP的DATASET是TQUERY(not TTABlE),如何用TQRExpr算出某一列数的合计数
- 关于object pascal的类的几个基本问题请您解答
- 在win2000下如何关闭计算机(api)
只要处理label的OnMouseDown事件就可
上面是源代码
别只走一条路啊!
呵呵
2、也可以响应LABEL的CLICK事件,然后向FORM发消息:
Perform( WM_SYSCOMMAND, SC_MOVE, 0 );
3、或者响应鼠标事件,当MOUSEMOVE时移动FORM。
1,最常规的方法:编程实现,在button1MouseDown,button1MouseMove中写代码,并在FormCreate,FormResize上加代码,具体如下:
procedure Tform1.FormCreate(Sender: TObject);
var
hr :THandle;
begin
menuopen:=false;
MouseLButtonDown:=False;
hr:=CreateEllipticRgn(0,0,Width,Height);
SetWindowRgn(Handle,hr,True);
end;procedure Tform1.FormResize(Sender: TObject);
var
hr :THandle;
begin
hr:=CreateEllipticRgn(0,0,width,height);
setwindowrgn(handle,hr,true);
end;procedure Tform1.button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
OriginalPos.x:=Form1.Left;
OriginalPos.y:=Form1.Top;
DownPos.x:=X;
DownPos.y:=Y;
DownPos:=ClientToScreen(DownPos);
if Button = mbLeft then
MouseLButtonDown:=True;
end;procedure Tform1.button1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if MouseLButtonDown then
begin
CurrentPos.x:=X;
CurrentPos.y:=Y;
CurrentPos:=ClientToScreen(CurrentPos);
Form1.Left:=OriginalPos.x+(CurrentPos.x-DownPos.x);
Form1.Top :=OriginalPos.y+(CurrentPos.y-DownPos.y);
end;
end;
2,偏招:捕捉windows信息,让windows认为此时你点的不是button,而是标题栏,具体代码我要去找找
谢谢你的回答.
请问你说的第一种方法在移动窗体时会出现虚线框吗?
我需要会出现虚线框的方法.
我也想找这种方法,你给出的是这样的代码吗?
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
Perform(WM_SysCommand, SC_MOVE or 2, 0);
end;
你的方法成功了,可是一去掉 or 2,就不行,能解释一下 or 2是什么意思吗?
begin
if (Msg.message=WM_LButtonDown) and(DefWindowProc(Handle,WM_NCHitTest,0,GetMessagePos)=HTClient)
then
begin
SendMessage(Handle,WM_NCLButtonDown, HTCaption,GetMessagePos);
Handled:=true;
end;
end;