 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Robert Solomon Guest
|
Posted: Sun Feb 13, 2005 10:56 pm Post subject: How do I use FormClose |
|
|
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.
|
|
| Back to top |
|
 |
Rob Kennedy Guest
|
Posted: Mon Feb 14, 2005 5:59 am Post subject: Re: How do I use FormClose |
|
|
Robert Solomon wrote:
| Quote: | procedure TMainFr.CreateChildForm
(const childName : string);
var Child: TChildFr;
begin
Child := TChildFr.Create(Application);
Child.Caption := childName;
end;
|
Assign the child's OnClose event handler so it refers to your FormClose
procedure. That way, when you try to close the form, it will free itself
instead of just minimizing.
--
Rob
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|