Sign in to follow this  
coderx04

Force Change Resoultion

Recommended Posts

Quote:
void ChangeRes() { // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/devcons_7gz7.asp // #include <winuser.h> // get the current devices display settings DEVMODE lpDevMode; ZeroMemory(&lpDevMode, sizeof(DEVMODE)); lpDevMode.dmSize = sizeof(DEVMODE); lpDevMode.dmDriverExtra = 0; if (!EnumDisplaySettings(NULL/* current device */,ENUM_CURRENT_SETTINGS, &lpDevMode)) ExitProcess(1); if (lpDevMode.dmPelsWidth == 800 && lpDevMode.dmPelsHeight == 600) return; // no need to change // set settings lpDevMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY; lpDevMode.dmPelsWidth = 800; lpDevMode.dmPelsHeight = 600; lpDevMode.dmDisplayFrequency = 85; // change settings long status; do { status = ChangeDisplaySettings(&lpDevMode, CDS_FULLSCREEN /* temporary, till program exits*/); lpDevMode.dmDisplayFrequency -= 5; } while (status != DISP_CHANGE_SUCCESSFUL && lpDevMode.dmDisplayFrequency >= 60); if (status != DISP_CHANGE_SUCCESSFUL) { lpDevMode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT ; status = ChangeDisplaySettings(&lpDevMode, CDS_FULLSCREEN /* temporary, till program exits*/); if (status != DISP_CHANGE_SUCCESSFUL) ExitProcess(1); } }
I got this code from my tutor for borland C++ builder, But When I use it in Visual C++ win32 application. and use SDL library, its not working, Can you tell me whats wrong with that..? This is the error when im compiling it : c:\program files\microsoft visual studio\vc98\include\winuser.h(39) : error C2146: syntax error : missing ';' before identifier 'HDWP' c:\program files\microsoft visual studio\vc98\include\winuser.h(39) : fatal error C1004: unexpected end of file found Error executing cl.exe.

Share this post


Link to post
Share on other sites
Not sure I've ever needed to use an HDWP structure. But anyways, check where your declaring that, sounds like you need to include another header for that structure. like windows.h.

btw, when you get that working, i wouldn't hard-code the res settings in like that if i where you. it'd be much safer to enumerate what the display can do somwhere else and let the user select it.

[Edited by - JohnHurt on November 23, 2004 7:29:45 AM]

Share this post


Link to post
Share on other sites
Why not hard Code it? Is there any other way to force change the resolution when the game start.

because, I dont want to have the game be different if the use change the display settings.

And thanks, After I include windows.h before include winuser.h
It did compile, but still no different.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this