Dear List :)

Do you know the WindowMenu property of a (parent) form?
It links to a menu that lists all current MDI children of an application.

I want to list all existing children also in other place. More exactly I 
want to create an interface similar with Macromedia Dreamweaver or 
Delphi 7, where each MDI child has its own tab from where it can be 
quickly accessed.

I started the work from TForm.Notification but something went wrong. The 
idea was to create a new tab in a TPageControl every time a TForm was 
created at runtime.
Somebody came with idea of adding a routine in each MDI form (in Create 
and Destroy) that will create and delete its corresponding tab, but I 
don't like the idea because I have many different forms derived from 
TFrom in my application and I have to modify them all.




The code that I tried is:

VAR  
    Initializing: Boolean= True;
    FormID: Integer= 0;

procedure TfrmMain.Button1Click(Sender: TObject);
VAR F: TForm;
begin
 F:= TForm.Create(Self);
 F.Caption:= 'xx';
 F.Name:= 'Form'+ i2s(FormID);
 F.Tag:= FormID;  
 F.FormStyle:= fsMDIChild;
 F.Show;
 F.BringToFront;
end;


procedure TfrmMain.FormCreate(Sender: TObject);
begin
   Initializing:= FALSE;
end;


procedure TfrmMain.Notification(AComponent: TComponent; Operation: 
TOperation);
VAR btn: TButton;
begin
 inherited;
 if NOT Initializing
 AND (Operation= opInsert)
 AND (AComponent is TForm)
 then
  begin
   inc(FormID);
     
   btn:= TButton.Create(Self);
   btn.Parent:= Self;
   btn.Visible:= TRUE;
   btn.BringToFront;
   btn.Top := 1;
   btn.Caption:=  (AComponent as TForm).Caption;    <--- AV here
   btn.Tag:= FormID;
   AComponent.Tag:= FormID;
  end;

if  (Operation= opRemove) then RemoveAsocButton;
end;


The code creates a Tform MDI child when you push the button.
At this moment the Notification is aware that a new component is ready 
to be created. Here I want to create the list of existing MDI children - 
the above code tries to create a button for each of these MDI children. 
However it fails when at this line (AComponent as TForm).Caption.  The 
AComponent seems to be un-initialized.

Delphi's documentation doesn't tell you big deal about Notification so I 
kinda got stuck.

_______________________________________________
Delphi mailing list -> Delphi@elists.org
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi

Reply via email to