Please help with ChangeDisplaySettings
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 3 of 3

Thread: Please help with ChangeDisplaySettings

  1. #1
    Join Date
    Jan 2002

    Please help with ChangeDisplaySettings

    I want to do simple thing - change refresh rate.
    I wrote simple code:

    LPDEVMODE newres;

    BUT it does'nt work.
    I know exactly, that this frequency is supported at this resolution, 'case I can setup it manually in properties dialog. But this code does't work. Why?

  2. #2
    Join Date
    Sep 2001
    Bristol, England

    Re: Please help with ChangeDisplaySettings

    Firstly, you're not allocating any memory for your DEVMODE pointer, and not initializing it (I would expect your code to crash!).

    Secondly, it's worth looking at the return values for the API calls - they will help you find problems as and when they occur and are good programming practice.

    The following code works fine for meEVMODE newres; // note, allocate a whole DEVMODE structure, not just a pointer to one
    newres.dmDriverExtra = 0;
    if (EnumDisplaySettings(NULL,ENUM_CURRENT_SETTINGS,&newres))
    long nResult = ChangeDisplaySettings(&newres,CDS_UPDATEREGISTRY);

  3. #3
    Join Date
    Mar 2001

    Re: Please help with ChangeDisplaySettings

    Hi Darren,

    Why do you expect the code crash if dmDriverExtra is not initialized?

    I have a project which uses ChangeVGADisplaySettings() in a way similar to this guy's code. It doesn't crash if I use a not very high frequency,lower than 100mhz, while setting VGA timing. But it does crash if I use a higher frquency for higher resolution,such as 14x10 or 16x12.

    Do you think it is caused by dmDriverExtra that is not initialized? Or by anything else? I did not change refresh rate in my code because the frequency and resolution will force it to that rate. Have I made any mistake here?

    Thanks in advance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)