Results 1 to 13 of 13

Thread: Taskbar Height/width

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Taskbar Height/width

    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?

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Thanks go to Mc Brain for this code:

    Dim IsVertical As Boolean

    Dim IsHorizontal As Boolean



    IsVertical = (Screen.Width - SysInfo1.WorkAreaWidth)

    IsHorizontal = (Screen.Height - SysInfo1.WorkAreaHeight)

    You have to have the sysinfo reference
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    i already have code that determines "where" it is docked... but when it is docked left or right i need to get its width

  4. #4

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    anyone?

  5. #5
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Yes, but:

    (Screen.Width - SysInfo1.WorkAreaWidth)

    Does get the width
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  6. #6
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Speaking of which, though,

    The code you have. Does it tell you which side of the screen the bar is one (left vs right for example)
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  7. #7

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    is there a way to use API to get the sysinfo information? I can't add another DLL to the application

  8. #8

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    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

  9. #9
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    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.

  10. #10
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    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.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  11. #11

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    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?

  12. #12

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    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...

    attached is the code
    Attached Files Attached Files

  13. #13

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width