Hide and Show the Start Button in Taskbar
This site is just too formal! After all programmers should have fun! So I decided to add a little hack to it to make it Interesting.
This is just a small snippet to Hide and Show the TaskBar.
I cannot think of any Use of this code except impressing your boss or your colleague. The code is fairly simple. You will be able to follow it with the comments. So here it is:
Option Explicit
'Sets the Window visibility of window specified by hWnd and nCmdShow is the Visibilit State Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _ ByVal nCmdShow As Long) As Long
'Finds a Window based on ClassName or WindowName or Both Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long
' The FindWindowEx function retrieves a handle to a window whose class name and window ' name match the specified strings. The function searches child windows, beginning with the ' one following the given child window. This function does not perform a case-sensitive search. 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
Dim OurParent As Long Dim ourHandle As Long
Public Function HideStartButton() ' This Function Hides the Start Button'
' Get the handle of Taskbar Window OurParent& = FindWindow("Shell_TrayWnd", "")
' Get the Handle of Start Button using the Taskbar Handle ourHandle& = FindWindowEx(OurParent&, 0, "Button", vbNullString)
'Hide the Start Button ShowWindow ourHandle&, 0 End Function
'Reverse the Process followed in Showing the Window Public Function ShowStartButton() 'This Function Shows the Start Button' OurParent& = FindWindow("Shell_TrayWnd", "") ourHandle& = FindWindowEx(OurParent&, 0, "Button", vbNullString) ShowWindow ourHandle&, 5 End Function
|
| Author: Abel Knezevic 10 May 2004 | Member Level: Bronze Points : 0 |
This is a cool nugget. Awesome for pranks! :)
|
| Author: the dude 12 Nov 2005 | Member Level: Bronze Points : 0 |
Nice code dude, but notice something. Long data type in vb.net = 8 bytes, and integer = 4 bytes, so it doesnt work until you remove the "&" and change long for integer ;-)
cheers. bye
|