1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Const ENUM_CURRENT_SETTINGS As Long = -1&
Const CCDEVICENAME = 32
Const CCFORMNAME = 32
Private Type DEVMODE
dmDeviceName As String * CCDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
Private Declare Function CopyRect Lib "user32" (lpDestRect As RECT, lpSourceRect As RECT) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim DevM As DEVMODE, rectWindow As RECT, rectCopy As RECT, monhwnd As Long
Call EnumDisplaySettings(0&, ENUM_CURRENT_SETTINGS, DevM)
monhwnd = FindWindow(vbNullString, Me.Caption)
GetWindowRect monhwnd, rectWindow
CopyRect rectCopy, rectWindow
MsgBox "largeur de l'userform:" + Str$(rectCopy.Right - rectCopy.Left) + " pixels" & vbCrLf & _
"hauteur de l'userform:" + Str$(rectCopy.Bottom - rectCopy.Top) + " pixels" & vbCrLf & _
"SANS LES BORDURES" & vbCrLf & "Quant à ton écran, il mesure " & DevM.dmPelsWidth & " pixels (de large)=" & " par " & DevM.dmPelsHeight & " pixels (de haut)"
End Sub |
Partager