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: 472
  • Last Modified:

How to set TaskBars auto hide property ?

Hi experts
How to hide task bar and how to set auto hide property
progrmmily
0
pramod_kumar_tk
Asked:
pramod_kumar_tk
  • 17
  • 10
  • 4
  • +2
1 Solution
 
TimCotteeCommented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
pramod_kumar_tkAuthor Commented:
Hi Experts
I not checked the code. I will comment later
thanx
pramod kumar
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Richie_SimonettiIT OperationsCommented:
oops!, sorry Tim, my code looks similar to yours! :o
0
 
TimCotteeCommented:
Well Richie, when you have one solution, any differences are only going to be in style rather than substance!
0
 
pramod_kumar_tkAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
Dim BarExists As as long
0
 
Richie_SimonettiIT OperationsCommented:
0
 
pramod_kumar_tkAuthor Commented:
Hi Richie,
But it is not working. Plz, tell me any other methode to make TaskBar Auto hide ?
0
 
Richie_SimonettiIT OperationsCommented:
I did a search and not found something different to already tried.
All examples uses codes from Tim or mine.
0
 
pramod_kumar_tkAuthor Commented:
What r u saying ????
U r code is for hiding TaskBar
My question How to Set AutoHide property ?
plz , help me
0
 
Richie_SimonettiIT OperationsCommented:
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
 
Richie_SimonettiIT OperationsCommented:
As its designer saids, this is a program that manage that (i hope):
http://home.nordnet.fr/~pmdevigne/Logiciels/ActiveTache/TaskBarActivate.zip
0
 
Richie_SimonettiIT OperationsCommented:
Well, at least i think i found it:

http://guille.costasol.net/utilidades/taskbar.htm
0
 
pramod_kumar_tkAuthor Commented:
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
 
TimCotteeCommented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
TimCotteeCommented:
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
 
Richie_SimonettiIT OperationsCommented:
"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
 
pramod_kumar_tkAuthor Commented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
pramod_kumar_tkAuthor Commented:
Hi Richie
What about unregister the current taskbar and create the same with same property ? is't possible ?
0
 
Richie_SimonettiIT OperationsCommented:
I am not sure, but as i said before, to me, it's a dangerous "toy".
0
 
Richie_SimonettiIT OperationsCommented:
And, maybe i am wrong, but i think that doesn't hide taskbar automatically, maybe on next boot.
0
 
pramod_kumar_tkAuthor Commented:
Do u know how to all this ?
Next boot it is not a problem for my  project
plz, help me
0
 
Richie_SimonettiIT OperationsCommented:
well, i must to do a research since i could end without my own taskbar (:0
0
 
pramod_kumar_tkAuthor Commented:
well
I am waiting !!!!!!!!!!!!!!!!!!!
0
 
Richie_SimonettiIT OperationsCommented:
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
 
pramod_kumar_tkAuthor Commented:
Hi Richie
Haha !!! It is good idea to sendkey to that property window
0
 
Richie_SimonettiIT OperationsCommented:
Yeah! since i don't trust on appactivate method when we work with dialog windows, i used tose api calls.
0
 
DanRollinsCommented:
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
 
NetminderCommented:
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

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