Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Show/hide taskbar in XP using VB.NET

Posted on 2011-02-24
12
Medium Priority
?
760 Views
Last Modified: 2012-05-11
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
Comment
Question by:jes12345
  • 4
  • 3
  • 2
  • +2
12 Comments
 
LVL 14

Expert Comment

by:quizwedge
ID: 34968861
0
 
LVL 13

Accepted Solution

by:
Rahul Agarwal earned 800 total points
ID: 34969236
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
 

Author Comment

by:jes12345
ID: 34969361
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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 14

Expert Comment

by:quizwedge
ID: 34969436
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
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 800 total points
ID: 34971178
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
 

Author Comment

by:jes12345
ID: 34977848
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
 
LVL 14

Assisted Solution

by:quizwedge
quizwedge earned 400 total points
ID: 34978563
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
 
LVL 12

Expert Comment

by:Mohamed Abowarda
ID: 34979142
0
 

Author Comment

by:jes12345
ID: 34998023
I have created the code based on agarwalrahul and quizwedge reply - however FindWindow is still not defined
0
 
LVL 86

Assisted Solution

by:Mike Tomlinson
Mike Tomlinson earned 800 total points
ID: 34998165
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
 

Author Closing Comment

by:jes12345
ID: 35001761
Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

963 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