我用dll建立了一个窗体,怎么与之里面的控件通讯? 我用dll建立了一个窗体,怎么与之里面的控件通讯? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的DLL是有模式窗体还是无模式窗体! 不知道,你想干什么,不过我知道你这样的想法基本是错误的,这样不符合模块封装的原理,你就不应该去访问DLL里的东西。你应该是在DLL中提供一个方法让EXE去调用从而达到改变或读取组件的状态。不过你要作到这一点也很Easy 主调单元:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DLLUnit;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } FDLLForm: TDllForm; public { Public declarations } end;var Form1: TForm1;function ExportForm: Integer; external 'DLL.dll';procedure FreeForm; external 'DLL.dll';implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin FDLLForm.Edit1.Text := 'abc'; FDLLForm.Show;end;procedure TForm1.FormCreate(Sender: TObject);begin FDLLForm := TDllForm(ExportForm);end;procedure TForm1.FormDestroy(Sender: TObject);begin FreeForm;end;end. 被调单元:unit DLLUnit;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TDllForm = class(TForm) Edit1: TEdit; private { Private declarations } public { Public declarations } end;implementation{$R *.dfm}var DllForm: TDllForm;function ExportForm: Integer;begin if DllForm = nil then DllForm := TDllForm.Create(nil); Result := Integer(DllForm);end;procedure FreeForm;begin if DllForm <> nil then FreeAndNil(DllForm);end;exports ExportForm,FreeForm;end. 关于消息 大家好,请问fastreport的预览窗口在打开时如何刷新? inttohex()后面的那个参数到底有啥用?显示位数?我用什么值代入都是一样结果,怎么回事 为什么这个窗口关不了?? 请各位老师多多帮忙 高分相送 哪位知道Delphi7.0的全部函数,过程下载! 小问题 帮我看看这个出错信息是什么意思?我该怎么改 COM+的问题,很急。。。。 如何把一个句子竖着打印啊??!! 如何删除image控件中的图片??急啊!!! 关于在Access数据库中存字体的Style属性~(期待中。。。。。。)
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DLLUnit;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
FDLLForm: TDllForm;
public
{ Public declarations }
end;var
Form1: TForm1;function ExportForm: Integer; external 'DLL.dll';
procedure FreeForm; external 'DLL.dll';
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
FDLLForm.Edit1.Text := 'abc';
FDLLForm.Show;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
FDLLForm := TDllForm(ExportForm);
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeForm;
end;end.
unit DLLUnit;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TDllForm = class(TForm)
Edit1: TEdit;
private
{ Private declarations }
public
{ Public declarations }
end;implementation{$R *.dfm}var
DllForm: TDllForm;function ExportForm: Integer;
begin
if DllForm = nil then
DllForm := TDllForm.Create(nil);
Result := Integer(DllForm);
end;procedure FreeForm;
begin
if DllForm <> nil then
FreeAndNil(DllForm);
end;exports
ExportForm,FreeForm;end.