procedure TForm1.Button1Click(Sender: TObject); var Edit:Tedit; begin Edit := TEdit.Create(Form1); with Edit do begin Parent := Form1; Left := Form1.Left+100; Top := Form1.top+100; Width := 100; end; end;
procedure TForm1.Button1Click(Sender: TObject); var Edit:Tedit; begin Edit := TEdit.Create(Form1); with Edit do begin Parent := Form1; Left := Form1.Left+100;//设置Edit的左边位置 Top := Form1.top+100;//设置Edit的高度位置 Width := 100; end; end;
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;type TForm1 = class(TForm) Button1: TButton; //界面放个按钮 procedure Button1Click(Sender: TObject); //添加这个事件 private { Private declarations } procedure MyEditMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); //声明事件 public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject); var Edit:TEdit; begin Edit := TEdit.Create(Form1); with Edit do begin Parent := Form1; Left := Form1.Left+100; Top := Form1.top+100; OnMouseDown := MyEditMouseDown; //赋值事件 end; end; procedure TForm1.MyEditMouseDown(Sender: TObject; Button: TMouseButton; //实现事件 Shift: TShiftState; X, Y: Integer); const SC_DRAGMOVE:longint=$f012; //声明消息 begin ReleaseCapture; sendmessage(TEdit(Sender).Handle,wm_syscommand, SC_DRAGMOVE, 0); //鼠标按下拖动就可以移动 end;end.
procedure tform1.createedit(x:integer;y:integer;w:integer;h:integer); var edit:tedit; begin Edit := TEdit.Create(Form1); with Edit do begin Parent := Form1; setbound(x,y,w,h); end; end;
var
Edit:Tedit;
begin
Edit := TEdit.Create(Form1);
with Edit do
begin
Parent := Form1;
Left := Form1.Left+100;
Top := Form1.top+100;
Width := 100;
end;
end;
呵呵
var Edt:TEdit ;
begin
Edt:=TEdit.Create(self);
Edt.Parent := Form1; //所属区
Edt.Left := 200 ;
Edt.Top := 12 ;
Edt.Visible := true ;
end;
var
Edit:Tedit;
begin
Edit := TEdit.Create(Form1);
with Edit do
begin
Parent := Form1;
Left := Form1.Left+100;//设置Edit的左边位置
Top := Form1.top+100;//设置Edit的高度位置
Width := 100;
end;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Button1: TButton; //界面放个按钮
procedure Button1Click(Sender: TObject); //添加这个事件
private
{ Private declarations }
procedure MyEditMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); //声明事件
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
Edit:TEdit;
begin
Edit := TEdit.Create(Form1);
with Edit do
begin
Parent := Form1;
Left := Form1.Left+100;
Top := Form1.top+100;
OnMouseDown := MyEditMouseDown; //赋值事件
end;
end;
procedure TForm1.MyEditMouseDown(Sender: TObject; Button: TMouseButton; //实现事件
Shift: TShiftState; X, Y: Integer);
const SC_DRAGMOVE:longint=$f012; //声明消息
begin
ReleaseCapture;
sendmessage(TEdit(Sender).Handle,wm_syscommand, SC_DRAGMOVE, 0); //鼠标按下拖动就可以移动
end;end.
procedure tform1.createedit(x:integer;y:integer;w:integer;h:integer);
var
edit:tedit;
begin
Edit := TEdit.Create(Form1);
with Edit do
begin
Parent := Form1;
setbound(x,y,w,h);
end;
end;