superboy
asked on
How to close all?
how do i close all my child MDI forms in
the master MDI Form?
How do i make the child MDI Forms change/minised into icons?
the master MDI Form?
How do i make the child MDI Forms change/minised into icons?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What full code?
From Delphi Help file:
property MDIChildCount: Integer;
Run-time and read-only. The value of the MDIChildCount property is the number of child windows open in an MDI application.
-------------------------- ---------- ----
property MDIChildren[I: Integer]: TForm;
Run-time and read-only. The MDIChildren property array provides access to a child window or form in an MDI application through an index value, I. The value of I is determined by the order in which the window was created. For example, the first MDI child window has an I value of 0.
-------------------------- ---------- ----
property ActiveMDIChild: TForm;
Run-time and read only. The value of the ActiveMDIChild property is the form that currently has focus in an MDI application. This only applies if the form is of type fsMDIForm.
From Delphi Help file:
property MDIChildCount: Integer;
Run-time and read-only. The value of the MDIChildCount property is the number of child windows open in an MDI application.
--------------------------
property MDIChildren[I: Integer]: TForm;
Run-time and read-only. The MDIChildren property array provides access to a child window or form in an MDI application through an index value, I. The value of I is determined by the order in which the window was created. For example, the first MDI child window has an I value of 0.
--------------------------
property ActiveMDIChild: TForm;
Run-time and read only. The value of the ActiveMDIChild property is the form that currently has focus in an MDI application. This only applies if the form is of type fsMDIForm.
ASKER
must i declare the variables MDIChildCount, MDIChildren
and so on?
and so on?
No, It is already declared as a property. Delphi "knows" how many
childs are opened, and how to access them.
childs are opened, and how to access them.
ASKER
if i minismised the forms into icons..
will delphi assigned some default icons to the forms
and can i do a arrangeicons after that?
will delphi assigned some default icons to the forms
and can i do a arrangeicons after that?
Yes.
ASKER
how do i add a message dialog when closing each MDI Child form?
like to confirm whether the user want to close../or he want to save what he has done in the MDI child form?
is there a way to check if something is written in the MDI child form when i has a memo in the child form...?
like to confirm whether the user want to close../or he want to save what he has done in the MDI child form?
is there a way to check if something is written in the MDI child form when i has a memo in the child form...?
ASKER
hey ronit, i try your method
To Close:
begin
with Form1 do
while MDIChildCount>0 do
MDIChildren[0].Release;
end;
and it crash my application...
the minimise code u wrote, i try it and it is actually for the
close all function...what abt minimised to icons?
To Close:
begin
with Form1 do
while MDIChildCount>0 do
MDIChildren[0].Release;
end;
and it crash my application...
the minimise code u wrote, i try it and it is actually for the
close all function...what abt minimised to icons?
I am checking...
Sorry my mistake. If you use Delphi 3, write the following code:
To Minimize:
procedure TMainForm.Button1Click(Sen der: TObject);
var I: byte;
begin
LockWindowUpdate(Handle);
if MDIChildCount>0 then
for I := MDIChildCount-1 downto 0 do
MDIChildren[I].WindowState :=wsMinimi zed;
LockWindowUpdate(0);
end;
To close:
procedure TMainForm.Button1Click(Sen der: TObject);
var I: byte;
begin
LockWindowUpdate(Handle);
if MDIChildCount>0 then
for I := MDIChildCount-1 downto 0 do
MDIChildren[I].Close;
LockWindowUpdate(0);
end;
and on the OnClose event of the child form write:
Action:=cafree;
To Minimize:
procedure TMainForm.Button1Click(Sen
var I: byte;
begin
LockWindowUpdate(Handle);
if MDIChildCount>0 then
for I := MDIChildCount-1 downto 0 do
MDIChildren[I].WindowState
LockWindowUpdate(0);
end;
To close:
procedure TMainForm.Button1Click(Sen
var I: byte;
begin
LockWindowUpdate(Handle);
if MDIChildCount>0 then
for I := MDIChildCount-1 downto 0 do
MDIChildren[I].Close;
LockWindowUpdate(0);
end;
and on the OnClose event of the child form write:
Action:=cafree;
ASKER
LockWindowUpdate(Handle);
what does this do?
what does this do?
ASKER
how do i restore all the MDI child windows to their previous
windowstate ? i want to do something like tile..but it does not work..
windowstate ? i want to do something like tile..but it does not work..
you can use the Cascade, Tile and ArrangeIcons methods of the MDI parent for that.
LockWindowUpdate(handle) freezes the screen until you call LockWindowUpdate(0). This, in order to increase performance.
ASKER
LockWindowUpdate(handle) does this make any app hang?
No, It's just preventing from screen to be refreshed while something is being processed.
ASKER
what is the MDIChildCount and MDIChildren?