none
Can the Window.PointsToScreenPixelsX method be used on multiple monitors with different display settings? RRS feed

  • Question

  • My company's Excel add-in needs to get the screen location of worksheet ranges. Historically, this has been quite easy using the Window.PointsToScreenPixelsX and Window.PointsToScreenPixelsY methods (see https://docs.microsoft.com/en-us/office/vba/api/excel.window.pointstoscreenpixelsx).

    However, recent changes to Excel 2016 provide for different scaling on different monitors, so many of our users have multiple monitors with some set to 125% scaling and others set to 100% scaling.

    In these cases, then Window.PointsToScreenPixelsX method returns seemingly random numbers, which obviously aren't random but I can't figure out how they are managing the multiple monitors with differential scaling.

    For example, let's assume that on of our users has 3 monitors side-by-side as follows:

    1. 1920x1080, 125% Scaling (Primary)
    2. 1920x1080, 100% Scaling
    3. 1920x1080, 150% Scaling

    If they open Excel on their 3rd monitor, the Window.PointsToScreenPixelsX returns values that I cannot understand, and I cannot work our how they are being calculated.

    Originally I thought that the Window.PointsToScreenPixelsX and Window.PointsToScreenPixelsY methods would simply ignore scaling, but they do return different values when different scaling is used via Display Settings. So I'm not at a loss...

    Has anyone else fought this battle and either won it or found another way to get the screen coordinates of a range?

    Thanks, M.


    Friday, March 15, 2019 5:27 AM