Problem changing monitor brightness RRS feed

  • Question

  • I am trying to change the monitor brightness programmatically from an MFC C++ app running on Windows 7. I am using the high level monitor configuration functions in DXVA2.dll.

    The problem is that GetPhysicalMonitorsFromHMONITOR() succeeds but it returns a pointer to a PHYSICAL_MONITOR struct that always contains a NULL handle in hPhysicalMonitor, although the physical monitor description field (szPhysicalMonitorDescription) is filled in correctly ("Dell 1901FP (Digital)"). The call to GetMonitorCapabilities() then returns the error code ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA (0xC0262582).

    Below is a snippet of the code:

    _monitorHandle = ::MonitorFromWindow(this->m_hWnd, MONITOR_DEFAULTTOPRIMARY);

        if (_monitorHandle != NULL)
            // Get the number of physical monitors that are associated with the HMONITOR monitor handle.
            BOOL bSuccess = ::GetNumberOfPhysicalMonitorsFromHMONITOR(_monitorHandle, &_numberOfPhysicalMonitors);
            if (bSuccess == TRUE && _numberOfPhysicalMonitors > 0)
                _physicalMonitors = new PHYSICAL_MONITOR[_numberOfPhysicalMonitors];
                // Retrieve the physical monitors associated with the HMONITOR monitor handle
                bSuccess = ::GetPhysicalMonitorsFromHMONITOR(_monitorHandle, _numberOfPhysicalMonitors, _physicalMonitors);

                if (bSuccess == TRUE)
                    HANDLE physicalMonitorHandle = _physicalMonitors[0].hPhysicalMonitor;
                    DWORD monitorCapabilities = 0;
                    DWORD supportedColourTemperatures = 0;

                    if (::GetMonitorCapabilities(physicalMonitorHandle, &monitorCapabilities, &supportedColourTemperatures) == TRUE)
                        _brightnessSupported = ((monitorCapabilities & MC_CAPS_BRIGHTNESS) > 0);

    Anyone know why a null handle is being returned. It fails in the same manner on several computers.





    • Moved by Jesse Jiang Thursday, September 1, 2011 5:56 AM (From:Visual C++ General)
    Wednesday, August 31, 2011 1:07 AM

All replies

  • Hi Martin,


    I think your issue should be raised in the Media Foundation Development for Windows Desktop. I believe they will know more information of this issue than us, and I will move this one to that forum.


    Thanks for your understanding,


    Best regards,


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, September 1, 2011 5:55 AM
  • Hey, bcs0228. Did you resolve the issue?

    I'm facing the same error returned by GetMonitorCapabilities, but I think the issue is not in the monitor handle being NULL. It may mean just a generic handle to the main display. The reason I say this is because my code similar to yours works fine on my Windows 7 system with the hPhysicalMonitor being 0, but then on another system the call to GetMonitorCapabilities returns FALSE and GetLastError returns ERROR_GRAPHICS_I2C_ERROR_TRANSMITTING_DATA or (0xc0262582).

    So I'd appreciate if you could share any info on this if you happened to fix it ...

    Wednesday, August 8, 2012 11:42 PM