|
Определение местоположение TaskBar |
|
|
Данный пример покажет местоположение панели
задач (там, где кнопка ПУСК :)))
Не забудьте расположите на форме элемент CommandButton. Private Declare Function FindWindow Lib "user32" Alias
"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As
Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect
As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Const tBarClass = "Shell_TrayWnd"
Dim tBarHwnd As Long
Dim tBarRect As RECT
Private Sub Command1_Click()
' узнать handle ТаскБара
tBarHwnd = FindWindow(tBarClass, "")
If tBarHwnd = 0 Then
MsgBox "Указанное окно не найдено!", 0
Else
' Окно найдено, идет определение местоположения
taskbar
GetWindowRect tBarHwnd, tBarRect
If tBarRect.Left = -2 And tBarRect.Top > -2 Then
' Taskbar внизу экрана
MsgBox "Taskbar is at the bottom of the screen.."
End If
If tBarRect.Left > -2 And tBarRect.Bottom = Screen.Height / Screen.TwipsPerPixelY + 2
Then
' Taskbar справа от экрана
MsgBox "Taskbar is aligned at the right of the screen.."
End If
If tBarRect.Bottom <> Screen.Height / Screen.TwipsPerPixelY + 2 And tBarRect.Right =
Screen.Width / Screen.TwipsPerPixelX + 2 Then
' Taskbar сверху экрана
MsgBox "Taskbar is at the top of the screen.."
End If
If tBarRect.Right <> Screen.Width / Screen.TwipsPerPixelX + 2 And tBarRect.Bottom =
Screen.Height / Screen.TwipsPerPixelY + 2 Then
' Taskbar слева от экрана
MsgBox "Taskbar is aligned at the left of the screen.."
End If
End If
End Sub
|
|
|
|
|
|
|