我自己生成个Tshapek控件,然后想通过鼠标的操作对生成的控件移动?procedure TForm1.Button1Click(Sender: TObject);
var
g:TGPGraphics;
p:TGPPen;
myshape:TShape;
begin myshape:=TShape.Create(self);
myshape.Parent:=Form1;
myshape.Width:=50;
myshape.Height:=50;
myshape.Pen.Color:=clred;
myshape.Shape:=stcircle;
myshape.Left:=random(150);
myshape.Top:=random(100);
end;
我想动态的生成shape然后,用鼠标对他移动,(有贴加的,到时候还考虑哪个在上面)!谢谢了
var
g:TGPGraphics;
p:TGPPen;
myshape:TShape;
begin myshape:=TShape.Create(self);
myshape.Parent:=Form1;
myshape.Width:=50;
myshape.Height:=50;
myshape.Pen.Color:=clred;
myshape.Shape:=stcircle;
myshape.Left:=random(150);
myshape.Top:=random(100);
end;
我想动态的生成shape然后,用鼠标对他移动,(有贴加的,到时候还考虑哪个在上面)!谢谢了
解决方案 »
- 大家平时都用什么皮肤控件?发现BusinessSkinForm好多的Bug!!!
- 使用SHChangeNotifyRegister函数监控系统文件操作,但是如果一次复制->粘贴大于10个文件时,怎么会只获得10个建立文件的消息呢?
- 请问一下怎么调用NERO的SDK开发刻录软件?
- 如何让一个窗体显示在其他任何程序的最前面?
- NTDLL.DLL文件是作什么用的?
- 我的Delphi6中怎么没有FrameForm和EditForm呢?
- 好想学好DELPHI。请高手指点!!!!!!!!
- 哪里有日期值可为空的日期控件?
- 初学DELPHI请大家推荐几本好书.
- delphi的bug,百思不结
- 请问如何在多选项卡(tabcontrol)控件中内嵌网页?
- 注册表中rdUnknown类型的类型怎么读出来
PropInfo: PPropInfo; // 要使用 TypInfo 单元
k: integer;
begin
for k := 0 to Self.ControlCount-1 do
begin
if not (Controls[k] is TShape) then
Continue;
propInfo := GetPropInfo(Self.Controls[k], 'Left');
if propInfo <> nil then // 存在属性
begin
if TShape(Controls[k]).Name = 'Shape1' then//根据名称找
TShape(Controls[k]).Left := 200;
end;
end;
end;
procedure TForm1.ConMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
releasecapture;
end;
procedure TForm1.ConMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Con := TControl(Sender);
setcapturecontrol(TControl(Sender));
zX := X;
zY := Y;
end;
procedure TForm1.ConMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
ds : tcontrol;
begin
ds := getcapturecontrol;
if ds = nil then exit;
ds.Left := ds.Left + X - zX;
ds.Top := ds.Top + Y - zY;
end;
procedure TForm1.Button1Click(Sender: TObject);
var x:integer;
begin
for x:=0 to 10 do
begin
with tbutton.create(nil) do
begin
parent:=self;
left:=20;
height:=20;
top:=x*20+50;
caption:=inttostr(x);
tag:=x;
OnMouseDown := conMouseDown;
OnMouseMove := conMouseMove;
OnMouseUp := conMouseUp;
end;
end;
end;