Advertisement

How do i make my window ALT+TAB safe?

Started by March 19, 2003 03:31 PM
2 comments, last by Guzba 21 years, 8 months ago
heres the createWindow function incase you need to see something:
  
bool createWindow(void)
{
	WNDCLASS Wnd;

	hInstance			= GetModuleHandle(NULL);
	Wnd.style			= CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
	Wnd.lpfnWndProc		= (WNDPROC) WndProc;
	Wnd.cbClsExtra		= 0;
	Wnd.cbWndExtra		= 0;
	Wnd.hInstance		= hInstance;
	Wnd.hIcon			= LoadIcon(NULL, IDI_WINLOGO);
	Wnd.hCursor			= LoadCursor(NULL, IDC_ARROW);
	Wnd.hbrBackground	= NULL;
	Wnd.lpszMenuName	= NULL;
	Wnd.lpszClassName	= "Space";

	if(!RegisterClass(&Wnd))
	{
		return false;
	}

	DWORD dwExStyle;	
		  dwExStyle = WS_EX_APPWINDOW;

	ShowCursor(FALSE);

	if(!(hWnd = CreateWindowEx(dwExStyle,
							   "Space",
							   "Space Quest",
							   WS_CLIPSIBLINGS |
							   WS_CLIPCHILDREN |
							   WS_POPUPWINDOW,
							   0, 0,
							   800, 
							   600,
							   NULL,
							   NULL,
							   hInstance,
							   NULL)))
	{
		killWindow();
		return false;
	}

	DEVMODE screenSettings;
	EnumDisplaySettings(NULL, 0, &screenSettings);
	screenSettings.dmPelsWidth  = 800;
	screenSettings.dmPelsHeight = 600;
	screenSettings.dmBitsPerPel = 16;
	screenSettings.dmFields		= DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;

	if(ChangeDisplaySettings(&screenSettings, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
	{
		return false;
	}

	int pixelFormat;

	static PIXELFORMATDESCRIPTOR pfd =	{ sizeof(PIXELFORMATDESCRIPTOR),	
										  1,	
										  PFD_DRAW_TO_WINDOW |
										  PFD_SUPPORT_OPENGL |
										  PFD_DOUBLEBUFFER,
										  PFD_TYPE_RGBA,	
										  16,
										  0, 0, 0, 0, 0, 0,
										  0,	
										  0,	
										  0,	
										  0, 0, 0, 0,
										  16,
										  0,	
										  0,	
										  PFD_MAIN_PLANE,
										  0,	
										  0, 0, 0
	};

	if (!(hDC = GetDC(hWnd)))
	{
		killWindow();
		return false;
	}

	if (!(pixelFormat = ChoosePixelFormat(hDC, &pfd)))
	{
		killWindow();
		return false;
	}

	if(!SetPixelFormat(hDC, pixelFormat, &pfd))
	{
		killWindow();
		return false;
	}

	if (!(hRC = wglCreateContext(hDC)))
	{
		killWindow();
		return false;
	}

	if(!wglMakeCurrent(hDC, hRC))
	{
		killWindow();
		return false;
	}

	ShowWindow(hWnd, SW_SHOW);
	SetForegroundWindow(hWnd);
	SetFocus(hWnd);

	if (!initGL())
	{
		killWindow();
		return false;
	}

	return true;
}
  
It always goes to full screen and i felt its important to allow them to unfullsize it for something without exiting
"I never finish what i sta.."Computer:ATI Radeon 9700 PROP4 2.66 GHz512 RDRAM
go to http://nehe.gamedev.net/ then go to lessons 1-5 and check out setting up an OpenGL window under windows, this will tell you how to switch between fulscreen and windowed mode, you can also try www.gametutorials.com they have alot of good stuff. I would tell you how to do it but then youd miss out on learning it for yourself. Also both the window making programs from nehe and gametutorials work to alt tab out of and back into.
"I don''t care what you think unless it is about me"
Advertisement
I made my basecode off of NeHe's, and it has the same problem as his, i run the window i make in 800x600 and my screen runs at 1024x768 and when i alt tab it shrinks it (and also i always want it in full screen, tahts why i took the option out

[edited by - Guzba on March 19, 2003 5:13:07 PM]
"I never finish what i sta.."Computer:ATI Radeon 9700 PROP4 2.66 GHz512 RDRAM
In a full screen application, you need to pause your game and information. Then when yoru window regains control, you need to re initialize everything lost then continue with the game.


<=- Talon -=>
HOMEPAGE in Development
Personal Quote: Age should only reflect the concept of TIME, not on our personality and actions. How did we ever manage to loose our childishness to the concept of age?
<=- Talon -=>

This topic is closed to new replies.

Advertisement