Results 1 to 6 of 6

Thread: TaskBar; Real time Hidden or Not

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Why not just turn the task bar off completely?
    VB Code:
    1. Private Const SWP_HIDEWINDOW = &H80
    2. Private Const SWP_SHOWWINDOW = &H40
    3.  
    4. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    5. Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    6.  
    7. Private Sub Form_Load()
    8. 'make it go away
    9. Dim Thwnd As Long
    10. Thwnd = FindWindow("Shell_traywnd", "")
    11. Call SetWindowPos(Thwnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)
    12. End Sub
    13.  
    14. Private Sub Form_Unload(Cancel As Integer)
    15. 'make it come back
    16. Dim Thwnd As Long
    17. Thwnd = FindWindow("Shell_traywnd", "")
    18. Call SetWindowPos(Thwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
    19. End Sub

  2. #2
    Red Rush-In
    Guest
    Thank you for your quick response. The problem is that it needs to float above the task bar not just sit at the bottom right of the screen. Taking away the task bar would not be the way to go for my app.

  3. #3

    Thread Starter
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Have you tried searching on this topic? It seems to me that I remember a post a couple of months ago that asked about this same issue.

  4. #4
    Red Rush-In
    Guest
    There have been numerouse questions asked about the height of
    the taskbar. But my problem is slightly different.

    If I use either SystemParametersInfo or SHAppBarMessage the
    task bar height is always going to be the same. My resolution is
    set to 1024 x 768. I derive the taskbar height from the rect type
    that those functions return. Now here is the catch; They will
    always return the same top value regardless if the taskbar is
    currently hidden or not
    . In my case it always returns 715.

    This is how the app needs to perform for someone who has auto
    hide enabled:
    The task bar is visible: The 715 value is no problem here
    and the app sits on top of the taskbar.
    The user moves thier mouse to the top of the screen and the
    taskbar hides itself:
    now if I was to use the 715 value that is
    always returned there would be a gap between the form and the
    bottom of the screen.
    The application needs to know if the taskbar is hidden at that
    moment

    Ok, actually SystemParametersInfo returns the entire screen
    coordinates if the taskbar is set to AutoHide. But again it is
    always the same value regardless of wether the taskBar is visible
    or not.

  5. #5
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Try GetWindowRect
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  6. #6
    Red Rush-In
    Guest
    Thank You! I Got it to work using SHAppBarMessage and GetWindowRect.

    Here is the code for the module if anyone else needs it or is just
    curiouse

    VB Code:
    1. Option Explicit
    2.  
    3. Public Type RECT
    4.     Left As Long
    5.     Top As Long
    6.     Right As Long
    7.     Bottom As Long
    8. End Type
    9.  
    10. Public Type APPBARDATA
    11.     cbSize As Long
    12.     hwnd As Long
    13.     uCallbackMessage As Long
    14.     uEdge As Long
    15.     rc As RECT
    16.     lParam As Long
    17. End Type
    18.  
    19. Public Const ABM_GETSTATE = &H4
    20. Public Const ABM_GETAUTOHIDEBAR = &H7
    21. Public Const ABM_GETTASKBARPOS = &H5
    22. Public Const ABS_ALWAYSONTOP = &H2
    23. Public Const ABE_LEFT = 0
    24. Public Const ABE_TOP = 1
    25. Public Const ABE_RIGHT = 2
    26. Public Const ABE_BOTTOM = 3
    27.  
    28. Public Declare Function SHAppBarMessage Lib "shell32.dll" _
    29.     (ByVal dwMessage As Long, _
    30.     pData As APPBARDATA) As Long
    31.  
    32. Public Declare Function GetWindowRect Lib "user32" _
    33.     (ByVal hwnd As Long, _
    34.     lpRect As RECT) As Long
    35.  
    36. Public Function GetTaskBarRect() As RECT
    37.     Dim state As Long
    38.     Dim position As Integer, hWndAppBar As Long
    39.     Dim myrect As RECT
    40.     Dim ABD As APPBARDATA
    41.  
    42.     ABD.cbSize = Len(ABD)
    43.    
    44.     state = SHAppBarMessage(ABM_GETSTATE, ABD)
    45.    
    46.     If (state = False) Or (state = ABS_ALWAYSONTOP) Then
    47.         'TaskBar is not set to auto hide
    48.         'so no extra work needs to be done
    49.         SHAppBarMessage ABM_GETTASKBARPOS, ABD
    50.         GetTaskBarRect = ABD.rc
    51.     Else
    52.         'TaskBar is set to auto hide
    53.         'Find location
    54.        
    55.         For position = ABE_LEFT To ABE_BOTTOM
    56.            
    57.             ABD.uEdge = position
    58.             hWndAppBar = SHAppBarMessage(ABM_GETAUTOHIDEBAR, ABD)
    59.        
    60.             If hWndAppBar > 0 Then
    61.                 'Location found
    62.                 'Now get Rect for its current position
    63.                 'Thank You PsychoMark !!!
    64.                 GetWindowRect hWndAppBar, myrect
    65.                 GetTaskBarRect = myrect
    66.                 Exit For
    67.             End If
    68.        
    69.         Next position
    70.     End If
    71.        
    72. End Function

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