月
月明风轻
Unregistered / Unconfirmed
GUEST, unregistred user!
程序使用DLL插件形式,
在主程序和DLL程序中都引用了dxBar的话会出现 "A class name TdxBar already exists";
此时我只有在DLL中用了dxBarmanager
如果我只在DLL程序中引用了dxBar单元就能够正常调用DLL窗体.
分不够再加
主窗体部分代码:
var
AForm: TForm;
CreateWindow: function(ParentApplication: TApplication;
ParentScreen: TScreen): TForm;
stdcall;
begin
hMod := LoadLibrary(PChar(ExtractFilePath(Application.ExeName) + 'PrjTest.dll'));
if hMod = 0 then
begin
ShowMessage('找不到文件');
Exit;
end;
@CreateWindow := GetProcAddress(hMod, 'CreateWindow');
if @CreateWindow <> nil then
begin
AForm := CreateWindow(Application, Screen);
cxPageCtrl_1.ActivePage.Caption := AForm.Caption;
AForm.Parent := cxPageCtrl_1.ActivePage;
AForm.FormStyle := fsNormal;
AForm.BorderStyle := bsNone;
AForm.Align := alClient;
AForm.Show;
end;
DLL部分代码
var
DLLApplication: TApplication;
DLLScreen: TScreen;
Form1: TForm1;
{$R *.res}
function CreateWindow(ParentApplication: TApplication;
ParentScreen: TScreen): TForm;
stdcall;
begin
if DLLApplication=nil then
begin
DLLApplication:=Application;
Application:=ParentApplication;
end
else
Application:=ParentApplication;
if DLLScreen=nil then
begin
DLLScreen:=Screen;
Screen:=ParentScreen;
end
else
Screen:=ParentScreen;
Form1 := TForm1.Create(nil);
Result := Form1 as TForm;
end;
在主程序和DLL程序中都引用了dxBar的话会出现 "A class name TdxBar already exists";
此时我只有在DLL中用了dxBarmanager
如果我只在DLL程序中引用了dxBar单元就能够正常调用DLL窗体.
分不够再加
主窗体部分代码:
var
AForm: TForm;
CreateWindow: function(ParentApplication: TApplication;
ParentScreen: TScreen): TForm;
stdcall;
begin
hMod := LoadLibrary(PChar(ExtractFilePath(Application.ExeName) + 'PrjTest.dll'));
if hMod = 0 then
begin
ShowMessage('找不到文件');
Exit;
end;
@CreateWindow := GetProcAddress(hMod, 'CreateWindow');
if @CreateWindow <> nil then
begin
AForm := CreateWindow(Application, Screen);
cxPageCtrl_1.ActivePage.Caption := AForm.Caption;
AForm.Parent := cxPageCtrl_1.ActivePage;
AForm.FormStyle := fsNormal;
AForm.BorderStyle := bsNone;
AForm.Align := alClient;
AForm.Show;
end;
DLL部分代码
var
DLLApplication: TApplication;
DLLScreen: TScreen;
Form1: TForm1;
{$R *.res}
function CreateWindow(ParentApplication: TApplication;
ParentScreen: TScreen): TForm;
stdcall;
begin
if DLLApplication=nil then
begin
DLLApplication:=Application;
Application:=ParentApplication;
end
else
Application:=ParentApplication;
if DLLScreen=nil then
begin
DLLScreen:=Screen;
Screen:=ParentScreen;
end
else
Screen:=ParentScreen;
Form1 := TForm1.Create(nil);
Result := Form1 as TForm;
end;