Help with OnKillFocus
-
i wrote a simple game in MFC and when someone has won or lose the game i want to kill the focus and display a messagebox saying you have won/lose... can i use OnKillFocus() to do that? i did that but it will only display the messagebox when i minimize the window or point on another window. Any suggestions or anything on what am doing wrong??? ... anyways, thank your for your help in advance....
-
OnKillFocus is a handler for WM_KILLFOCUS, which is sent to a window when it loses the focus. That's why it's called when you minimise or point to another window (as your game's window loses the focus). The change the window that has the focus, use SetFocus(). If you create a message box, that will by default obtain the focus, so your game will lose it. I don't think you need to worry about focus at all in this circumstance, you just need to:
if (game_is_won)
{
MessageBox(NULL, _T("Game over, dude!"), _T("MyGame"), MB_OK);
}------------------------ Derek Waters derek@lj-oz.com
-
i wrote a simple game in MFC and when someone has won or lose the game i want to kill the focus and display a messagebox saying you have won/lose... can i use OnKillFocus() to do that? i did that but it will only display the messagebox when i minimize the window or point on another window. Any suggestions or anything on what am doing wrong??? ... anyways, thank your for your help in advance....
OnKillFocus
is used to perform whatever action you please when the window has lost the focus. To make a window lose its focus, set it elsewehere withSetFocus
orSetForegroundWindow
. Joaquín M López Muñoz Telefónica, Investigación y Desarrollo -
i wrote a simple game in MFC and when someone has won or lose the game i want to kill the focus and display a messagebox saying you have won/lose... can i use OnKillFocus() to do that? i did that but it will only display the messagebox when i minimize the window or point on another window. Any suggestions or anything on what am doing wrong??? ... anyways, thank your for your help in advance....
OnKillFocus is a handler for WM_KILLFOCUS, which is sent to a window when it loses the focus. That's why it's called when you minimise or point to another window (as your game's window loses the focus). The change the window that has the focus, use SetFocus(). If you create a message box, that will by default obtain the focus, so your game will lose it. I don't think you need to worry about focus at all in this circumstance, you just need to:
if (game_is_won)
{
MessageBox(NULL, _T("Game over, dude!"), _T("MyGame"), MB_OK);
}------------------------ Derek Waters derek@lj-oz.com