OK, I've got the code in the child form. Seems to be fine.
But I must still be missing something. I commented out the global variable from the library unit and put it in the var of the main form. then i moved it to the procedure (derived from embedform procedure i found in the forum) for opening the child form.
procedure TFormMain.MenuItemStatesClick(Sender: TObject);
var
FormInPanel : TForm;
Ctrl : tControl;
begin
FormInPanel := TForm(TFormStates.NewInstance);
FormInPanel.Create(Panel1);
while FormInPanel.ControlCount > 0 do begin
Ctrl:=FormInPanel.Controls[0];
Ctrl.Parent:=Panel1;
end;
// OpenFormInPanel;
FormInPanel.OnCloseHandler := @ChildIsDestroyedNotifier;
end;
When i compile the program i get:
unitmain.pas(108,15) Error: identifier idents no member "OnCloseHandler"
The main form is mostly an empty shell for the child forms.
uses
Windows, Classes, SysUtils, FileUtil, LResources, Forms, Controls,
Graphics, Dialogs, StdCtrls, Menus, ExtCtrls, UnitVendor2,
UnitLibrary, UnitStates;
type
{ TFormMain }
TFormMain = class(TForm)
Label1: TLabel;
MainMenu1: TMainMenu;
MenuHelp: TMenuItem;
MenuItemStates: TMenuItem;
MenuItemVendors: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
MenuItemExit: TMenuItem;
MenuItemAbout: TMenuItem;
MenuFile: TMenuItem;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure MenuItemStatesClick(Sender: TObject);
procedure MenuItemVendorsClick(Sender: TObject);
procedure MenuItemAboutClick(Sender: TObject);
procedure MenuItemExitClick(Sender: TObject);
procedure ChildIsDestroyedNotifier;
private
// procedure OpenFormInPanel;
public
end;
var
FormMain: TFormMain;
// FormInPanel : TForm;
I appreciate your help