locked
Disconnecting secondary monitor causing issues with primary monitor virtual geometry RRS feed

  • Question

  • I'm running Windows 10 on a laptop with an external 1920x1080 monitor connected. The external monitor is set as primary and the laptop display as secondary. The scale factor is not set on the laptop, but set to 175% on the external monitor.

    I'm inspecting the virtual display geometry using the windows function EnumDisplayMonitors().

    The issue I am intermittently encountering (roughly one in ten disconnects of the external monitor) is after unplugging the external monitor, the virtual geometry reported on the laptop is incorrect. After unplugging the external monitor the laptop virtual geometry is reported as 50% higher than its actual physical display geometry. A precondition here is I am running a per monitor Hi DPI aware application on the external monitor when disconnecting it.

    Any ideas why disconnecting a monitor in this fashion can occasionally screw up the reported virtual dimensions of my primary laptop display?


    • Edited by steve_l_ Thursday, December 15, 2016 8:38 PM
    Wednesday, December 14, 2016 2:05 AM

All replies


  • I'm running Windows 10 on a laptop with an external 1920x1080 monitor connected. The external monitor is set as secondary and the laptop display as primary. The scale factor is not set on the primary, but set to 175% on the secondary.

    I'm inspecting the virtual display geometry using the C function EnumDisplayMonitors().

    The issue I am intermittently encountering (roughly one in ten disconnects of the secondary monitor) is after unplugging the secondary monitor, the virtual geometry reported on the primary is incorrect. After unplugging the secondary monitor the virtual geometry is reported as 50% higher than its actual physical display geometry. A precondition here is I am running a per monitor Hi DPI aware application on the secondary when disconnecting the primary. 

    Any ideas why disconnecting a monitor in this fashion can occasionally screw up the reported virtual dimensions of my primary laptop display ? 
    • Merged by Hart Wang Thursday, December 15, 2016 2:35 AM duplicate
    Wednesday, December 14, 2016 2:02 AM
  • Hi steve_l_,

    thanks for posting here.

    >>Any ideas why disconnecting a monitor in this fashion can occasionally screw up the reported virtual dimensions of my primary laptop display ? 

    How do you call EnumDisplayMonitors method? In my opinion, this may be caused by the hdc and lprcClip parameters setting.

    Setting the hdc parameter to NULL lets you use the EnumDisplayMonitors function to obtain a handle and position rectangle for one or more display monitors. The following table shows how the four combinations of NULL and non-NULL hdc and lprcClip values affect the behavior of the EnumDisplayMonitors function.

    Hope this could be help of you.

    Best Regards,
    Sera Yu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, December 14, 2016 5:56 AM
  • Hi steve_l_,

    Thank you for posting here.

    Since you have posted same issue on MSDN forum. According to MSDN policy.

    I will merge the case to C++ forum.

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 15, 2016 2:33 AM
  • The steps I used to return monitor geometry were:

    1. First calling SetProcessDpiAwareness() passing in PROCESS_DPI_AWARENESS::PROCESS_PER_MONITOR_DPI_AWARE

    2. Using EnumDisplayMonitors, passing in NULL, NULL to retrieve information for all displays. GetMonitorInfo() was used to retrieve display geometry for each monitor.


    • Edited by steve_l_ Thursday, December 15, 2016 8:37 PM
    Thursday, December 15, 2016 8:36 PM
  • Hi steve_l_,

    Unlike the other awareness values, PROCESS_PER_MONITOR_DPI_AWARE should adapt to the display that it is on. This means that it is always rendered natively and is never scaled by the system. The responsibility is on the app to adjust the scale factor when receiving the WM_DPICHANGED message.

    And also now that DPI awareness is tied to a thread rather than an application, you can use this method to update the DPI awareness. However, consider using SetThreadDpiAwarenessContext instead.

    For more information, please refer to this document below.

    https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx

    Hope this could be help of you.

    Best Regards,
    Sera Yu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, December 19, 2016 8:04 AM