Q
qf0421
Unregistered / Unconfirmed
GUEST, unregistred user!
我想让控件在程序运行时可以被用户用鼠标移动,下面是代码:
procedure WMLBUTTONDOWN(var Msg:TMessage);message WM_LBUTTONDOWN;
procedure WMLBUTTONUP(var Msg:TMessage);message WM_LBUTTONUP;
procedure WMMOUSEMOVE(var Msg:TMessage);message WM_MOUSEMOVE;
implementation
procedure TDataMdl.WMLBUTTONDOWN(var Msg:TMessage);
begin
fmousex:=Msg.LParamLo;
fmousey:=Msg.LParamHi;
fwanttomove:=true;
end;
procedure TDataMdl.WMLBUTTONUP(var Msg:TMessage);
begin
fwanttomove:=false;
nd;
procedure TDataMdl.WMMOUSEMOVE(var Msg:TMessage);
var x,y:integer;
begin
if fwanttomove then
begin
x:=Msg.LParamLo;
y:=Msg.LParamHi;
left:=left+(x-fmousex);
top:=top+(y-fmousey);
end;
end;
可当鼠标移动过快时就移出了控件的客户区,从而使控件接收不到
WM_MOUSEMOVE,导致给人的感觉是移动发滞,我想用SetCapture
可这个控件不是从TWinControl继承的,没有HANDLE.
有那位大虾知道该怎么办?
在下先有礼了!!
procedure WMLBUTTONDOWN(var Msg:TMessage);message WM_LBUTTONDOWN;
procedure WMLBUTTONUP(var Msg:TMessage);message WM_LBUTTONUP;
procedure WMMOUSEMOVE(var Msg:TMessage);message WM_MOUSEMOVE;
implementation
procedure TDataMdl.WMLBUTTONDOWN(var Msg:TMessage);
begin
fmousex:=Msg.LParamLo;
fmousey:=Msg.LParamHi;
fwanttomove:=true;
end;
procedure TDataMdl.WMLBUTTONUP(var Msg:TMessage);
begin
fwanttomove:=false;
nd;
procedure TDataMdl.WMMOUSEMOVE(var Msg:TMessage);
var x,y:integer;
begin
if fwanttomove then
begin
x:=Msg.LParamLo;
y:=Msg.LParamHi;
left:=left+(x-fmousex);
top:=top+(y-fmousey);
end;
end;
可当鼠标移动过快时就移出了控件的客户区,从而使控件接收不到
WM_MOUSEMOVE,导致给人的感觉是移动发滞,我想用SetCapture
可这个控件不是从TWinControl继承的,没有HANDLE.
有那位大虾知道该怎么办?
在下先有礼了!!