Solved

How to set TaskBars auto hide property ?

Posted on 2001-09-13
33
445 Views
Last Modified: 2013-11-23
Hi experts
How to hide task bar and how to set auto hide property
progrmmily
0
Comment
Question by:pramod_kumar_tk
  • 17
  • 10
  • 4
  • +2
33 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 6479170
This code hides the taskbar when the form loads and shows it when it unloads, it is a quick hack of a routine to hide/show the start button so can be neatened up a bit.

Const SWP_HIDEWINDOW = &H80
Const SWP_SHOWWINDOW = &H40
Const GW_CHILD = 5
Const GW_HWNDNEXT = 2
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
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Dim tWnd As Long, bWnd As Long, sSave As String * 250
Private Sub Form_Load()
    'KPD-Team 1999
    'URL: http://www.allapi.net/
    'E-Mail: KPDTeam@Allapi.net

    'This code will hide the Start-button
    'Find the taskbar's handle
    tWnd = FindWindow("Shell_traywnd", vbNullString)
    'Search for a child window
    bWnd = tWnd 'GetWindow(tWnd, GW_CHILD)
'    Do
'        'get the child window's classname
'        GetClassName bWnd, sSave, 250
'        'We have the handle of the Start button If the classname is 'button'
'        If LCase(Left$(sSave, 6)) = "button" Then Exit Do
'        'Search the next child
'        bWnd = GetWindow(bWnd, GW_HWNDNEXT)
'    Loop
'    'Hide the start button
    SetWindowPos bWnd, 0, 0, 0, 0, 0, SWP_HIDEWINDOW
End Sub
Private Sub Form_Unload(Cancel As Integer)
    'Show the start button
    SetWindowPos bWnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW
End Sub
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 25 total points
ID: 6480555
Maybe:



Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_HIDE = 0
Private Const SW_NORMAL = 1
Dim ret As Long

Private Sub Form_Click()
If ret <> 0 Then
    ShowWindow ret, SW_NORMAL
End If
End Sub

Private Sub Form_Load()

ret = FindWindow("Shell_TrayWnd", vbNullString)
If ret <> 0 Then
    ShowWindow ret, SW_HIDE
End If
End Sub


0
 

Author Comment

by:pramod_kumar_tk
ID: 6481553
Hi Experts
I not checked the code. I will comment later
thanx
pramod kumar
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6482557
oops!, sorry Tim, my code looks similar to yours! :o
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6482564
Well Richie, when you have one solution, any differences are only going to be in style rather than substance!
0
 

Author Comment

by:pramod_kumar_tk
ID: 6483218
Hi Both
Both of ur codes r working OK, for hiding the TaskBar
but , what about to set auto hide property ?
What the wrong with following code ????
Dim pwnd As Long, rtn As Long
     
    Dim abd As APPBARDATA
    Dim BarExists As Integer
    Dim uEdge As Long
    pwnd = FindWindow("Shell_TrayWnd", vbNullString)
   
    If Me.Check1.Value = 1 Then
        abd.cbSize = Len(abd)
        abd.hwnd = pwnd
        abd.uEdge = ABE_RIGHT
        BarExists = SHAppBarMessage(ABM_GETAUTOHIDEBAR, abd)
        If BarExists = 0 Then
            abd.lParam = True
            BarExists = SHAppBarMessage(ABM_SETAUTOHIDEBAR, abd)
        End If
    Else
        abd.cbSize = Len(abd)
        abd.hwnd = pwnd
        abd.uEdge = ABE_RIGHT
        BarExists = SHAppBarMessage(ABM_GETAUTOHIDEBAR, abd)
        If BarExists = pwnd Then
            abd.lParam = False
            BarExists = SHAppBarMessage(ABM_SETAUTOHIDEBAR, abd)
        End If
   End If
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6483559
Dim BarExists As as long
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6483708
0
 

Author Comment

by:pramod_kumar_tk
ID: 6484190
Hi Richie,
But it is not working. Plz, tell me any other methode to make TaskBar Auto hide ?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6484295
I did a search and not found something different to already tried.
All examples uses codes from Tim or mine.
0
 

Author Comment

by:pramod_kumar_tk
ID: 6484340
What r u saying ????
U r code is for hiding TaskBar
My question How to Set AutoHide property ?
plz , help me
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6485383
Is what i said!
There is code to hide taskbar all around the net but i not found code using property Autohide.

I found only a "close" related stuff:
http://support.microsoft.com/directory/article.asp?ID=KB;EN-US;q197585
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6485390
As its designer saids, this is a program that manage that (i hope):
http://home.nordnet.fr/~pmdevigne/Logiciels/ActiveTache/TaskBarActivate.zip
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6485397
Well, at least i think i found it:

http://guille.costasol.net/utilidades/taskbar.htm
0
 

Author Comment

by:pramod_kumar_tk
ID: 6486460
Hi Richie,
Thanx for u comment. I mis understud what u said. sorry
But One link is other than english. I don't know that laguage
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6486919
Richie, the French one is probably not what is required, I think that all this app does is hook the mouse movement and hide / show the taskbar itself rather than giving any idea of how to actually set the autohide property of the taskbar. I did have a play with this myself and didn't quite get it to work. All the calls returned success but it didn't set the property properly. The example class in the second link didn't work for me either. Whether this is because I am running NT or not I don't know. I have to admit to being dubious as to whether this is truly possible as having read through the appropriate API calls etc, it appears that in order to be able to do this properly you have to remove the existing taskbar and create a new one in order to register it as autohide. I don't think that you can do it by simply attempting to change that part of the structure. I could be wrong but that is the way it looks at the moment.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6487411
pramod_kumar_tk:
Well, i can read spanish and after doing a research of ctaskbar class from elguille only can tell you that it is not (again) what we need.

Tim:
I just put that link without any hope, just to see if it can help.
My link to MSDN article explains that this task is not possible in the way we need. There is a workaround in the article, too.
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6487487
I read French but not spanish so between us we have it covered. I agree that the MSDN article really answers the question, but not why. I think as I said before that the reason is that it can only be done when you initially register an appbar to an edge of the desktop. Windows itself can handle it because it knows the contents and attributes of the appbar and can destroy and re-create it at will. It may be a substantial (if possible) task to gather all of this information and properly unregister the existing appbar before creating a new one with the same properties with a different autohide value. At least this is my experience having tried to achieve this over the last few days.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6487653
"I read French but not spanish so between us we have it covered. I agree that the MSDN article really
answers the question, but not why. ...."
I agree with you, Tim, that's a BIG WHY.
0
 

Author Comment

by:pramod_kumar_tk
ID: 6492416
Hi Tim & Richie
It is interesting. then u both have some interest on this matter.
so the class cTaskBar doesn't do anything other than we know, which is a vain.
If it is possible to unregister the current taskbar and create the same with same property and then set auto hide property ? That u are saying ?
any way i want ot set autohide property ?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6492447
Humm...dangerous thing, i think. If something goes wrong, we could lost it.
I did try with this APIs without result.
SetWindowPos
MoveWindow
ShowWindow
SendMessage
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6499839
So, where we are?
Here is an extract from a link inside microsoft article (http://support.microsoft.com/directory/article.asp?ID=kb;en-us;Q179363)

"....
A taskbar automatically hides itself if a program sizes itself to cover the entire screen.

There is no programmatic way to change the Auto-Hide option (that is left up to the user by design), but if a program takes over the entire screen then it will automatically cover the taskbar.
......."

Cheers
0
 

Author Comment

by:pramod_kumar_tk
ID: 6504386
Hi Richie
What about unregister the current taskbar and create the same with same property ? is't possible ?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6504507
I am not sure, but as i said before, to me, it's a dangerous "toy".
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6504511
And, maybe i am wrong, but i think that doesn't hide taskbar automatically, maybe on next boot.
0
 

Author Comment

by:pramod_kumar_tk
ID: 6507799
Do u know how to all this ?
Next boot it is not a problem for my  project
plz, help me
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6509886
well, i must to do a research since i could end without my own taskbar (:0
0
 

Author Comment

by:pramod_kumar_tk
ID: 6511711
well
I am waiting !!!!!!!!!!!!!!!!!!!
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6513943
I don't know if it would like you but i can't get any better. Sorry:
'Set a reference to shdoc401.dll

Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function BringWindowToTop Lib "user32" (ByVal hwnd As Long) As Long

Sub WindowOnTop(WindowCaption As String)
Dim ret As Long
ret = FindWindow(vbNullString, WindowCaption)
If ret <> 0 Then
    BringWindowToTop ret
End If
End Sub

Private Sub Form_Click()
Dim oShell As Shell32.Shell
Set oShell = New Shell32.Shell
oShell.TrayProperties
WindowOnTop "Propiedades de Barra de tareas" ' replace this with yours
SendKeys "%o"   ' replace this with yours
SendKeys "{ENTER}"

End Sub
0
 

Author Comment

by:pramod_kumar_tk
ID: 6514501
Hi Richie
Haha !!! It is good idea to sendkey to that property window
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6515513
Yeah! since i don't trust on appactivate method when we work with dialog windows, i used tose api calls.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7208353
Hi pramod_kumar_tk,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Split points between: TimCottee and Richie_Simonetti

pramod_kumar_tk, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
LVL 5

Expert Comment

by:Netminder
ID: 7241184
Per recommendation, force-accepted.

Netminder
CS Moderator

TimCottee: points for you at http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_20341062.html
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now