1

I'm trying to change resolution of my display using win32 call ChangeDisplaySettings with the following way:

DEVMODE devmode; devmode.dmPelsWidth = 1024; devmode.dmPelsHeight = 768; long result = ChangeDisplaySettings(&devmode, DM_PELSWIDTH || DM_PELSHEIGHT); qDebug() << "RESULT OF CHANGE DISPLAY :"<< result; 

Always I get the same result value, -2, that indicates "display mode stored in the Registry". The source of this info is the following:

http://www.codeproject.com/Articles/36664/Changing-Display-Settings-Programmatically

The issue here is that my resolution DOES NOT CHANGE never. Any idea why I cannot do that?

1 Answer 1

1

Always consult with MSDN when using Window API.

This should work:

DEVMODE devmode; devmode.dmPelsWidth = 1024; devmode.dmPelsHeight = 768; devmode.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT; devmode.dmSize = sizeof(DEVMODE); long result = ChangeDisplaySettings(&devmode, 0); 
Sign up to request clarification or add additional context in comments.

2 Comments

Like a charm! Thanks @Stas This solution store the resolution in registry right? If I want to restore a previous resolution, how I need to proceed?
The solution of the above comment is ChangeDisplaySettings ( NULL, 0 );

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.