Jump to content

  • Log In with Google      Sign In   
  • Create Account


ChangeDisplaySettingsEx() always returns DISP_CHANGE_BADPARAM


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 gretty   Members   -  Reputation: 192

Like
0Likes
Like

Posted 05 February 2013 - 09:56 PM

Hello

 

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)
 

 



Sponsor:

#2 nobodynews   Crossbones+   -  Reputation: 1761

Like
0Likes
Like

Posted 05 February 2013 - 11:38 PM

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.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS