Show() a form without giving it focus

  • Thread starter Thread starter jake
  • Start date Start date
J

jake

How can I Show() a form without letting it get focus?
As in:

(this code will run in a separate thread)

myFrom frm = new myForm();
frm.Show();

Focus should remain in whatever application currently has focus on the
desktop.

Regards,
jake
 
How can I Show() a form without letting it get focus?
As in:

(this code will run in a separate thread)

myFrom frm = new myForm();
frm.Show();

Focus should remain in whatever application currently has focus on the
desktop.

Regards,
jake

I have not ever needed to do this nor have I tried it, but it seems
that a:

this.Select();

after the frm.Show() should do the trick.
 
I have not ever needed to do this nor have I tried it, but it seems
that a:

this.Select();

after the frm.Show() should do the trick.

I just tried your suggestion with both Select() overloads and all
possible combinations of the second overload parameters to no avail.
I thought this would surely do the trick.

At any rate, I found an alternative using GetForgroundWindow() and
SetForgroundWindow() and it works.

Actually the Select() suggestion gave me the idea to find a way to
move the focus around; that is how I found this solution.

Thank you very much Joe.
Regards,
jake
 
myFrom frm = new myForm();
frm.Show();

Focus should remain in whatever application currently has focus on the
desktop.

this might solve your problem:

myFrom frm = new myForm();
frm.WindowState = FormWindowState.Minimized;
frm.Show();
 
this might solve your problem:

myFrom frm = new myForm();
frm.WindowState = FormWindowState.Minimized;
frm.Show();


Family Tree Mike,
Right on the money!


Ben and Julia,
The problem in my scenario is that I need to "popup" the window, as
Mike put it, and not take away the focus from whichever application
that has the focus at the time; it may not be my application.
GetForegroundWindow() and SetForegroundWindow() in user32.dll did the
trick.

Thanks to all.
Regards,
jake
 
Back
Top