窗体中有edit、checkbox控件,我想把它们初始化为edit为空,checkbox不选中
因此我做了一个dll,把窗体的名称做为参数传给DLL,为什么不能正常工作呢
如果把初始化过程和可执行程序写在一块就没问题,这是为什么呀?
DLL源码如下
library Wzz_ResetForm;
uses
ExtCtrls,
QStdCtrls,
Forms,
SysUtils,
Dialogs,
StdCtrls,
Classes;
procedure ResetForm(FormName:pointer);stdcall;
var
i:integer;
begin
//FormName.Caption :='asfsdafsdfsdf';
for i:=0 to TForm(FormName).ComponentCount - 1 do
begin
if TForm(FormName).Components[i] is TLabeledEdit then
(TForm(FormName).Components[i] as TLabeledEdit).Text:='45245';
{if TForm(FormName).Components[i] is TCheckbox then
TCheckbox(TForm(FormName).Components[i]).Checked:=false;}
showmessage(TLabeledEdit(TForm(FormName).Components[i]).Text);
end;
end;
exports
ResetForm;
{$R *.res}begin
end.
因此我做了一个dll,把窗体的名称做为参数传给DLL,为什么不能正常工作呢
如果把初始化过程和可执行程序写在一块就没问题,这是为什么呀?
DLL源码如下
library Wzz_ResetForm;
uses
ExtCtrls,
QStdCtrls,
Forms,
SysUtils,
Dialogs,
StdCtrls,
Classes;
procedure ResetForm(FormName:pointer);stdcall;
var
i:integer;
begin
//FormName.Caption :='asfsdafsdfsdf';
for i:=0 to TForm(FormName).ComponentCount - 1 do
begin
if TForm(FormName).Components[i] is TLabeledEdit then
(TForm(FormName).Components[i] as TLabeledEdit).Text:='45245';
{if TForm(FormName).Components[i] is TCheckbox then
TCheckbox(TForm(FormName).Components[i]).Checked:=false;}
showmessage(TLabeledEdit(TForm(FormName).Components[i]).Text);
end;
end;
exports
ResetForm;
{$R *.res}begin
end.
ResetForm(pointer(窗体名));