Declare PtrSafe Function GetDesktopWindow Lib "user32" () As LongPtr
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Declare PtrSafe Function GetWindowRect Lib "user32" (ByVal hwnd As LongPtr, lpRect As Rect) As Long
Declare PtrSafe Function GetDeviceCaps Lib "gdi32" (ByVal hdc As LongPtr, ByVal nIndex As Long) As Long
Declare PtrSafe Function GetDC Lib "user32" (ByVal hwnd As LongPtr) As LongPtr
Type Rect: Left As Long: Top As Long: Right As Long: Bottom As Long: End Type
Type donne: HeightTaskBar As Long: WidthTaskbar As Long: ScreenHeight As Long: ScreenWidth As Long: PointToPixel As Double: End Type
Function dimWindow() As donne
Dim R1 As Rect, R2 As Rect, M As donne
PtPx = GetDeviceCaps(GetDC(0), 88): PtPx = 1 / (PtPx / 72)
HwnDTaskB = FindWindow("Shell_TrayWnd", vbNullString)
HwnDDescktop = GetDesktopWindow
GetWindowRect HwnDDescktop, R1: GetWindowRect HwnDTaskB, R2
M.ScreenWidth = R1.Right: M.ScreenHeight = R1.Bottom: M.HeightTaskBar = (R2.Bottom - R2.Top): M.WidthTaskbar = R2.Right: M.PointToPixel = PtPx
dimWindow = M
End Function
Sub test()
Dim mesure As donne
mesure = dimWindow
MsgBox mesure.ScreenWidth & " x " & mesure.ScreenHeight
MsgBox "Hauteur barre des taches : " & mesure.HeightTaskBar & " pixel"
MsgBox "Largeur barre des taches : " & mesure.WidthTaskbar & " pixel "
MsgBox " coefficient point to pixel : " & mesure.PointToPixel
End Sub