Re: How to get a reference to main form in a Windows Form 2.0 Application?
- From: Jon Shemitz <jon@xxxxxxxxxxxxxxxxx>
- Date: Fri, 25 Aug 2006 13:15:12 -0700
jldearmas@xxxxxxxxx wrote:
How to get a reference to main form in a Windows Form 2.0 Application?
I'm making a a library and I need a reference to the main form of the
application that is using that library.
I just spent a few minutes trying to answer this - and it may not be
possible.
* The Application class has nothing like a MainForm property.
* The Application.Run(Form) method doesn't log its parameter anywhere
public; it adds an event handler to the MainForm's Closed event.
There's no way (that I know of) to examine a form's Closed event
handlers to see which has a handler in the Application class; you can
only treat the event as a delegate within the Form class itself.
* The Application.OpenForms collection seems to be in form creation
order. In most cases, the first form will be the main form - but you
can't count on this. If the Main() procedure creates (and shows) a
form before calling Application.Run, the main form will not be first
in the OpenForms collection.
--
..NET 2.0 for Delphi Programmers www.midnightbeach.com/.net
Delphi skills make .NET easy to learn In print, in stores.
.
- Follow-Ups:
- References:
- Prev by Date: Re: Adding scheduling to an application
- Next by Date: Re: ToString - meaningful Vs. Useless
- Previous by thread: Re: How to get a reference to main form in a Windows Form 2.0 Application?
- Next by thread: Re: How to get a reference to main form in a Windows Form 2.0 Application?
- Index(es):