For Programmers: Free Programming Magazines  


Home > Archive > Delphi > February 2005 > How do I use FormClose procedure?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How do I use FormClose procedure?
Rob Solomon

2005-02-14, 4:01 am

The following is from the mini-Delphi course at about.com. I am unable
to figure out how to use the FormClose procedure that is included. The
CloseAll menu item minimizes forms. The lesson says that the FormClose
procedure is needed to close forms but I don't know how to include this
procedure.

Any help would be appreciated.

Thanks

unit Main;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
Dialogs, Child, Menus;

type
TMainFr = class(TForm)
MainMenu1: TMainMenu;
F1: TMenuItem;
NewChild: TMenuItem;
CloseAll: TMenuItem;
Window: TMenuItem;
CascadeOption: TMenuItem;
TileOption: TMenuItem;
ArrangeAll: TMenuItem;
procedure NewChildClick(Sender: TObject);
procedure CloseAllClick(Sender: TObject);
procedure CascadeOptionClick(Sender: TObject);
procedure TileOptionClick(Sender: TObject);
procedure ArrangeAllClick(Sender: TObject);
private
{ Private declarations }
procedure CreateChildForm (const childName : string);
procedure FormClose (Sender: TObject; var Action: TCloseAction);

public
{ Public declarations }
end;

var
MainFr: TMainFr;

implementation

{$R *.dfm}
procedure TMainFr.CreateChildForm
(const childName : string);
var Child: TChildFr;
begin
Child := TChildFr.Create(Application);
Child.Caption := childName;
end;

procedure TMainFr.FormClose
(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;

procedure TMainFr.NewChildClick(Sender: TObject);
begin
CreateChildForm('Child '+IntToStr(MDIChildCount+1));
end;

procedure TMainFr.CloseAllClick(Sender: TObject);
var i: integer;
begin
for i:= 0 to MdiChildCount - 1 do MDIChildren[i].Close;
end;

procedure TMainFr.CascadeOptionClick(Sender: TObject);
begin
Cascade;
end;

procedure TMainFr.TileOptionClick(Sender: TObject);
begin
Tile;
end;

procedure TMainFr.ArrangeAllClick(Sender: TObject);
begin
ArrangeIcons;
end;

end.
Rob Kennedy

2005-02-14, 4:01 am

Rob Solomon wrote:
> The following is from the mini-Delphi course at about.com.


Answered in comp.lang.pascal.delphi.misc.

--
Rob
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com