![]() |
|
#1
|
|||
|
|||
|
Other forms that i show/hide from my main one id like to create and destroy instead so they aren't always loaded unless i really need to.
how would i go about doing this? |
|
#2
|
|||
|
|||
|
read this:
[link]http://delphi.about.com/od/beginners/l/aa070203a.htm[/link] simon |
|
#3
|
|||
|
|||
|
ummm ok i hope i understood it in someway is this ok to use?
When i want to show the form. Code:
Procedure TFrmMain.MMWSSecurityClick(Sender: TObject);
Var
Form: TFrmSecurity;
Begin
Form := TFrmSecurity.Create(Self);
MMWSSecurity.Enabled := False;
Form.Show;
End;
Code:
Procedure TFrmSecurity.BtnCloseClick(Sender: TObject);
Begin
FrmMain.MMWSSecurity.Enabled := True;
Self.Release;
End;
|
|
#4
|
|||
|
|||
|
hmm do you have to invent your own code ?
I see you want to have modeless forms so just follow the example. Create the form using Show (as you did) and close it using the OnCloseForm event and instead of calling release do a close - I dont know if your method is wrong but if it is possible - follow the correct example.regard simon |
|
#5
|
|||
|
|||
|
An efficient way to manage forms in an application is to create an instance of the form when needed, show it as a modal form using ShowModal(), and Release it when through with it. The steps are as follows:
1) Apart from your main form, do not autocreate any form unless your program logic absolutely requires it. 2) Using your own example, I would do this: Code:
Procedure TFrmMain.MMWSSecurityClick(Sender: TObject); var
Form: TFrmSecurity;
begin
Form := TFrmSecurity.Create(Self);
// You can set any properties of Form here, e.g.
// Form.Caption:='Security settings';
if (Form.ShowModal()=mrOk) // Show form until done
begin
// Possibly save values that are set in Form.
end
Form.Release(); // Destroy and free memory
end
Port Harcourt, Nigeria |
|
#6
|
|||
|
|||
|
Simor so you think i should call Form.Close for the button to close the form and just use what was suggested in that article for the OnClose event of the form?
|
|
#7
|
|||
|
|||
|
In the article for closing the form with a button it just releases it like i said so what's the point in an OnClose event?
|
|
#8
|
|||
|
|||
|
It seems your way is working, and maybe it's the same thing -
since "self" is the frmsecurity, and you also release it so whats the point in doing close and puting that code in onclose ? maybe there is no point ? -sorry simon |
|
#9
|
|||
|
|||
|
Kool less work for me lol.
Well i don't see much difference in usage of ram between it being opened or closed most likely because it's not all that big yet but it will be thnx for the help. |
![]() |
| Thread Tools | |
| Display Modes | |
|
|