F
flymyhart
Unregistered / Unconfirmed
GUEST, unregistred user!
我想做一个自动创建控件的程序!
可是我发现 线程里只要 调用 控件的Parent 属性 就会出错!!
程序 如下(我先做的一个例子!)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
count: integer;
implementation
{$R *.dfm}
procedure createdit;stdcall;
var
edit1:TEdit;
begin
edit1:=TEdit.create(self);
edit1.Parent:=Form1;
edit1.Top:=20;
edit1.Left:=50;
edit1.Height:=10;
edit1.Width:=30;
sleep(10);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
_d:dword;
begin
CreateThread(nil,0,@createdit,nil,0,_d);
end;
end.
可是我发现 线程里只要 调用 控件的Parent 属性 就会出错!!
程序 如下(我先做的一个例子!)
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
count: integer;
implementation
{$R *.dfm}
procedure createdit;stdcall;
var
edit1:TEdit;
begin
edit1:=TEdit.create(self);
edit1.Parent:=Form1;
edit1.Top:=20;
edit1.Left:=50;
edit1.Height:=10;
edit1.Width:=30;
sleep(10);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
_d:dword;
begin
CreateThread(nil,0,@createdit,nil,0,_d);
end;
end.