none
GetHDC and multiple screens RRS feed

  • Question

  • On a multiple-display system, I would like to know for any given form, what the device capabilities are for the screen that the form is shown on.

    However, when I do a GetHdc from a form, and do a GetDeviceCaps call, the values from the GetDeviceCaps are only for the Primary Screen, not the screen where the form currently is.

    If you drag a form from one monitor to the next, how do you get the HDC to reflect the new monitor?
    Monday, October 5, 2009 9:44 PM

Answers

  • Use the Screen class in the System.Windows.Forms namespace.  The FromPoint() method gives you a Screen instance.  In unmanaged code, you'd use MonitorFromPoint() and GetMonitorInfo().

    Hans Passant.
    • Marked as answer by eryang Monday, October 12, 2009 2:58 AM
    Tuesday, October 6, 2009 12:30 AM
    Moderator