Is the taskbar Visible?

Posted on 1999-07-06
Medium Priority
Last Modified: 2012-06-27
i am using this code to hide the taskbar

hwnd1 = FindWindow("Shell_traywnd", "")
Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)

i want to hide the taskbar while booting the system, the code here works, but windows trigger it back again.
i want to know if it is visible, so i could send the hiding code again, without using a timer to kill it every second.
Question by:pakos

Expert Comment

ID: 1522275
Create a new project in Visual Basic. Form1 is created by default.

Add the following Constant and Declare statements to the General Declarations section of Form1 (note that the Declare statement must be typed as a single line of code):
Private Declare Function SHAppBarMessage Lib "shell32.dll"
   (ByVal dwMessage As Long, pData As APPBARDATA) As Long

Add a Command Button control to Form1. Command1 is created by default.

Add the following code to the Click event for Command1.
Private Sub Command1_Click()
    Dim IsThere As Integer
    IsThere = BarExists()
    If IsThere = 0 Then
        Text1.Text = "TaskBar not in auto-hide or always-on-top mode"
    End If
    If IsThere = ABS_ALWAYSONTOP Then
        Text1.Text = "TaskBar always-on-top"
    End If
    If IsThere = ABS_AUTOHIDE Then
        Text1.Text = "TaskBar in auto-hide"
    End If
End Sub

Create a new function called BarExists. Add the following code to this function.
Function BarExists() As Integer
    Dim Bardata As APPBARDATA
    BarExists = SHAppBarMessage(ABM_GETSTATE, Bardata)
End Function

Add a Text Box control to Form1. Text1 is created by default. Set its MultiLine property to True.

Add a new module to the project. Module1.Bas is created by default.

Add the following TYPE structures to Module1.Bas:
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type
        cbSize As Long
        hwnd As Long
        uCallbackMessage As Long
        uEdge As Long
        rc As RECT
        lParam As Long '  message specific
End Type

LVL 13

Expert Comment

ID: 1522276

Author Comment

ID: 1522277
This isn't what i need, by using this code i kill the taskbar, no matter (autohide or always on top), try using my code, and add it to urs it doesn't give me the status of the taskbar.
and here's the code the show the taskbar again :
    hwnd1 = FindWindow("Shell_traywnd", "")
    Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)

Try adding my code to yours, and u will get the picture,
and thanx for ur concern

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Accepted Solution

setiawan earned 800 total points
ID: 1522278
Try this :
  dim ret, hwnd1 as long

  hwnd1 = FindWindow("Shell_traywnd", "")
  ret= IsWindowVisible ( hwnd1 )
  If ret=TRUE then
      Call SetWindowPos(hwnd1, 0, 0, 0, 0, 0,SWP_HIDEWINDOW
  End If
 Hope this can solve your problem, cya

ps : to declare IsWindowVisible
     Declare Function IsWindowVisible& Lib "user32" (ByVal hwnd As Long)  

Expert Comment

ID: 1522279
'scuse me guys, but I'd like to comment so's I can see this thread when answer is accepted (I'm collecting code snippets whilst I teach myself some API calls).  Hope you don't mind.

Author Comment

ID: 1522280
Thanx, u just saved my a.. :)

Author Comment

ID: 1522281
jaynee, u have a good knowledge in heritage buildings, what a coincidence,

Expert Comment

ID: 1522282
'sOK, pakos - it all went a bit pear-shaped for a bit there, didn't it?  You can reach me on greebie@hotmail.com for today only, if you need to.

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

619 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question