jl*******@yahoo .com 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.Ope nForms 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.