I have this code to determine the height of the task bar
Code:
Dim lRes As Long
Dim rectVal As RECT
Dim TaskbarLoc As String
TaskbarLoc = GetTaskBarLoc
lRes = SystemParametersInfo(SPI_GETWORKAREA, 0, rectVal, 0)
GetTaskbarHeight = ((Screen.Height / Screen.TwipsPerPixelX) - rectVal.Bottom) * Screen.TwipsPerPixelX
it works fine... but when the task bar is on the right or left of the screen it returns 0 as the height.. what would I have to change to determine the "width" of the taskbar when it is docked to the left or right of the screen?
yeah the code i have will return either left,right,top, or bottom.. depending on where the taskbar is...
I am making an app that is like a menu bar.. it is going to be dockable either on the top or bottom of the screen or free floating.. but when docking to the top or bottom.. I need to take into account that the taskbar could be on the left or right side... and size my bar accordingly
Ah...this one. Your program sounds very cool, and I'd like to check it out when you are done.
Butl, as far as your question concerning my Code Library and its little bag of dirty tricks, the answer is no. I've never been in a situation where I had to deal with the task bar located anywhere except at the bottom of the screen. However comma there are a boatload of web sites out there with code ripe for the picking, so let me see what I can see.
thanks.. i am also looking for possible ways to detect user interaction with the taskbar.. as in.. lets say i get it docked to the bottom and everything is sized fine.. and then the user moves it to the left side.. or just resizes the taskbar in its current position. is there a way to capture these events so I can resize accordigly?
I found a code sample that is really cool and does what i need it to do.. it acts just like the taskbar.. so no worries about resizing and dealing with user interaction with the taskbar.. but also allows to be a free floating from...
Originally posted by Lord_Rat Could I have the top left right bottom code?
I have a program where I am displaying a notification near the system clock and would love to be able to tell where the clock actually is.
in a command button.. or whatever event
Code:
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()
' Attempt to get the handle to the taskbar
tBarHwnd = FindWindow(tBarClass, "")
If tBarHwnd = 0 Then
' Failed to find window
MsgBox "Window Not Found !", 0, "Unable to retrieve hWnd"
Else
' Window was found
' Get the location of the taskbar
GetWindowRect tBarHwnd, tBarRect
If tBarRect.Left = -2 And tBarRect.Top > -2 Then
' Taskbar is located at the bottom of the screen
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 is at the right hand edge of the screen
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 is at the top of the screen
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 is located at the left of the screen
MsgBox "Taskbar is aligned at the left of the screen.."
End If
End If
End Sub