Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: returning focus back to main form



Permlink Replies: 2 - Last Post: May 19, 2015 12:01 PM Last Post By: Boba ½° Threads: [ Previous | Next ]
Boba ½°

Posts: 73
Registered: 12/19/03
returning focus back to main form
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 19, 2015 9:28 AM
Dear all;
after I create a new window by calling CreateWindow from my
main form's constructor, the focus is shifted to that new
window - as noted by Remy Lebeau - and application's main
form is not the topmost window any more. How do I return
the focus back to where it would've ended up if no API calls
were made? TIA.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: returning focus back to main form
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 19, 2015 11:11 AM   in response to: Boba ½° in response to: Boba ½°
Boba wrote:

Dear all; after I create a new window by calling CreateWindow from my
main form's constructor, the focus is shifted to that new window - as
noted by Remy Lebeau

That depends on how you are showing the window. For instance, you could
use ShowWindow() with the SW_SHOWNOACTIVATE flag to show the window without
giving it focus.

How do I return the focus back to where it would've ended up if no API
calls were made?

Have you tried simply calling SetFocus() on the MainForm HWND? Or the MainForm's
BringToFront() method?

--
Remy Lebeau (TeamB)
Boba ½°

Posts: 73
Registered: 12/19/03
Re: returning focus back to main form
Click to report abuse...   Click to reply to this thread Reply
  Posted: May 19, 2015 12:01 PM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Thanks for the prompt reply, Remy. All of your
suggestions have been tried before my original
post went off.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02