Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

System.Windows.Forms.Form.ActiveForm always null

786 views
Skip to first unread message

steenbt

unread,
Mar 1, 2005, 4:55:06 PM3/1/05
to
I just finished an application, with a standard Form. Though the form is
Active (the property is true) the static System.Windows.Forms.Form.ActiveForm
is null all the time.
I tried to call Activate and Focus but the state for ActiveForm does not
change.

I need to know what the ActiveForm is because I need to disable some
keyboard activities depending on what form is displayed. I mostly am
intereseted in the Modal state.

Any idea why ActiveForm would always be NULL?

Thierry

Aaron Fischer

unread,
Mar 1, 2005, 9:55:03 PM3/1/05
to
if you are interested in the modal stat how do you launch your other forms?
form.show() or form.showdialog()?

steenbt

unread,
Mar 2, 2005, 8:27:03 AM3/2/05
to

I'm mostly interested to know if a MessageBox is currently displayed.

Ed

unread,
Mar 31, 2007, 1:42:00 PM3/31/07
to
I am having this issue always no matter the project using Visual Studio 2005 and c#, System.Windows.Forms.Form.ActiveForm is ALWAYS null, on all forms in all applications...any ideas? Nothing fancy...even happens from a new project with 2 forms in it..no cross threading, nothing fancy at all.

From http://www.developmentnow.com/g/29_2005_3_0_0_158032/System-Windows-Forms-Form-ActiveForm-always-null.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Ed

unread,
Mar 31, 2007, 2:08:39 PM3/31/07
to
Ok, so i figured out it is only in Debug mode when i set a breakpoint, i'm guessing the visual studio environment is considered part of the application so when focus goes back to visual studio to interpret values, it is considered losing activation on the test applications form...not sure how i'm going to test this code but i'll manage

From http://www.developmentnow.com/groups/viewthread.aspx?newsgroupid=29&threadid=158032

Julian

unread,
Jul 22, 2009, 9:27:29 PM7/22/09
to
A quick solution for this problem is to create a static delegate method on your main form.
Have that method invoke other delegate methods.

sample:
public delegate void Invoker( Delegate function , object[] args );

in main form

public static Invoker MethodInvoker;

private void MethodInvokerHandle( Delegate function , object[] args )
{
this.BeginInvoke ( function , args );
}

From http://www.developmentnow.com/groups/viewthread.aspx?newsgroupid=29&threadid=158032

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com/g/

0 new messages