I'm trying to call a ChildForm from a main form to a DLL.
When I take out cxDBTreeList, I get an error when creating it...
If I delete the cxDBTreeList again, it works without any errors.
It seems that the Result is null in the TcxEditDBRegisteredRepositoryItems.GetItemByDataBinding event.
With an empty cxDBTreeList, the Result seems to be null in the TcxScrollBarPainter.GetMinThumbnailSize event.
@DLLForm
library Project1;
uses
System.SysUtils,
System.Classes,
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
function CreateDLLForm(App: TApplication): TForm;
begin
Application := App;
Form1 := TForm1.Create(Application.MainForm);
Result := Form1;
end;
exports
CreateDLLForm;
unit Unit1;
...
type
TForm1 = class(TForm)
cxDBTreeList1: TcxDBTreeList;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
end.
@MainForm
unit Unit1;
...
var
Form1: TForm1;
DLLHandle: THandle;
DLLForm : TForm;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
type
TDLLProc = function(App: TApplication): TForm;
var
AProcedure : TDLLProc;
MessageStr : String;
begin
DLLHandle := LoadLibrary(PChar( 'Project1.dll' ));
if (DLLHandle > 32) then
begin
@AProcedure := GetProcAddress( DLLHandle, PChar( 'CreateDLLForm' ) );
if (@AProcedure <> nil ) then
begin
DLLForm := AProcedure(Application);
with DLLForm do
begin
Width := 500;
Height := 500;
end;
Application.ProcessMessages;
end
else
begin
MessageStr := 'Not find dll file1';
ShowMessage( MessageStr );
end;
end
else
begin
MessageStr := 'Not find dll file2';
ShowMessage( MessageStr );
end;
end;