Announcement

Collapse
No announcement yet.

Computers DPI setting?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Computers DPI setting?

    Hi,

    Anyone know how to get a computers DPI setting? It looks like it should
    be 96 or 120. I have mine set at 120 with 1024 x 768 res. and it is very
    easy to read text. Causes me problems with bitmaps in my code, so I
    have to created a smaller size bitmap to install on other computers.

    Thanks,

    Brent

  • #2
    Hey Brent,
    they old GetDeviceCaps trick should do...

    Code:
    #COMPILE EXE '#Win 8.04#
    #DIM ALL
    #INCLUDE "WIN32API.INC" '#2005-01-27#
    '______________________________________________________________________________
     
    FUNCTION PBMAIN () AS LONG
     LOCAL hDC  AS DWORD
     LOCAL dpiY AS LONG
     LOCAL dpiX AS LONG
     
     hDC  = GetDc(%HWND_DESKTOP)
     dpiX = GetDeviceCaps(hDC, %LOGPIXELSX) 'Thank to Börje Hagsten
     dpiY = GetDeviceCaps(hDC, %LOGPIXELSY)
     ReleaseDc %HWND_DESKTOP, hDC
     
     MessageBox %HWND_DESKTOP, _
                "Dot Per Inch horizontally is" & STR$(dpiX) & $CRLF & _
                "Dot Per Inch vertically is"   & STR$(dpiY), _
                "Screen DPI", %MB_ICONINFORMATION OR %MB_OK
     
     MsgBox "Dot Per Inch : " +  STR$(dpiY) & $CRLF &  $CRLF & _
            "Font: " +  STR$(dpiY / 96 * 100) + "% of normal size"
     
    END FUNCTION
    '______________________________________________________________________________

    Comment


    • #3
      Pierre,

      Very nice - this will help alot. Thank you!
      I use a trial and error magic number to change bitmap size created
      with DPI set at 120. 76% x Width and 81% x Height of bitmap made in
      1024 x 768 res. Can't make sense of the numbers to create formula.
      Just know that resizing bitmap this way will work on other computers
      res. 800 x 600 and 1280 x 800. Must be to do with font size?

      Thanks Again,

      Brent

      Comment

      Working...
      X