| :: Get the current Video settings: Colors, Resolution and Pixels per Inch |
Author |
Andrea Tincani |
Language |
VB5, VB6 |
Operating
Systems |
Windows 95, 98 and NT |
| API
Declarations |
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 |
| Module |
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 |
'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 |
|
 |
|
 |