Alt tab with fullscreen fix

This issue was covered in another post…but it was vague with details…so here you go. some psuedo code. Let me know if ya find something I missed.

//I started with the NEHEGL stuff tutorial "setting up an opengl window"
//
//http://nehe.gamedev.net/lesson.asp?index=01
//
//but it doesn't handle alt-tabbing proper so I ammended the WndProc(). the new stuff looks like this

bool configFS = true;   //do we want the app to be configured as fullscreen? YES!

LRESULT CALLBACK WndProc(	HWND	hWnd,			// Handle For This Window
				UINT	uMsg,			// Message For This Window
				WPARAM	wParam,			// Additional Message Information
				LPARAM	lParam)			// Additional Message Information
{
	switch (uMsg)						// Check For Windows Messages
	{
		case WM_ACTIVATEAPP:				//This handles alt tab issues--change to desktop size and minimize
		{
			if (!wParam){
				if (active){
					ShowWindow(hWnd,SW_SHOWMINNOACTIVE);
					active=FALSE;						// Program Is No Longer Active
					ChangeDisplaySettings(NULL,0);
				}
			}else{
				if (!active){
					KillGLWindow();						// Kill Our Current Window
					if (configFS){
						if (!CreateGLWindow("fulscreen (r) 640 480 16 - 2D Font",640,480,16,configFS)){
							return 0;						// Quit If Window Was Not Created
						}
					}else{
						if (!CreateGLWindow("windowed (r) 640 480 16 - 2D Font",640,480,16,configFS)){
							return 0;						// Quit If Window Was Not Created
						}
					}
					ShowWindow(hWnd,SW_SHOW);
					active=TRUE;						// Program Is Active
				}
			}
			return 0;								// Return To The Message Loop
		}
} 

cheers

I ran into issues, introduced when I replaced the case WM_ACTIVATE with case WM_ACTIVEAPP. But by having both cases alt-tabbing seems fine…however devstudio does get pushed to monitor 2 on my 2 monitor setup, when I alt-tab to it with the Opengl application running in the background…Essentially I am recommending leaving the WM_ACTIVATE case intact as listed in the NeheGL Sample code, and placing WM_ACTIVATEAPP after it…what follows is the WM_ACTIVATE code which should get put back in, and precedes the WM_ACTIVATEAPP.

Any one got any ideas on why alt-tab pushes dev studio to monitor 2?

 	
	case WM_ACTIVATE:							// Watch For Window Activate Message
		{
			if (!HIWORD(wParam))					// Check Minimization State
			{
				active=TRUE;						// Program Is Active
			}
			else
			{
				active=FALSE;						// Program Is No Longer Active
			}

			return 0;								// Return To The Message Loop
		} 

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.