1.メインのプロジェクト(EXE)にボタンとPanelを配置。
2.サブのプロジェクトを作成し、DBGridを配置。
※DBGridは、データを表示、編集できるようにしておく。
3.メインのフォームのボタンを押すと
PanelにDLLをドッキングさせる。
この場合、ドッキングされた状態でDBGridの表示は出来るが、
編集が出来ない。
また、Gridをクリックすると「親ウィンドウを持っていません」の
エラーが出る。
フローティングでフォームを表示すると問題ない。
ドッキングした状態で編集することは出来ないのでしょうか?
EXE側:
type
TFMain00 = class(TForm)
Panel1: TPanel;
DockPanel: TPanel;
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private 宣言 }
public
{ Public 宣言 }
end;
var
FMain00: TFMain00;
Sub01: TForm;
function Sub01_CreateDLLForm(hOwner: HWND): TForm; external 'Sub01.dll';
procedure Sub01_FreeDLLForm; external 'Sub01.dll';
implementation
{$R *.dfm}
procedure TFMain00.Button1Click(Sender: TObject);
begin
DockPanel.Visible := False;
DockPanel.Align := alClient;
Sub01.ManualDock(DockPanel);
Sub01.Show;
DockPanel.Visible := True;
end;
procedure TFMain00.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Sub01_FreeDLLForm;
end;
procedure TFMain00.FormCreate(Sender: TObject);
begin
Sub01 := Sub01_CreateDLLForm(Application.Handle);
end;
procedure TFMain00.Button2Click(Sender: TObject);
begin
Sub01.Close;
end;
procedure TFMain00.Button3Click(Sender: TObject);
begin
Sub01.Show;
end;
DLL側(プロジェクトのソース):
※DBGridにデータを表示させるのは、プロパティで直接設定。
library Sub01;
uses
Forms,
Windows,
Sub01p in 'Sub01p.pas' {FSub01};
{$R *.res}
//=============================================================================
// DLLフォームを作成する
//=============================================================================
function Sub01_CreateDLLForm(hOwner: HWND): TFSub01;
begin
//Application.Initialize;
// DLLフォームの親アプリケーションを特定。
Application.Handle := hOwner;
// DLLフォームを作成。
FSub01 := TFSub01.Create(Application);
Result := FSub01;
end;
//=============================================================================
// DLLフォームを破棄する。
//=============================================================================
procedure Sub01_FreeDLLForm;
begin
// DLLフォームを破棄。
FSub01.Free;
// DLLフォームの親アプリケーションを解放。
Application.Handle := 0;
end;
exports
Sub01_CreateDLLForm,
Sub01_FreeDLLForm;
end.
実行時パッケージを使用すると
なぜかうまくいきました。
ツイート | ![]() |