Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 772
  • Last Modified:

Show/hide taskbar in XP using VB.NET

I want to create a small system tray icon app that toggle show/hide taskbar in XP. I.e if the taskbar is dispalyed normally clicking the tray will make the taskbare hide automatically (as can be manually selected under properties). If the taskbar is in the hide mode and you click the icon again it will go into always-show mode.
0
jes12345
Asked:
jes12345
  • 4
  • 3
  • 2
  • +2
4 Solutions
 
Rahul AgarwalTeam LeaderCommented:
Use Code:

Private Declare Function FindWindowEx Lib "user32" _
    Alias "FindWindowExA" (ByVal hWnd1 As Long, _
    ByVal hWnd2 As Long, _
    ByVal lpsz1 As String, _
    ByVal lpsz2 As String) As Long

Sub TaskBar(blnValue As Boolean)
    Dim lngHandle As Long
    Dim lngStartButton As Long

    lngHandle = FindWindow("Shell_TrayWnd", "")
   
    If blnValue Then
        ShowWindow lngHandle, 5
    Else
        ShowWindow lngHandle, 0
    End If
End Sub

Private Sub Cmdhide_Click()
Dim A As Boolean
A = False
TaskBar (A)
End Sub

Private Sub Cmdunhide_Click()
Dim A As Boolean
A = True
TaskBar (A)
End Sub
0
 
jes12345Author Commented:
quizwedge: I did see that solution but I did not get a working code from studying it.

agarwalrahul:The methods FindWindow and ShowWindow is not defined..
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
quizwedgeCommented:
What error(s) were you getting with the solution in the link? Not sure how long your code is, but perhaps you could post what you have that's applicable.
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
For VB.Net you need to change all the "Long" to "Integer" (or IntPtr if applicable).

*Declarations with "Long" are usually for the older VB6...
0
 
jes12345Author Commented:
I did not get a working example from the suggested url since the posts only had fragments of code. If anyone can please post a working sample they will be given the 500 points. Thanks.
0
 
quizwedgeCommented:
First, you need to have the following above your class declaration

Imports System.Runtime.InteropServices

Open in new window


Then, within your class you have to have

<DllImport("User32")> Private Shared Function ShowWindow(ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer
    End Function

Open in new window


You should then be able to hide the current window with the following command
ShowWindow(Me.Handle.ToInt32, 0) '0 = Hide

Open in new window


You should also be able to show the current window with the following command
ShowWindow(Me.Handle.ToInt32, 9) '9 = Restore

Open in new window




0
 
Mohamed AbowardaSoftware EngineerCommented:
0
 
jes12345Author Commented:
I have created the code based on agarwalrahul and quizwedge reply - however FindWindow is still not defined
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Use:

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer

Or:

    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
0
 
jes12345Author Commented:
Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

  • 4
  • 3
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now