Jump to content
  • Advertisement
Sign in to follow this  

ChangeDisplaySettingsEx() always returns DISP_CHANGE_BADPARAM

This topic is 2109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I am attempting to set the Display Mode of my Monitor using WinAPI C++ functions.

My Problem: Calling ChangeDisplaySettingsEx() always returns DISP_CHANGE_BADPARAM. What am I doing wrong?

I think it may be my devMode.dmDriverExtra value thats causing the error. I've read MSDN and the explaination of devMode.dmDriverExtra is confusing. What is it and how do I find out the Monitors' dmDriverExtra?

Whats causing my code below to always return `DISP_CHANGE_BADPARAM`?

DEVMODE devMode;
    POINTL p                = {0,0};
    _tcscpy(devMode.dmDeviceName, _T("\\Device\\00000072")); 
    devMode.dmSpecVersion    = DM_SPECVERSION;
    devMode.dmDriverVersion = 1;  // How do I determine the driver version?
    devMode.dmSize            = sizeof(DEVMODE);
    devMode.dmDriverExtra   = 0x5c0000; //
    devMode.dmFields        = DM_POSITION;
    devMode.dmPosition        = p;

    LONG res = ChangeDisplaySettingsEx(_T("\\Device\\00000072"), &devMode, mainHwnd, CDS_UPDATEREGISTRY | CDS_NORESET, NULL);
    _tprintf(_T("%s: %d\n\n\n"), _T("\\Device\\00000072"), res);
    // The above printf always prints out "\Device\00000072: -5" (DISP_CHANGE_BADPARAM=-5)


Share this post

Link to post
Share on other sites
For ChangeDisplaySettingsEx MSDN says: To ensure that the DEVMODE structure passed to ChangeDisplaySettingsEx is valid and contains only values supported by the display driver, use the DEVMODE returned by the EnumDisplaySettings function. I'd suggest following the MSDN instructions for EnumDisplaySettings (or EnumDisplaySettingsEx). Note: this in turn might lead to using EnumDisplayDevices if you expect there to be multiple monitors. I also looked for some examples of using these functions. The best one I could find is here: http://www.news2news.com/vfp/?example=374&ver=vcpp It's about 10 years old and written for the console so you'll need to adapt it to your own needs, but it wasn't that hard to understand.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!