Skip to main content
gamedev.net
🔒 Locked

fullscreen

Started by mike74 Sep 17, 2005 at 12:17 AM 2 replies 1k views
Original Post
mike74
mike74
I'm creating a fullscreen game, and I go into fullscreen mode like so: ChangeDisplaySettings(&dmScreenSettings, CDS_FULLSCREEN); I noticed that when my program exits, Windows seems to automatically go back into the original mode. So, I guess I don't need to worry about that. However, when someone Alt-tabs away from my game, it doesn't change back to the original mode. Anyone know how to make it do so? mike http://www.coolgroups.com/
Mike C.http://www.coolgroups.com/zoomer/http://www.coolgroups.com/ez/
Drew_Benton
Drew_Benton
Well doing a little research and application of code, here's what I've been able to come up with.

First, you will need to register the Alt+Tab hotkey so you can detect in in the message loop. You only need to do this once.

RegisterHotKey( hWnd, 0, MOD_ALT, VK_TAB );

Second, you will need to add in the detection code to your WindowProc function.

case WM_HOTKEY:	if( lParam == MAKELONG( MOD_ALT, VK_TAB ) )	{	}break;


Now the rest is up to you. Right now, the code that you put into that if statement will be called when the user presses Alt+Tab. ideally, you would want to probabally pause your game, and reset the display to that of the desktop mode. Then when you get another message to your program, WM_ACTIVATE in particular, then you can check to see if the game was 'paused'. If it was, you resume the game and are back in fullscreen mode. Good luck!

References:
Lock Windows Desktop
WM_HOTKEY
RegisterHotKey
timw
timw
I think windows sends a WM_ACTIVATE message in this case.


[edit]
also I forgot to mention, anytime alt is pressed while pressing a key windows sends a WM_SYSCOMMAND message and when you get that message, simply check the key you want by using the getkeystate macro, for instance this checks to see if alt + enter has been pressed, a common way to alternate b/w windowed and fullscreen mode.

case WM_SYSCOMMAND:
if(GetKeyState(VK_RETURN)&0x8000) {
ScreenDesc.bFullscreen = !ScreenDesc.bFullscreen;
changeDisplay(&ScreenDesc, hwnd);
}
else
return DefWindowProc(hwnd, msgID, wParam, lParam);
break;

however for alt tab you should use the above method since it takes care of more things that you probably havnen't thought of.

Tim

[Edited by - timw on September 17, 2005 2:11:04 AM]
mike74
mike74
Here's what I settled upon:

case WM_ACTIVATE:if (LOWORD(wParam)==WA_INACTIVE) ChangeDisplaySettings(NULL,0);                            else fullscreen();break; 


It seems to work.

mike
http://www.coolgroups.com/
Mike C.http://www.coolgroups.com/zoomer/http://www.coolgroups.com/ez/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.