🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Window focus

Started by
1 comment, last by ursus 17 years, 10 months ago
Hello all, I would really, really, really appreciate an example/article/tutorial or any help on how to handle Window (created basing on NeHe template) alt-tabbing. I’ve been trying to find something and work it out myself for around a week now but I failed miserably. I understand this should fit into this sort of scheme: Window looses its focus: 1 Window is killed 2 fullscreen flag set to FALSE 3 new window (minimized) created Window regains its focus: 1 Window is killed 2 fullscreen flag set to TRUE 3 new window (maximized) created Thank you very much in advance.
Advertisement
What happens when you try to alt-tab your app? Knowing the symptoms will help us resolve your problem.
Right, perhaps I wasn’t very descriptive, sorry for that.

Basing on NeHe skeleton code I use: CreateGLWindow() and KillGLWindow() functions that should nicely create the window and close it cleanly checking for errors on the way.

In order to check if the window has lost/regained its focus, following WM messages can be used: WM_SETFOCUS, WM_KILLFOCUS or WM_ACTIVATEAPP they are very similar (the way I understand it from the MSDN documentation).

I think, this sort of code should do the trick:

case WM_ACTIVATEAPP:{  if ((BOOL)wParam==TRUE)	{		// window was activated		active=TRUE;		KillGLWindow();		// close window		fullscreen=TRUE;	  // full screen flag set to true		window_created=FALSE; 	// recereate it at the next loop	}	else	{		// window lost its focus		active=FALSE;		KillGLWindow();		// close window		fullscreen=FALSE; 	// full screen flag set to false		window_created=FALSE; 	// recereate it at the next loop	}}break;


In CreateGLWindow() fullscreen flag is checked and if false ShowWindow(hWnd,SW_MINIMIZE)

Things seem to be going well when the window looses its focus but when trying to go back to it I get ‘Could Not Unregister Class’ error message from KillGLWindow().

It looks to me like the KillGLWindow() is sent more than once but I am not sure.

If all above doesn’t make much sense I can post the whole code (simplified as much as possible of course).

Thank you

This topic is closed to new replies.

Advertisement