W
wgzhou
Unregistered / Unconfirmed
GUEST, unregistred user!
第一次试着写个DLL,就是设置窗体的颜色和字体,代码如下:
procedure getparm(H:HWND; setform:Tform;storefile:string);export;
var
setform: Tsetform;
setform1:Tform;
storefile1:string;
implementation
{$R *.DFM}
procedure getparm(H:HWND;setform:Tform;storefile:string);
begin
try
setform1:=setform;
storefile1:=storefile;
application.handle:=H;
setform:=Tsetform.Create(application);
setform.ShowModal;
finally
setform.free;
end;
end;
procedure Tsetform.Button1Click(Sender: TObject);
begin
if colordialog1.Execute then
setform1.Color:=colordialog1.Color;
end;
//-------------------------
//问题所在:
procedure Tsetform.Button2Click(Sender: TObject);
begin
if fontdialog1.Execute then
begin
// setform1.font:=fontdialog1.font;//使用这个语句时出现:cannot assign a Tfont to a Tfont
// setform1.Font.Color:=fontdialog1.font.Color;//使用它时,正常
//使用以下三条语句的任一条时,form的字体也能变,但退出主程序时,出现访问非法地址的错误
// setform1.font.Name:=fontdialog1.font.Name;
// setform1.font.size:=fontdialog1.font.size;
setform1.font.Style:=fontdialog1.font.Style;
end;
end;
procedure Tsetform.Button3Click(Sender: TObject);
begin
setform.Close;//此行用错误,是不是在DLL中不能用CLOSE
end;
procedure getparm(H:HWND; setform:Tform;storefile:string);export;
var
setform: Tsetform;
setform1:Tform;
storefile1:string;
implementation
{$R *.DFM}
procedure getparm(H:HWND;setform:Tform;storefile:string);
begin
try
setform1:=setform;
storefile1:=storefile;
application.handle:=H;
setform:=Tsetform.Create(application);
setform.ShowModal;
finally
setform.free;
end;
end;
procedure Tsetform.Button1Click(Sender: TObject);
begin
if colordialog1.Execute then
setform1.Color:=colordialog1.Color;
end;
//-------------------------
//问题所在:
procedure Tsetform.Button2Click(Sender: TObject);
begin
if fontdialog1.Execute then
begin
// setform1.font:=fontdialog1.font;//使用这个语句时出现:cannot assign a Tfont to a Tfont
// setform1.Font.Color:=fontdialog1.font.Color;//使用它时,正常
//使用以下三条语句的任一条时,form的字体也能变,但退出主程序时,出现访问非法地址的错误
// setform1.font.Name:=fontdialog1.font.Name;
// setform1.font.size:=fontdialog1.font.size;
setform1.font.Style:=fontdialog1.font.Style;
end;
end;
procedure Tsetform.Button3Click(Sender: TObject);
begin
setform.Close;//此行用错误,是不是在DLL中不能用CLOSE
end;