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 56 57 58 59 60 61
|
Public Type TaskBarInformation
Left As Long 'Position par rapport au bord gauche de l'écran
Top As Long 'Position par rapport au haut de l'écran
Width As Long 'Largeur
Height As Long 'Hauteur
Position As tbPosition
End Type
Public Enum tbPosition
tbBottom = 3
tbLeft = 4
tbRight = 2
tbTop = 1
End Enum
Public Function GetTaskBarInformation() As TaskBarInformation
Dim rctTemp As tRect
Dim tskTemp As TaskBarInformation
Dim intI As Integer, intJ As Integer
Dim hwnd As Long
With Screen
intI = .Width \ (.TwipsPerPixelX * 2)
intJ = .Height \ (.TwipsPerPixelY * 2)
End With
' Récupère le handle de la barre des taches
hwnd = FindWindow("Shell_traywnd", vbNullString)
'Récupère le rectangle de la barre des taches
GetWindowRect hwnd, rctTemp
'Calcule les dimensions
With tskTemp
.Left = rctTemp.Left
.Top = rctTemp.Top
.Width = rctTemp.Right - rctTemp.Left
.Height = rctTemp.Bottom - rctTemp.Top
If .Top > intJ Then
.Position = tbBottom ' Bottom
ElseIf .Left > intI Then
.Position = tbRight ' Right
ElseIf .Top < intJ Then
.Position = tbTop ' Top
Else
.Position = tbLeft ' Left
End If
End With
GetTaskBarInformation = tskTemp
End Function |
Partager