Show() a form without giving it focus

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
 
J

Joe Cool

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.
 
C

con-man-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 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
 
J

Julia M

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();
 
C

con-man-jake

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top