Jump to content
Ian Branch

Two questions if you please?

Recommended Posts

Hi Team,

Question 1.  What are the consequences/pros & cons of using MyForm.Create(nil).show; v MyForm.Create(self).show;?

 

Question 2.  I have asked this somewhere/sometime in the past but I don't recall where/when or the answer.  When I open some projects they open showing the form, others open showing the source code and yet other open not showing either.   Annoying..    Where is this information kept/save so I can set or reset it so I get them to all open the same please?  If I in fact can...

 

Regards & TIA,

Ian

Share this post


Link to post

The version without the owner leaks. 

 

Potentially there could be issues with popup parent also. Which form do you want to be the popup parent? Although I could be wrong on that one. I'm not sure that the framework looks at the component owner to determine the popup parent in auto mode. 

Edited by David Heffernan

Share this post


Link to post
7 hours ago, Ian Branch said:

When I open some projects they open showing the form, others open showing the source code and yet other open not showing either.   Annoying..    Where is this information kept/save so I can set or reset it so I get them to all open the same please?

This information is buried inside the DSK file of the project. Inspect the View<n> section for the source file in question and note the EditViewName entry. For the source view to be visible it contains the PAS file name, while for the design view it says Borland.FormDesignerView.

 

Note that the the last state is stored and overwrites your changes when the IDE options are set to store the current desktop on close.

Share this post


Link to post

David - Thank you.  I'll stick to MyForm.create(self).show I think.

 

UWE - Thank you.  I have found the Option and have set it now.

 

Regards & Tks to both.

Ian

 

Share this post


Link to post
10 hours ago, David Heffernan said:

The version without the owner leaks. 

Unless the Form has an OnClose event handler that sets the Action parameter to caFree, allowing the Form to free itself when it is closed.  This is a common idiom when using Show() instead of ShowModal().

Quote

Potentially there could be issues with popup parent also. Which form do you want to be the popup parent? Although I could be wrong on that one. I'm not sure that the framework looks at the component owner to determine the popup parent in auto mode. 

It does not look at the Owner at all. Nor could it anyway, because the Owner may not be a TWinControl at all.  Candidates for an auto-assigned PopupParent include the Application's ActiveForm, the Application's MainForm, the Screen's ActiveForm, and the Application window.

Edited by Remy Lebeau
  • Like 1

Share this post


Link to post
10 hours ago, Remy Lebeau said:

Nor could it anyway, because the Owner may not be a TWinControl at all.

Well, it easily could if it would use runtime type testing, the is operator. My framework does it this way. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×