Jump to content
  • Advertisement
Sign in to follow this  
JonW

WM_KILLFOCUS Not Getting Sent

This topic is 4879 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
Quote:
Original post by Skeleton_V@T
Quote:
Original post by Anonymous Poster
I find that WM_KILLFOCUS is only sent when an apps main window reliquenches control to one of it's (child) controls.


I'm not sure about 'only', you may try creating a plain window which alerts user when WM_KILLFOCUS is sent. Switching between windows in Windows Explorer will also generate this message.
It is weird I've never had troubles with WM_KILLFOCUS, I believe the problem arose from your window procedure (seconded ApochPiQ).

My use of the word "only" was intentional, however incorrect. It appears that when I switched to another window, one of my app's child controls had acquired focus programmatically. This explains why WM_KILLFOCUS wasn't sent.


Share this post


Link to post
Share on other sites
Advertisement
I think I figured out what's going on. When I create the window, I try to give it focus with SetForegroundWindow. According to MSDN's entry on SetForegroundWindow:

------------------------------------
"In a preemptive multitasking environment, you should generally let the user control which window is the foreground window.

Windows 98/Me: The system restricts which processes can set the foreground window.

...

With this change, an application cannot force a window to the foreground while the user is working with another window. Instead, Foreground and Background Windows will activate the window (see SetActiveWindow) and call the function to notify the user.
------------------------------------

When my window appears, my app does not usually have the focus. Though I receive WM_SETFOCUS after the call to SetForegroundWindow, I don't think I'm really getting the focus. That is why I have to click on the window before it will receive WM_KILLFOCUS.

Is my guess correct? I don't really want to hack my way out of this problem, so maybe I'll just do things differently that won't require me to get WM_KILLFOCUS.

My message handling is just done with a standard loop:

while (GetMessage)
{
Translate it
Dispatch it
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!