Video Settings
Get the current Video settings: Colors, Resolution and Pixels per Inch
Module
Option Explicit
Private Declare Function GetDeviceCaps Lib "gdi32.dll" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Private Const HORZRES = 8 ' Horizontal size in pixels
Private Const VERTRES = 10 ' Vertical size in pixels
Private Const BITSPIXEL = 12 ' Bits per Pixel
Private Const LOGPIXELSX = 88 ' Pixel/inch in X
Private Const LOGPIXELSY = 90 ' Pixel/inch in Y
Public Sub GetVideoCaps(hDC As Long, Colors As Long, XResolution As Long, YResolution As Long)
Dim i As Integer
Dim BitsPerPixel As Long
BitsPerPixel = GetDeviceCaps(hDC, BITSPIXEL)
Colors = 1
For i = 1 To BitsPerPixel
Colors = Colors * 2
Next
XResolution = GetDeviceCaps(hDC, HORZRES)
YResolution = GetDeviceCaps(hDC, VERTRES)
End Sub
Public Sub GetPixelsInch(hDC As Long, PX As Long, PY As Long)
PX = GetDeviceCaps(hDC, LOGPIXELSX)
PY = GetDeviceCaps(hDC, LOGPIXELSY)
End Sub
Usage
Private Sub Form_Load()
Dim c As Long
Dim x As Long
Dim y As Long
GetVideoCaps Form1.hDC, c, x, y
MsgBox x & "x" & y & " - " & c & " colors"
GetPixelsInch Form1.hDC, x, y
MsgBox x & " Pixels/Inch in X" & vbCrLf & y & " Pixels/Inch in Y"
End Sub
Special Instructions
This code originally appeared on AndreaVB.com, and has been republished here with the permission of Andrea Tincani.
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.