Results 1 to 4 of 4

Thread: Auto hiding Taskbar through VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 1999
    Posts
    2

    Red face

    What is the procedure of Auto hiding Taskbar through VB Programming

  2. #2
    Guest
    I don't think there is a way put on Auto Hide, at least not that I know of. I searched the Registry, can't seem to find it, search INI files, can't find it there either (unless I'm not a good searcher).

    But you can hide and show the taskbar:

    Code:
    Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" (ByVal lpClassName As String, ByVal _
    lpWindowName As String) As Long
    
    Private Declare Function ShowWindow Lib "user32" _
    Alias "ShowWindow" (ByVal hwnd As Long, ByVal nCmdShow As _
    Long) As Long
    
    Private Const SW_HIDE = 0
    Private Const SW_SHOW = 5
    
    Dim tray&
    Dim shtray&
    
    Private Sub Command1_Click()
    'Hide
    tray& = FindWindow("Shell_TrayWnd", vbNullString)
    shtray& = ShowWindow(tray&, SW_HIDE)
    End Sub
    
    Private Sub Command2_Click()
    'Show
    tray& = FindWindow("Shell_TrayWnd", vbNullString)
    shtray& = ShowWindow(tray&, SW_SHOW)
    End Sub

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Well, it should be possible with the SHAppbarmessage, but I just can't get it to work

    Code:
    Option Explicit
    
    Const ABS_AUTOHIDE = &H1
    Const ABS_ONTOP = &H2
    Const ABM_GETSTATE = &H4
    Const ABM_GETTASKBARPOS = &H5
    Const ABM_SETAUTOHIDEBAR = &H8
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    Private Type APPBARDATA
        cbSize As Long
        hwnd As Long
        uCallbackMessage As Long
        uEdge As Long
        rc As RECT
        lParam As Long '  message specific
    End Type
    Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
    Private Sub Form_Paint()
        Dim ABD As APPBARDATA, Ret As Long
            ABD.cbSize = Len(ABD)
            ABD.hwnd = Me.hwnd
            ABD.lParam = ABS_AUTOHIDE
            ABD.uCallbackMessage = ABS_AUTOHIDE
            
            SHAppBarMessage ABM_SETAUTOHIDEBAR, ABD
            
                Ret = SHAppBarMessage(ABM_GETSTATE, ABD)
        If (Ret And ABS_AUTOHIDE) Then Me.Print "Autohide option is on"
    End Sub
    It should be possible so good luck, and be sure to lemme know when you got it to work
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Here another alternative way to do it.

    Code:
    'Put this code into a basic module file
    Option Explicit
    Dim handleW1 As Long
    Public Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Public Declare Function SetWindowPos Lib "user32" (ByVal handleW1 As Long, ByVal handleW1InsertWhere As Long, ByVal w As Long, ByVal x As Long, ByVal y As Long, ByVal z As Long, ByVal wFlags As Long) As Long
    
    Const TOGGLE_HIDEWINDOW = &H80
    Const TOGGLE_UNHIDEWINDOW = &H40
    
    Public Function HideTaskbar()
        handleW1 = FindWindowA("Shell_traywnd", "")
        Call SetWindowPos(handleW1, 0, 0, 0, 0, 0, TOGGLE_HIDEWINDOW)
    End Function
    
    Public Function UnhideTaskbar()
        Call SetWindowPos(handleW1, 0, 0, 0, 0, 0, TOGGLE_UNHIDEWINDOW)
    End Function
    Code:
    'Put this code into a form
    Private Sub CmdAction_Click()
    If CmdAction.Caption = "Hide" Then
        HideTaskbar
        CmdAction.Caption = "UnHide"
    Else
        UnhideTaskbar
        CmdAction.Caption = "Hide"
    End If
    Cheers!

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