Page 1 of 2 12 LastLast
Results 1 to 40 of 48

Thread: Working With Different Monitor Resolutions

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Working With Different Monitor Resolutions

    Hello,

    I'm having trouble getting my app to display properly on different monitors.
    I had originally built my app on a system with a monitor having a resolution of 1920X1200

    My app draws to scale using GDI+
    Using GDI+ an 850 pixel x 1100 pixel rectangle is 8.5" x 11"
    and I found that 800 pixels x 1035 pixels draws exactly 8.5" x 11" on the above monitor.
    All my scaling when drawing to the monitor used the above ratio.

    I never really understood why I had to scale 850px to 800px, but it works.

    Can someone please explain to me why this works?

    Also now that I am trying on different monitors, I find that:
    For a 1920X1080 resolution monitor
    800 pixels X 931 pixels gives exactly 8.5"X11"
    For a 1680 X1050 resolution monitor
    697 pixels X 905 pixels gives exactly 8.5"X11"

    Is there a proper mathematical way to deal with these different resolutions, rather than just trial and error?
    Last edited by mms_; Nov 11th, 2018 at 03:02 AM.

  2. #2
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Working With Different Monitor Resolutions

    Hello, welcome to the forums.

    You may want to read this thread.

  3. #3
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Working With Different Monitor Resolutions

    Hello mms_,

    Yes, welcome to the forums.

    From your post, I'm not exactly sure what you're asking. I've read it a couple of times, and it seems to be one of two things:

    1) When you draw something that's, say, 400 x 400 pixels, you want to make sure it's square on the monitor. And this is irrespective of its actual size when measured with a physical ruler.
    or
    2) You want to be able to draw graphics on the screen, and have their size be in some true physical dimensions.

    If it's #1 you're after, that doesn't seem difficult to me, as virtually all monitors have a per-pixel 1-to-1 aspect ratio (be sure to read my Edit1 at the bottom). So, unless you've got some really weird monitor, you should be able to just treat your pixel (or twip) aspect ratio as 1, and everything should be fine.

    However, if it's #2 you're after, that's a much more nettlesome problem. This is something I've continued to work on, and I still don't have a perfect answer. When monitors are installed on a computer's system, they place something called the EDID (Extended Display Identification Data) into the registry. (There's also a deeper version of the EDID in the video card that VB6 can't get at.) However, on a multi-monitor system, or even on a system that has had different monitors used on it, I've found it virtually impossible to pair this EDID information with an actual monitor handle (hMonitor). You may be able to find some web pages that claim to do it, such as this one, but I've never been able to make them reliably work, and I've tried. My system is a high-end ASUS gamer's laptop, and I frequently take it to client sites and plug different monitors into it. Furthermore, at home, I have a three external monitors whereby I disable the laptop's actual monitor. Sitting here right now, I can request registry EDID information, and it doesn't report correctly. In fact, although my center monitor is a Samsung 32" monitor, and my two side monitors are somewhat smaller full-HD ASUS monitors, the registry reports the same EDID information for all three monitors.

    Now, what's more frustrating is that Windows knows my monitors are different, because it correctly reports GetDpiForMonitor Windows API information.

    If you're really insistent upon trying to get a monitor's true physical dimensions, you might try the relatively new DXGI.DLL, specifically this call, along with the DXGI_OUTPUT_DESC1 structure. That's something I haven't tried, and it may be a reliable way to pair a monitor's hMonitor with its EDID information.

    Now, short of trying to dig out a monitor's EDID information, I do have routines that come very close to doing what you want (i.e., #2 above). If you look at the code in the attached BAS module, specifically the MonitorPhysicalWidth and MonitorPhysicalHeight functions, they can help you to draw that box with known physical dimensions. Those two functions, along with MonitorWidthTwips and MonitorHeightTwips (or MonitorWidthPx and MonitorHeightPx) will get you very close. However, please note that, to accomplish this, the GetDpiForMonitor Windows API call is made, along with using a couple of different values out of the MONITOR_DPI_TYPE enumeration. And this approach seems to get quite close to physical dimensions, but not necessarily exact.

    Also, you may find code posted by me in the codebank that shows how to get at that EDID information, and also code kicking around by Tanner Helland, but I can promise you that it's not reliable, as stated above.

    Good Luck,
    Elroy

    EDIT1: I should probably say one more thing. Personally, I've always highly recommended to all my clients that they run their monitors in their native resolution, and also at 96 (100%) DPI. If they want to enlarge their forms (fonts, images, etc), I recommend that they make sure they're on Windows 10, and that they use the new "Change the size of text, apps, and other items" setting within Windows 10 settings. In my experience, this provides much better results, and doesn't tamper with the way the GDI or GDI+ works on the system (which changing the DPI does).

    If you're using resolutions other than the native (whereby a logical pixel is no longer a physical pixel) resolution, I'll bow out and let others get it sorted for you. Yes, this happens when you use the Windows 10 scaling. However, with the Windows 10 scaling, you still know that your per-pixel aspect ratio is still 1-to-1.
    Attached Files Attached Files
    Last edited by Elroy; Nov 11th, 2018 at 06:24 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Working With Different Monitor Resolutions

    Sure, LCD monitors pretty much have to be used with their native settings. They aren't analog devices like a CRT, and even color CRTs aren't completely analog due to the way they work with phosphor dots or stripes and shadow masks.

    "Change the size of text, apps, and other items" isn't magic, it changes the DPI setting used by Windows for the monitor from standard 96 to something larger.

    If your programs are not DPI Aware and do not deal with DPI settings other than 96 one form or another of appcompat display virtualization is applied. This can result in blurry text and blurred pixelated bitmap graphics and even wrong-size fonts and text cut off in controls and Forms.

    You might read High DPI Settings in Windows and the other articles it links to.


    "Pixel" is always a relative unit of measure in Windows. Units like Twips, Inches, Centimeters, etc. are considered absolute units. That has nothing to do with the dots that light up on a display being actual physical things. Getting hung up on that just leads to madness.

    It has to be that way or we'd never have had proper printing or plotting capabilities in Windows.


    However none of that has anything to do with the sucker's game of trying to use a monitor as a ruler or cutting board. Even if you jump through hoops trying to tweak everything just so, as soon as you use another monitor all of your tweaks need to be done over again.

    Monitor makers are not required to match up dot pitch with any external physical measurements, and they don't even have to provide accurate EDID data.
    Last edited by dilettante; Nov 11th, 2018 at 02:09 PM.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    Thank you all for the in-depth answers!

    There is a wealth of information there and it's going to take time to digest it all.

    My app is designed for two monitors.
    Basically user does his thing on monitor one, and two pages are displayed side-by-side on the secondary monitor.
    All pages in the project can be scrolled through in pairs.
    In my case the second monitor is ~ 20-1/2" x 13" and two exact-size 8-1/2" x 11" pages fit nicely on that large monitor.
    Any graphics drawn on those pages are to scale.
    Sure, no one is going to take a ruler and measure anything on the screen, but to my eye it is very pleasing.

    Last night I found I can easily scale things to fit on any monitor selected knowing the resolution of that second monitor and it's
    aspect ratio.
    I scale from the original 800px to 850px ratio.
    What's troubling to me is where I came up with this; probably trial and error, but I found these commented out lines in my code:
    Code:
    'screenDpiX = screenPixelX / screenInchX '= 94.11765
    'screenDpiY = screenPixelY / screenInchY '= 93.16666
    I started out using a 1920x1200 (ie 16:10) monitor
    I must have just decided to use one scaling constant of 0.941 (800/850=0.94112 and 1035/1100=0.9409)
    and then scale again if a different 16:10 monitor was used.
    I assumed I guess that X and Y DPi's would always be the same,
    Now I see the high-definition monitor I have 1920×1080 does not have the same aspect ratio
    Different X and Y scaling factors are required 800/850=0.94112 for X direction and 931/1100=0.84636 for Y direction
    I have to change all my drawing code and this will not be trivial. Ouch!

    Am I missing something, or having different X and Y scale factors is just the way it is?

    Elroy
    I was very excited when I saw you posted MonitorPhysicalWidth and MonitorPhysicalHeight functions
    (thanks for these), but when I tried to run them I was getting zero returns for both.
    Investigating further I see Windows8 or higher is required. I am running Windows7 unfortunately.

    Until I upgrade, is there any Windows7 way to retrieve this information that you know of?
    Last edited by mms_; Nov 11th, 2018 at 03:37 PM.

  6. #6
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Working With Different Monitor Resolutions

    Basically, if you want something to have some physical dimension in a monitor, you need to know the physical dimensions of that monitor, convert that to Twips, Pixels or to the scale that you use and then apply Rule of Three.
    You may need to declare the application as DPI aware so Windows doesn't lie to you when reporting [whatever].

    The difficult part is to get the monitors physical dimensions. There are methods reading the EDID data but it seems that they are not always reliable or available, and it seems that the only realible method is to instruct the user to physically measure the monitor with a physical ruler and enter the data.

  7. #7
    Frenzied Member
    Join Date
    May 2014
    Location
    Kallithea Attikis, Greece
    Posts
    1,289

    Re: Working With Different Monitor Resolutions

    I think OP have to use rendering of the page in screen,the page which may hold in memory bitmap. In a memory bitmap he can use exactly the pixels for Width/Height and the rendering need to know only the width and height in pixels where should be FIT IN the page. FIT IN means that with any aspect ratio of the page we can redraw to get maximum area in the output or rendering frame. So maybe there are bands left right or up down. Also when we resize a bitmap we have to use HALFTONE because we get a blend of pixels. The other way COLORONCOLOR destroy the image, especially if we have text (fine details). Some image viewers use the COLORONCOLOR which is fast, when we make continues scale, and at the final scale use the HALFTONE.

    About the stretch mode: https://docs.microsoft.com/en-us/win...stretchbltmode

    take a look here http://www.vbforums.com/showthread.p...-encoder-class
    where I post a viewer (you can also paint on it). Shows how to make various tasks, cropping, resizing, using a pointer to paint. You can paint on a memory bitmap as you see the rendering one in any scale.

  8. #8
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Working With Different Monitor Resolutions

    Quote Originally Posted by mms_ View Post
    Elroy
    I was very excited when I saw you posted MonitorPhysicalWidth and MonitorPhysicalHeight functions
    (thanks for these), but when I tried to run them I was getting zero returns for both.
    Investigating further I see Windows8 or higher is required. I am running Windows7 unfortunately.

    Until I upgrade, is there any Windows7 way to retrieve this information that you know of?
    Hi mms_,

    It's the GetDpiForMonitor API call found in the shcore.dll library I'm using, and this was introduced in Windows 8.1. I seriously doubt you could install this library on earlier versions of Windows, and I wouldn't even try.

    The only other alternative is going to be digging the EDID out of the registry. And again, as I and others have stated, this isn't reliable. And also, the following code doesn't use an extremely well documented way of digging the EDID out of the registry, as there are other ways more documented by Microsoft to get it out. So, with those caveats, I'll provide the following code:

    Code:
    Option Explicit
    '
    Public Type RECT
        Left   As Long
        Top    As Long
        Right  As Long ' This is +1 (right - left = width)
        Bottom As Long ' This is +1 (bottom - top = height)
    End Type
    Private Type DISPLAY_DEVICEW
       cbSize As Long
       DeviceName(0 To 63) As Byte
       DeviceString(0 To 255) As Byte
       StateFlags As Long
       DeviceID(0 To 255) As Byte
       DeviceKey(0 To 255) As Byte
    End Type
    Private Type MONITORINFOEX
        cbSize As Long
        rcMonitor As RECT
        rcWork As RECT
        dwFlags As Long
        szDevice As String * 32
    End Type
    '
    Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Dest As Any, ByRef Source As Any, ByVal Bytes As Long)
    Private Declare Function RegOpenKeyExW Lib "advapi32" (ByVal HKEY As Long, ByVal ptrToSubKey As Long, ByVal ulOptions As Long, ByVal samDesired As Long, ByRef phkResult As Long) As Long
    Private Declare Function RegQueryValueExW Lib "advapi32" (ByVal HKEY As Long, ByVal lpszValueName As Long, ByVal lpReserved As Long, ByRef lpType As Long, ByVal ptrToData As Long, ByRef lpcbData As Long) As Long
    Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal HKEY As Long) As Long
    Private Declare Function EnumDisplayDevices Lib "user32" Alias "EnumDisplayDevicesW" (ByVal ptrToDeviceName As Long, ByVal iDevNum As Long, ByRef lpDisplayDevice As DISPLAY_DEVICEW, ByVal dwFlags As Long) As Long
    Private Declare Function GetMonitorInfoEx Lib "user32.dll" Alias "GetMonitorInfoA" (ByVal hMonitor As Long, ByRef lpmi As MONITORINFOEX) As Long
    '
    
    Public Function MonitorSerialNo(hMonitor As Long) As Long
        ' NOT reliable, based on EDID.
        ' Returns ZERO if not found or not available for some reason.
        Dim bbEDID() As Byte
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        ' Grab a serial number, which is just a 4-byte long in positions 12-15 (0-based).
        CopyMemory ByVal VarPtr(MonitorSerialNo), ByVal VarPtr(bbEDID(12)), 4&
    End Function
    
    Public Function MonitorWidthMM(hMonitor As Long) As Single
        ' NOT reliable, based on EDID.
        ' Returns ZERO if not found or not available for some reason.
        Dim bbEDID() As Byte
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        MonitorWidthMM = ((bbEDID(68) And &HF0) * 16) + bbEDID(66)
    End Function
    
    Public Function MonitorHeightMM(hMonitor As Long) As Single
        ' NOT reliable, based on EDID.
        ' Returns ZERO if not found or not available for some reason.
        Dim bbEDID() As Byte
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        MonitorHeightMM = ((bbEDID(68) And &HF) * 256) + bbEDID(67)
    End Function
        
    Public Function MonitorSizeInch(hMonitor As Long) As Single
        ' NOT reliable, based on EDID.
        ' Returns ZERO if not found or not available for some reason.
        Dim bbEDID() As Byte
        Dim lWidthMM As Long
        Dim lHeightMM As Long
        Dim nWidthInches As Single
        Dim nHeightInches As Single
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        '
        lWidthMM = ((bbEDID(68) And &HF0) * 16) + bbEDID(66)
        lHeightMM = ((bbEDID(68) And &HF) * 256) + bbEDID(67)
        nWidthInches = (lWidthMM / 25.4!)
        nHeightInches = (lHeightMM / 25.4!)
        MonitorSizeInch = CLng(Sqr(nWidthInches * nWidthInches + nHeightInches * nHeightInches) * 10!) / 10!
    End Function
        
    Public Function MonitorWidthInch(hMonitor As Long) As Single
        ' NOT reliable, based on EDID.
        ' Returns ZERO if not found or not available for some reason.
        Dim bbEDID() As Byte
        Dim lWidthMM As Long
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        '
        lWidthMM = ((bbEDID(68) And &HF0) * 16) + bbEDID(66)
        MonitorWidthInch = CLng((lWidthMM / 25.4!) * 10!) / 10!
    End Function
        
    Public Function MonitorHeightInch(hMonitor As Long) As Single
        ' NOT reliable, based on EDID.
        ' Returns ZERO if not found or not available for some reason.
        Dim bbEDID() As Byte
        Dim lHeightMM As Long
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        '
        lHeightMM = ((bbEDID(68) And &HF) * 256) + bbEDID(67)
        MonitorHeightInch = CLng((lHeightMM / 25.4!) * 10!) / 10!
    End Function
        
    Public Function MonitorNativeResHorizPx(hMonitor As Long) As Single
        ' NOT reliable, based on EDID.
        ' Returns ZERO if not found or not available for some reason.
        Dim bbEDID() As Byte
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        '
        MonitorNativeResHorizPx = ((bbEDID(58) And &HF0) * 16) + bbEDID(56)
    End Function
        
    Public Function MonitorNativeResVertPx(hMonitor As Long) As Single
        ' NOT reliable, based on EDID.
        ' Returns ZERO if not found or not available for some reason.
        Dim bbEDID() As Byte
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        '
        MonitorNativeResVertPx = ((bbEDID(61) And &HF0) * 16) + bbEDID(59)
    End Function
    
    Public Function MonitorName(hMonitor As Long) As String
        ' NOT reliable, based on EDID.
        ' Returns empty string if not found or not available for some reason.
        Dim bbEDID() As Byte
        Dim iBlockPtr As Long
        Dim iOffset As Long
        Dim sName As String
        Dim sChar As String
        Dim i As Long
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        '
        ' Monitor name is an optional descriptor (but provided 99.9% of the time).
        ' Found in one of the four VESA Descriptor blocks of the EDID.  Those descriptor blocks are found in set locations:
        ' 54-71, 72-89, 90-107, 108-125
        ' Location of the monitor name is not guaranteed in advance, so each block must be parsed individually until found.
        For iBlockPtr = 0 To 3
            ' Determine a proper offset based on which descriptor block we're searching.
            Select Case iBlockPtr
            Case 0: iOffset = 54
            Case 1: iOffset = 72
            Case 2: iOffset = 90
            Case 3: iOffset = 108
            End Select
            '
            ' Check the first three bytes of the descriptor.
            ' These must always be 0 (per the EDID spec); if they aren't, this is the primary timing descriptor.
            If (bbEDID(iOffset) = 0) And (bbEDID(iOffset + 1) = 0) And (bbEDID(iOffset + 2) = 0) Then
                '
                ' This is not the primary timing block.
                ' Look for the #FC identifier in byte 3, which indicates a monitor name block.
                If (bbEDID(iOffset + 3) = &HFC) Then
                    ' Retrieve the monitor name and trim any null bytes.
                    sName = vbNullString
                    For i = (iOffset + 4) To (iOffset + 17)
                        If (bbEDID(i) <> 0) Then
                            sChar = Chr$(bbEDID(i))
                            If (sChar = vbLf) Or (sChar = vbCr) Then sChar = " "
                            sName = sName & sChar
                        End If
                    Next i
                    ' Save the retrieved monitor name now.
                    If Len(sName) > 0 Then
                        MonitorName = Trim$(sName)
                        Exit Function
                    End If
                End If
            End If
        Next iBlockPtr
    End Function
        
    Public Function MonitorMfgYear(hMonitor As Long) As Integer
        ' NOT reliable, based on EDID.
        ' Returns ZERO if not found or not available for some reason.
        Dim bbEDID() As Byte
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        
        ' A 2-byte int in positions 17-18 (0-based).
        CopyMemory ByVal VarPtr(MonitorMfgYear), ByVal VarPtr(bbEDID(17)), 1&
        MonitorMfgYear = MonitorMfgYear + 1990
    End Function
        
    Public Function MonitorMfgWeek(hMonitor As Long) As Integer
        ' NOT reliable, based on EDID.
        ' Returns ZERO if not found or not available for some reason.
        '
        ' Note that both Week and Year are a bit funky.
        ' If Week returns 255, then the Year is the Model year and not necessarily the Manufacture year.
        Dim bbEDID() As Byte
        '
        If Not MonitorEDID(hMonitor, bbEDID) Then Exit Function
        
        ' A 2-byte int in positions 17-18 (0-based).
        CopyMemory ByVal VarPtr(MonitorMfgWeek), ByVal VarPtr(bbEDID(16)), 1&
    End Function
    
    Public Function MonitorEDID(hMonitor As Long, bbEDID() As Byte) As Boolean
        ' Tanner Helland deserves a great deal of the credit for workout out reading the EDID from the registry.
        ' Extended Display Identification Data (EDID).
        ' All kinds of information is provided in the EDID.
        ' A good resource is: https://en.wikipedia.org/wiki/Extended_Display_Identification_Data
        '
        ' Given a registry path (created from a monitor's device ID), retrieve a corresponding EDID.
        ' Returns: TRUE if the EDID is found, else FALSE.
        ' The actual EDID is returned in bbEDID().  Be careful, it's not dimensioned if not found.
        Dim hReg As Long
        Dim iRet As Long
        Dim iSize As Long
        Dim sReg As String
        Dim sRegPath As String
        '
        Const HKEY_LOCAL_MACHINE As Long = &H80000002 ' EDID data is stored in the local machine branch; note that WRITING values here requires admin access, but QUERYING does not.
        Const KEY_QUERY_VALUE As Long = &H1& ' To avoid UAC, we must only use QUERY access rights.
        '
        sRegPath = MonitorRegKeyPart(hMonitor)
        If Len(sRegPath) = 0 Then Exit Function
        '
        ' Use the substrings to create a path to the EDID location inside the registry
        sRegPath = "System\CurrentControlSet\Enum\Display\" & sRegPath & "\Device Parameters"
        '
        ' Before we can retrieve the EDID, we first have to open its registry key.  Get a handle to the key (if possible).
        iRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, StrPtr(sRegPath), 0&, KEY_QUERY_VALUE, hReg)
        'The registry key was opened successfully.  Use it to query the actual value at that location.
        If (iRet = 0&) And (hReg <> 0&) Then
            ' Before retrieving the array itself, we need to determine its size.
            sReg = "EDID"
            iRet = RegQueryValueExW(hReg, StrPtr(sReg), 0&, ByVal 0&, ByVal 0&, iSize)
            ' Size was retrieved successfully.  Dimension the array and receive the EDID data.
            ' EDIDs should never be shorter than 128 bytes.
            ' Newer versions of the spec allow *longer* than 128, but 128 is the minimum.
            If (iRet = 0&) And (iSize >= 128&) Then
                ReDim bbEDID(0 To iSize - 1)
                iRet = RegQueryValueExW(hReg, StrPtr(sReg), 0&, 0&, VarPtr(bbEDID(0)), iSize)
                If iRet = 0& Then MonitorEDID = True
            End If
        End If
        If Not MonitorEDID Then Erase bbEDID
        If hReg Then RegCloseKey hReg
    End Function
    
    Public Function MonitorRegKeyPart(hMonitor As Long) As String
        ' This returns the two key parts (concatenated) to get the monitor's registry info.
        ' it should be prefaced with "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\DISPLAY\" for use.
        ' Neither a preceeding nor following \ is returned.
        ' Empty string is returned if it can't be found.
        Dim i As Long
        Dim sDevID As String
        Dim sArray() As String
        Dim sInternalName As String
        Dim InfoDetailed As DISPLAY_DEVICEW
        '
        sInternalName = MonitorInternalName(hMonitor)
        If Len(sInternalName) = 0 Then Exit Function
        '
        InfoDetailed.cbSize = LenB(InfoDetailed)
        If EnumDisplayDevices(StrPtr(sInternalName), 0&, InfoDetailed, 1&) = 0& Then Exit Function
        '
        sDevID = String$(128, 0)
        CopyMemory ByVal StrPtr(sDevID), ByVal VarPtr(InfoDetailed.DeviceID(0)), 256
        i = InStr(sDevID, vbNullChar)
        If i Then sDevID = Left$(sDevID, i - 1)
        If Len(sDevID) = 0 Then Exit Function
        ' We need to parse out various bits of the device ID in order to construct a registry path where the EDID lies.
        ' The substrings we need are delimited by pound signs, so make sure at least one exists.
        If InStr(sDevID, "#") = 0 Then Exit Function
        ' Parse the device ID into discrete substrings.
        sArray = Split(sDevID, "#")
        ' Make sure we generated enough substrings to correctly generate a registry path.
        If UBound(sArray) < 2 Then Exit Function
        '
        MonitorRegKeyPart = sArray(1) & "\" & sArray(2)
    End Function
    
    Public Function MonitorInternalName(hMonitor As Long) As String
        ' This is an internal name that isn't good for much (other than calls herein).
        '
        ' Need to check that cbSize = Len(uMonInfoEx) is correct.
        '
        Dim i As Long
        Dim uMonInfoEx As MONITORINFOEX
        uMonInfoEx.cbSize = Len(uMonInfoEx)
        If GetMonitorInfoEx(hMonitor, uMonInfoEx) = 0 Then Exit Function
        MonitorInternalName = uMonInfoEx.szDevice
        i = InStr(MonitorInternalName, vbNullChar)
        If i Then MonitorInternalName = Left$(MonitorInternalName, i - 1)
    End Function

    Similar to my code in post #3, this is a wholly self-contained BAS module. I didn't provide you any way to get hMonitor in this module, but you can use the functions in the other module to get these handles (hMonitorForForm, hPrimaryMonitor, hSecondaryMonitor). I've also got another procedure that just returns an array of hMonitor values, which is handles for all the active monitors on the system. Let me know if you think you need it, and I'll post it.

    Basically, to answer your question, you'd focus on MonitorWidthMM, MonitorHeightMM, MonitorSizeInch, MonitorWidthInch, MonitorHeightInch. There are also calls for MonitorNativeResHorizPx and MonitorNativeResVertPx, which could possibly be used to determine an aspect ratio, and then compare that to the aspect ratio of the resolution you're using, making appropriate adjustments.

    But let's be clear, every one of the above calls involves reading the EDID from the registry. If you're interested in learning more about the EDID, there's a good Wikipedia page on it. These EDIDs are actually things larger than Windows, and are used by all OSs.

    Good Luck,
    Elroy

    EDIT1: I'm also a bit reluctant to say this, but I'd recommend that you consider getting everyone updated to Windows 10. Microsoft has been working really hard to do scaling in a way that's far superior to either changing monitor resolutions and/or changing the DPI. With the new "Scale and Layout" settings, you get correctly scaled fonts and well scaled pictures, without even worrying about all the DPI Aware stuff that some of the above talked about. Simply stated, it just works. Furthermore, I've got some old GDI graphics procedures that don't work correctly unless DPI = 96 (100%), and these all work fine regardless of how the Windows 10 "Scale and Layout" settings are set.
    Last edited by Elroy; Nov 11th, 2018 at 08:29 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  9. #9
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Working With Different Monitor Resolutions

    Quote Originally Posted by Elroy View Post
    With the new "Scale and Layout" settings, you get correctly scaled fonts and well scaled pictures, without even worrying about all the DPI Aware stuff that some of the above talked about. Simply stated, it just works.
    I'm already wondering if I'm the only one that dislikes very much to see the text blurred.

    (The first thing that I do every time I install a new program and I see the text blurred is to set in the compatibility tab "Disable Display Scaling On High DPI Settings".)

  10. #10
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: Working With Different Monitor Resolutions

    You do realize that in order to determine the actual size it will be when displayed depends on more than the res and aspect ratio right?

    Monitor size and DPI settings also play a huge part.

  11. #11
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Working With Different Monitor Resolutions

    "Disable Display Scaling On High DPI Settings" doesn't even exist any more. It appears to be an old feature of the abandoned Windows 8.x OSs and unsupported versions of Windows 10. It might have existed in Windows 7 but it isn't documented anymore.

    Some desktop applications may appear blurred on high-DPI displays

    Disable DPI virtualization for the application. To do this, right-click the application’s shortcut and then click Properties. On the Compatibility tab, select Disable Display Scaling On High DPI Settings, and then click OK. This causes the text in the application to appear clearer. However, if the application does not correctly handle high DPI settings, this procedure may have adverse side effects such as truncated text and incorrectly sized graphical elements.
    This is why we got the new GDI Scaling option in a recent (April 2017) update to Windows 10, about 3 updates ago. That appcompat shim is also known as "System (enhanced) DPI virtualization."

    Time to get aboard the train, Windows 10 left the station a long, long time ago (July 2015). We can almost still see you back there.

  12. #12
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Working With Different Monitor Resolutions

    Quote Originally Posted by dilettante View Post
    "Disable Display Scaling On High DPI Settings" doesn't even exist any more. It appears to be an old feature of the abandoned Windows 8.x OSs and unsupported versions of Windows 10. It might have existed in Windows 7 but it isn't documented anymore.

    Some desktop applications may appear blurred on high-DPI displays



    This is why we got the new GDI Scaling option in a recent (April 2017) update to Windows 10, about 3 updates ago. That appcompat shim is also known as "System (enhanced) DPI virtualization."

    Time to get aboard the train, Windows 10 left the station a long, long time ago (July 2015). We can almost still see you back there.
    Ok, tell me then what is the name in English. I have it in Spanish.

    Name:  No_DPI_Scaling.png
Views: 947
Size:  24.2 KB

    PS: it is Windows 1709

  13. #13
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Working With Different Monitor Resolutions

    The Forum software will probably turn this into a bloated, blurry JPEG, but... that doesn't look like the Properties dialogs I have:

    Name:  sshot.jpg
Views: 973
Size:  45.1 KB

    Yep. Oh well.

    Point being, DPI settings are on a second subdialog now and there is nothing like Disable Display Scaling On High DPI Settings there.

  14. #14
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Working With Different Monitor Resolutions

    Ok, that, thanks. I always set by "Application". That eliminates the blurring.

  15. #15
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Working With Different Monitor Resolutions

    1709 is still good for a few months. Support ends soon though:

    End of service for Home, Pro, and Pro for Workstation editions: April 9, 2019.

  16. #16
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Working With Different Monitor Resolutions

    Quote Originally Posted by Eduardo- View Post
    Ok, that, thanks. I always set by "Application". That eliminates the blurring.
    Er, then you are lying to Windows and saying your program is DPI Aware when it isn't.

  17. #17
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Working With Different Monitor Resolutions

    Quote Originally Posted by dilettante View Post
    Er, then you are lying to Windows and saying your program is DPI Aware when it isn't.
    They are not my programs. They are any program (about 10 may be now) that I use from any source.

    About what that setting does, yes, I suppose that is the same as the manifest stating that it is DPI aware.
    I saw a couple of little problems in a couple of programs, but not something I can't live with.
    Also I may be reading the text smaller, the text displaying as for 96 DPI even when the screen is set to 120 DPI (I really didn't investigate much).
    I only saw a real problem in just one program (TextRep) where the screen was cut and a button then was missing. I had to set it back to blurred text in that case.

  18. #18
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Working With Different Monitor Resolutions

    Quote Originally Posted by dilettante View Post
    you are lying to Windows
    Yes, I lie a lot to Windows. But it lied to me first.

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    Elroy
    Thank you again for your response and a possible Windows7 solution.

    I tried your code for both my primary and secondary monitors.
    Primary monitor size is correctly reported as 13.5" x 7.6"
    Secondary monitor is erroneously reported as 31.5" x 17.7" (it actually is 20.4" x 12.8")

    I will take you up on your offer for your procedure that returns an array of hMonitor values for all monitors in system.

    When I first attached a secondary monitor to my laptop this weekend, Windows showed three additional monitors.
    I had hooked up different additional monitors in the past.
    Perhaps Windows keeps these entries in the Registry, and Windows is reporting a previous secondary monitor??
    (I did hook up to a very large monitor in the past for a presentation at work).

    Thanks to others also.
    Last edited by mms_; Nov 11th, 2018 at 11:32 PM.

  20. #20

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    oops!

    Didn't mean to double post, and I can't delete this!
    Moderator please delete.
    Last edited by mms_; Nov 11th, 2018 at 11:30 PM.

  21. #21
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Working With Different Monitor Resolutions

    Quote Originally Posted by mms_ View Post
    Elroy
    I will take you up on your offer for your procedure that returns an array of hMonitor values for all monitors in system.
    Here's more stand alone code that returns the array of hMonitor handles. Also note that, in places in my code, I have things called "Monitor Numbers (Num)" in addition to hMonitor handles. These numbers are just a 1,2,3 ordinal count of the monitors (with primary not necessarily being 1). Furthermore, it's important to realize that these do NOT necessarily match up with the monitor numbers you see in Control Panel (or Settings). I have yet to figure out a way to match those Control Panel numbers with anything I can get with an API call. But that really hasn't ever bothered me. My Primary Monitor is always the one you're using for the TaskBar, and that works.

    Also, in addition to the following code snippet, I've attached my entire Gen_MonitorEx.BAS module from my primary project. Please understand that this module has been reworked several times through the years. At present, it does everything I need for a Windows 10 (and prior Windows) system. A while back, I abandon all use of the VB6 Screen object (except the case of gathering fonts), as that Screen object lies to us in many respects when trying to use things like .TwipsPerPixelX, .TwipsPerPixelY, .Width, & .Height. Rather than use that Screen object, I use the calls found in this Gen_MonitorEx.BAS module, and things work MUCH better.

    Now, I must say that the attached (zipped) Gen_MonitorEx.BAS module isn't entirely self-contained. In other words, it makes some references to other things in my primary project. However, in the above pieces I gave you (which were all snipped out of this Gen_MonitorEx.BAS module) I believe I filled in those references (just trying to be nice and clear). If you use the Gen_MonitorEx.BAS module attachment, I'll leave it to you to clean up those references in your own project. (However, again, the little code snippet below with the MonitorHandles call is self-contained.)

    Code:
    
    Option Explicit
    '
    Public Type RECT
        Left   As Long
        Top    As Long
        Right  As Long ' This is +1 (right - left = width)
        Bottom As Long ' This is +1 (bottom - top = height)
    End Type
    '
    Private Declare Function EnumDisplayMonitors Lib "user32" (ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As Long, dwData As Long) As Long
    '
    Private giTemp() As Long
    '
    
    Public Function MonitorHandles() As Long()
        ' All of them, ZERO based.
        Dim i As Long
        Dim iTempPtr As Long
        i = MonitorCount
        If i = 0 Then Exit Function
        '
        ReDim giTemp(0 To i - 1)
        iTempPtr = -1               ' Start at -1 because the array will be zero based.
        EnumDisplayMonitors 0&, ByVal 0&, AddressOf MonitorGatherEnum, iTempPtr
        MonitorHandles = giTemp
    End Function
    
    Public Function MonitorCount() As Long
        ' This does NOT count disabled monitors.
        EnumDisplayMonitors 0&, ByVal 0&, AddressOf MonitorCountEnum, MonitorCount
    End Function
    
    Private Function MonitorGatherEnum(ByVal hMonitor As Long, ByVal hdcMonitor As Long, uRect As RECT, dwData As Long) As Long
        dwData = dwData + 1
        giTemp(dwData) = hMonitor
        MonitorGatherEnum = 1 ' Gather them all.
    End Function
    
    Private Function MonitorCountEnum(ByVal hMonitor As Long, ByVal hdcMonitor As Long, uRect As RECT, dwData As Long) As Long
        dwData = dwData + 1
        MonitorCountEnum = 1 ' Count them all.
    End Function
    

    ------------------------------------

    Quote Originally Posted by mms_ View Post
    I tried your code for both my primary and secondary monitors.
    Primary monitor size is correctly reported as 13.5" x 7.6"
    Secondary monitor is erroneously reported as 31.5" x 17.7" (it actually is 20.4" x 12.8")
    Yes, those are precisely the problems that I (and I believe others) have seen when trying to use the EDID information. Things seem to work fine if you take a new computer out of the box, and then plug new monitors into it. However, once you start swapping around monitors, Windows doesn't keep things straight in a way that allows us to "get at it". What's most frustrating is that, internally, Windows DOES keep it straight. Otherwise, how could those MonitorPhysicalWidth and MonitorPhysicalHeight functions work that I initially gave you, and, they do work (although it takes Windows 8.1 or later to see it).

    Personally, and to state again, for us on Win10, I think we should explore getting the DXGI_OUTPUT_DESC1 structure with calls to GetDesc1 found in the DXGI.DLL library. This seems to have good possibilities. If I get motivated, I may look into that. But mms_, that's not going to help you until you upgrade to Windows 10, as the DXGI.DLL is quite new.

    Anyway, best of luck with your project.

    Elroy

    EDIT1: Actually, I believe I'm mistaken about the "age" of the DXGI.DLL library. Actually, it seems to have been around for a while. I just need to explore what it's capable of giving us, and how much work it would take to get it.
    Attached Files Attached Files
    Last edited by Elroy; Nov 12th, 2018 at 08:25 AM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  22. #22

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    Thank you Elroy

    Just for fun, I tried your EDID code on my work computer this morning.
    Primary monitor is erroneously reported as 14.4" x 10.8" (it actually is 16.0" x 12.0")
    Secondary monitor size is correctly reported as 20.4" x 12.8"
    The secondary monitor here at work is exactly the same (make and model) as my home secondary monitor.
    I'm running Windows7 Professional on both systems.

    Regarding Windows10, IT here at work has been hounding me for a while to let them upgrade me to a new system;
    I keep putting them off, but it will have to happen in the next few months.
    At home also I will upgrade after I see how work system is.

    Does VB6 install painlessly on Windows10?
    Does VB6 work properly on Windows10?

    Thanks again!

  23. #23

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    This is the second time forum software has double posted, and I can't delete this 2nd post,
    other than to erase it.
    Sorry!

  24. #24
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Working With Different Monitor Resolutions

    Quote Originally Posted by mms_ View Post
    Does VB6 install painlessly on Windows10?
    Not entirely, but you can get it done. Here's a link I put together to cover most of the problems. There are also several other resources there to help you. Two tips: 1) For some reason, after installing (including the VB6 SP6), you have to manually register the msdatsrc.tlb TypeLib. This isn't always the case, but it's often the case. I've got no idea what causes this. And 2) do NOT use any of the compatibility settings on the VB6.EXE. You will need to learn about something called shims for things to work correctly. Those are also discussed in that thread.


    Quote Originally Posted by mms_ View Post
    Does VB6 work properly on Windows10?
    Yes, so long as you don't use any compatibility settings. The primary thing that's lost is the little handles for moving controls on a form when you've selected multiple controls (with the dashed selection box). Everything still works, including all the control formatting. You just don't get to clearly see what you've selected. At first, that was HUGELY annoying to me, but I've managed to get used to not having them. Now, I don't really miss them at all. Beyond that one annoyance, everything else in the VB6 IDE seems to work absolutely fine.


    Good Luck,
    Elroy

    EDIT1: Also, on the latest version of Windows 10, I'm now getting a strange totally shrunk form on my screen. It definitely has something to do with the VB6 IDE:

    Name:  phantom.png
Views: 884
Size:  870 Bytes

    If you minimize the IDE and then re-normalize it, it's gone. I've learned to just ignore it.
    Last edited by Elroy; Nov 12th, 2018 at 12:57 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  25. #25

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    Thank you Elroy.

  26. #26

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    Hello again,

    So I spent all week changing all my drawing code to use different scaling factors in X & Y directions.

    Testing on two different systems, with two different monitor setups, all works OK.
    Both systems show two 8-1/2" x 11" page previews with graphics drawn perfectly on these pages.

    I'm thinking I totally wasted my time however.


    After I completed this, it struck me to do a simple test in a clean VB6 project, and draw a square and a circle on Form1 like so:

    stat = GdipDrawRectangle(graphics, redPen, 20, 30, 200, 200)
    stat = GdipDrawEllipse(graphics, redPen, 300, 30, 200, 200)


    This draws a 200px square and a 200px diameter circle side by side.

    When this draws on my laptop screen a perfect square and a perfect circle are drawn on the form.
    When I drag that form onto my secondary display, the square becomes a rectangle, and the circle an ellipse.

    Wanting to draw to exact scale aside, this is unacceptable; a square should be square, and a circle should be round.

    Both my laptop, and secondary displays are set to 1920 x 1080 resolution (and are both Windows recommended settings).

    Am I missing something totally obvious here?

  27. #27
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Working With Different Monitor Resolutions

    Hi mms_,

    What you're asking is a bit of a tall order. Now, you said you "spent all week changing all my drawing code to use different scaling factors in X & Y directions". However, in your GdiPlus lines, you're not using any scaling factors. And, by scaling factor, I assume we're talking about a factor that adjusts things for the width of a pixel being different from the height of a pixel.

    Typically, when people have a problem somewhat similar to what you described, they build their program so that all the graphics can be drawn/redrawn with a single call. Anytime data changes they make that call. However, they may also make that call in the Form_Resize event, which allows them to correctly resize things.

    Now, when you move your form from one monitor to another, there's not a specific event that fires for that transition. However, the Form_Move event is certainly firing when you're moving your form. So, we've still got a solution. When you initially draw (first call of your draw event), store the hMonitor your form is on. Then, as it's moving, check for a change in the hMonitor value (possibly using my hMonitorForForm call). And, if it changes, call your procedure to redraw everything, using the correct scaling factors.

    If you just adamantly insist on a square being square, and a circle being a circle, I see no other way to get it done. Also, when the form is split between two monitors, that are different sizes and/or set on different resolutions, you're never going to get that situation perfect.

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  28. #28

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    Thanks Elroy,

    Yes I know no scaling applied, I just wanted to see what happened without scaling.

    I'm thinking perhaps I could have found a better way to accomplish the scaling, but its done, it works, so I'll leave it for now
    and continue with the problem at hand.

    The problem as I see it is that Windows wrongly recommends a resolution of 1920 x 1080 for my second monitor.
    My second monitor is 20.4" x 12.8" (a 16:10 native aspect ratio monitor not a FHD monitor)

    If I change my second monitor to 1680 x 1050 (a 16:10 aspect ratio) the problem goes away, and squares are rendered square,
    and circles rendered round on the second monitor.

    My laptop screen is 13.5" x 7.6" (an FHD aspect ratio size).
    Windows will render a square square, and a circle round on my laptop screen, without any scaling on this screen.

    So the problem as I see it arises when the two monitors have different aspect ratios.

    Steps I think need to be taken by my app:
    - determine aspect ratios of both monitors
    - if both the same, do nothing (ie don't apply any scaling factors to drawing code), graphics will be rendered correctly
    - if secondary monitor aspect ratio different than primary either:
    - apply scaling factor to any graphics to be displayed on second monitor
    - OR
    - report to user app recommends changing second monitor resolution to one having same aspect ratio as it's native resolution

    Make sense?

    (I know from one of your earlier answers, I won't be able to determine native resolutions (hence native aspect ratio)
    of either monitor until I upgrade to Windows 10)

  29. #29

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    So my methodology is just not doing as I want or thought it would.

    I have to tackle this issue anew.

    If anyone would give me suggestions as to how they would handle a two monitor setup, it would be appreciated.

    Or do I just let Windows do what it does, and put up with wrong aspect ratios of on screen renderings, and "fuzziness" of Forms on secondary monitor?

  30. #30

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    double post

  31. #31
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Working With Different Monitor Resolutions

    mms,

    I re-read your OP, but maybe it would be best if you outlined your objectives and platforms. Regarding platforms, can we assume Windows 10? Regarding objectives, are you trying to assure that a drawn square is square; are you trying to control the actual physical dimensions of drawings; are you wanting to eliminate font fuzz and/or image fuzz; are you trying to eliminate all fuzz regardless of DPI, scaling, and/or resolution (native or not)?

    All of these things would affect my approach, and an optimal way to solve the problems.

    For me, I demand that users stay at 96 DPI (i.e., 100%). (They can change the monitor resolution if they like, but I don't recommend it.) But, with Windows 10, they're allowed to use the scaling. Under those conditions, I can eliminate all fuzz except the slight amount for scaled images. Fonts work near perfectly. Now, to guarantee that a square is square, I believe I can accomplish that with some Windows 10 calls. However, to guarantee physical scaling, the only foolproof way I'd know to do that is to ask the user for the monitors' physical dimensions.

    So, as you see, there are several separate issues to be address, some more easily solvable than others. The most difficult would be to ask for everything in, say, a Windows 7 machine.

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  32. #32

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    Thank you Elroy

    Restating:

    platforms
    assume Windows 10? for now must be Windows 7 (as that's all I have)

    objectives
    assure that a drawn square is square? yes
    control the actual physical dimensions of drawings? not important (for now anyway)
    eliminate font fuzz and/or image fuzz? yes
    eliminate all fuzz regardless of DPI, scaling, and/or resolution (native or not)? yes

    I've attached small 13Kb project demonstrating my problems.
    On my home system (laptop + 2nd monitor) graphics on Form2 on 2nd monitor is misshapen and blurry.
    If I drag Form2 back to laptop monitor, everything is properly shaped and perfectly clear.
    Attached Files Attached Files

  33. #33
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Working With Different Monitor Resolutions

    mms,

    I'm certainly the wrong person to answer this. As stated above, I always run at 96 DPI. And furthermore, I strongly recommend running at native resolution. You shouldn't see any problems with those criteria.

    Therefore, if you don't mind, please outline how you're setting up each of the two monitors (DPI & Resolution). Also, please provide the native resolution of each of the two monitors.

    Personally, I'd think that Dilettante or LaVolpe would be the best to give you guidance for Windows 7 running at non-96 DPI and/or a resolution with a different aspect ratio than the native resolution. LaVolpe wrote an excellent tutorial about precisely these conditions.

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  34. #34

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    My home system consists of a Dell XPS Laptop with physical screen size of 13-1/2" x 7-5/8" (I don't know how/where to find specs for this laptop)
    hooked up to a 2nd Dell 2407WFP monitor.

    Per my monitor's owner's manual, the 2nd monitor has a physical screen size of 20.4" x 12.7" and the optimal resolution is 1920 x 1200 at 60 Hz

    I've not changed any settings on laptop, and use the recommended resolution for both laptop and 2nd monitor as suggested by Windows
    (1920 x 1080 for both displays)

    Regarding DPI settings, I understand what this is, but don't know where to go to find what the current settings are.
    (If you can direct me how to find this out, I will).

    I will continue to look for my laptop monitor specs.

  35. #35
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Working With Different Monitor Resolutions

    Ok, just from what you've provided, it's hard to believe that the recommended resolution for that 2nd monitor is 1920x1080, particularly since you've stated that it says the optimal resolution is 1920x1200. That's possibly a large part of the reason for your fuzz and your non-square squares. Set it to 1920x1200 if there's a setting for that, and see how that looks.

    If you don't know where your DPI is, I suspect it's set at 96. However, you can check it by right-clicking on your desktop, select "Screen Resolution", then select "Make text and other items larger or smaller", then select "Set Custom Text Size (DPI)". It reports as a percentage, but 100% = 96DPI. If it's set to anything else, that may be another source of fuzz, but it shouldn't affect a square not being square.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  36. #36

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    Thanks Elroy,

    1920 x 1200 is not available for 2nd monitor

    Custom DPI setting is set to default value of 125% (I never adjusted this)

    I was able to find info on my laptop display:
    15.6 FHD True Life
    7.62" x 13.55"
    Max resolution 1920 x 1080 at 60 Hz

  37. #37
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Working With Different Monitor Resolutions

    Ok mms, this may be a video card (i.e., video chipset) issue. Each video chipset has various resolutions it will support (and not support). If your particular video chipset for your laptop doesn't support 1920x1200, then you may have a problem. Also, different monitors handle non-native resolutions differently, depending on the monitor. Some monitors will just put black-space around the edges for resolutions with different aspect ratios. Others will "stretch" or "shrink" the actual pixels so that the entire screen is used. I suspect yours is doing the latter. (And just before I get called on it, the physical pixels aren't actually stretched/shrunk. Rather, more (or less) than one physical pixel is used for each logical pixel, often resulting in fractional pixels, which is basically blur.)

    Therefore, if your video chipset can't support 1920x1200, that is very likely your problem. You could "fix" it by developing a ratio out of 1200 vs 1080, and then using that ratio for your vertical graphing, but that's not something I'd do.

    Another option might be to use a resolution that is supported by your video chipset with the same aspect ratio as your monitor. Just so you know, this 2nd monitor's aspect ratio is 16/10 (or 1.6). Another resolution that's 16/10 is 960x600. You may want to check and see if that's an option. You would use 4 physical pixels for each logical pixel with that setting, but there would be no blur, and a square would be square.

    Good Luck,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  38. #38

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    OK thanks for trying to help Elroy.

    As for your first suggestion of trying to develop a ratio for all draws; that is the first thing I tried.
    I had a separate scaleX and scaleY factor and used in every draw call.
    There was a couple hundred draw calls to change and when all said and done, even though aspect problem
    was fixed, it caused other problems.
    I abandoned that approach (you said above you wouldn't have considered it anyway).

    I tried your second suggestion of trying other 16/10 resolutions for 2nd monitor; things just got worse.

    My current solution is drawing to a backbuffer with 1:1 pixel aspect ratio, and then just do one
    scaling of the entire bitmap to correct 2nd monitor aspect ratio.
    Since there is only one scaling operation, it was very easy to implement.
    This seems to work ok, but I notice that the scaled image is not as sharp as the unscaled image
    (GDI+ scaling of one pixel wide lines for example turn a little blury)

    Just curios if anyone tried my test app on another 2 monitor set-up, and if the squares and circles
    rendered as true squares and circles?
    Last edited by mms_; Dec 8th, 2018 at 06:13 PM.

  39. #39
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,995

    Re: Working With Different Monitor Resolutions

    Hello. I think that Elroy already said it all. I just want to emphasize that if you don't want any blurring, then you are required to run the monitor to its native resolution. Doing that you'll also solve the aspect ratio problem.
    Option 1: Change the laptop
    Option 2: change the monitor

    A third option would be to run it to an exact submultiple that in this case it could be 960x600, exactly the half, using four pixels per pixel. The laptop most probably doesn't have that strange resolution either.

  40. #40

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2018
    Posts
    602

    Re: Working With Different Monitor Resolutions

    OK thanks.

    I guess it comes down to secondary monitor must have exact same native resolution,
    or at least support a resolution of same aspect ratio as primary monitor.

    In my case, my home set-up does not, so I can never achieve the results I am after.

    A good lesson I guess, for the next time I'm making a purchase.

Page 1 of 2 12 LastLast

Posting Permissions

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



Click Here to Expand Forum to Full Width