控件拖动的问题(100分)

  • 主题发起人 主题发起人 jzqxs
  • 开始时间 开始时间
J

jzqxs

Unregistered / Unconfirmed
GUEST, unregistred user!
我在form1上放一个edit1,设edit1的属性dragkind为dock,dragmode为dmAutomatic,运行程序edit1就可以拖动了,但一拖动就变成窗体模式,怎样使它不变成仓体模式呢?恳请赐教
 
dragmode:dmMannul
 
改成dmMannul就拖不动了啊
 
高手在哪里?
 
我在form1上放一个edit1,设edit1的属性dragkind为dock,dragmode为dmAutomatic,运行程序edit1就可以拖动了,但一拖动就变成窗体模式,怎样使它不变成窗体模式呢?恳请高手赐教
好久都不见高手呢
 
你是要在窗体内部拖动?
 
是,要在窗体内部拖动
 
拖动控件时,要求控件不变成窗体模式
 
我在form1上放一个edit1,设edit1的属性dragkind为dock,dragmode为dmAutomatic,运行程序edit1就可以拖动了,但一拖动就变成窗体模式,要求拖动edit1时,edit1不变成窗体模式。恳请高手赐教
 
var
dx,dy:integer;
{在edit的onmousedown和mousemove里分别写下面的东西}
procedure TForm1.Edit1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
var
pt:tpoint;
begin
if ssleft in shift then
with TEdit(Sender)do
begin
pt:=ClienttoParent(point(x,y));
Top:=Top+pt.Y-DY;
Left:=Left+pt.X-DX;
DX:=pt.X;
DY:=pt.Y;
end;

end;

procedure TForm1.Edit1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var
pt:tpoint;
begin
if ssleft in shift then
with TEdit(Sender)do
begin
pt:=ClienttoParent(point(x,y));
dx:=pt.X;
dy:=pt.Y;
end;
end;
 
还是不行哦,加了楼上的代码,拖动edit1还是变窗体
 
多谢hs-kill,你的方法对的。
 
hs_kill,我拖动了还想调节大小,怎么做?
 
hs_kill,我拖动了还想调节大小,怎么做?如果能做,请发我邮箱jzqxs@163.com多谢
 
实际上的代码应该这么写,不过8个小黑块你要自己画了:
procedure TForm1.Edit1MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
begin
if (SDM>0) and (ssleft in shift) then
begin
ReleaseCapture;
(Sender as TWinControl).Perform(WM_SysCommand,SDM,0);
end;
end;

procedure TForm1.Edit1MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
const
SC_DragMoveLeft=$f001;
SC_DragMoveRight=$f002;
SC_DragMoveTop=$f003;
SC_DragMoveLeftTop=$f004;
SC_DragMoveRightTop=$f005;
SC_DragMoveBottom=$f006;
SC_DragMoveLeftBottom=$f007;
SC_DragMoveRightBottom=$f008;
SC_DragMove=$f009;
var
tx,ty:integer;
begin
SDM:=0;
if mbLeft=button then
begin
SDM:=SC_DragMove;
With TWinControl(Sender)do
begin
tx:=height div 2;
if x<=10 then
begin
if y<=10 then
SDM:=SC_DragMoveLeftTop
else
if y>=height-10 then
SDM:=SC_DragMoveLeftBottom
else
if (y>=ty-5) and (y<=ty+5) then
SDM:=SC_DragMoveLeft;
end
else
if (x>=tx-5) and (x<=tx+5) then
begin
if y<=10 then
SDM:=SC_DragMoveTop
else
if y>=height-10 then
SDM:=SC_DragMoveBottom;
end
else
if x>=width-10 then
begin
if y<=10 then
SDM:=SC_DragMoveRightTop
else
if y>=height-10 then
SDM:=SC_DragMoveRightBottom
else
if (y>=ty-5) and (y<=ty+5) then
SDM:=SC_DragMoveRight;
end
end;
end;
end;
 
后退
顶部