问题是这样的:有一个Form窗体,Form上有一个Button,我想实现的效果是当程序跑起来后,当鼠标左键单击Button时,获得对Button的控制权,这时Button会跟随鼠标移动,当鼠标停止移动后,再此单击鼠标左键,Button就落在当前的鼠标坐标位置。多谢...
解决方案 »
- delphi中关于动态生成treeview的问题
- Delphi+ApdComPort控件开发串口通讯程序,如果判断当收到规定的数据后触发事件
- -----重金悬赏!:看看这个报表怎么实现(用delphi的 QReport 或Rave)
- 刚开始学,遇到了问题?帮帮忙吧!!
- 项目分析-大家一起来
- ActiveForm调试问题
- 急!!!怎么可以正确的+1啊?
- 在DELPHI下,SOCKET编程,READ,WRITE的问题 (谢谢大家,进来看看也好)
- 在消息钩子中,我可以拦截任意进程的WM_CLOSE,但是怎么阻止该消息继续往下传递呢?
- SQL的语句问题!上次已经提到过了
- 关于向量异常处理
- 如何编程删除桌面IE图标?
Y: Integer);
begin
if (ssLeft in Shift) then begin
ReleaseCapture;
SendMessage(Button1.Handle,WM_SYSCOMMAND,SC_MOVE+1,0);
end;
end;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
Procedure Test(var Msg: TWMNCHITTEST); message WM_NCHITTEST;
{ Public declarations }
end;var
Form1: TForm1;
IsMove: Boolean;implementation{$R *.dfm}
procedure TForm1.Test(var Msg: TWMNCHITTEST);
var
P: TPoint;
begin
inherited;
if IsMove then
begin
P := Point(MsG.XPos, Msg.YPos);
p := ScreenToClient(P);
Button1.Left := P.x + 2;
Button1.Top := p.Y;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
IsMove := not IsMove;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
IsMove := False;
end;
这一句后面的message WM_NCHITTEST;有什么作用?而且有关TWMNCHITTEST、WM_NCHITTEST这些知识又去哪学呢?这个应该是Windows消息机制吧?