Nascondere o visualizzare lo StartButton di Windows7 con PInvoke
Scritto da
Massimo Bonanni il
mercoledì 9 novembre 2011
•
Linguaggio:
• Livello: 100
In una precedente pillola abbiamo visto come sia possibile
nascondere la TaskBar di Windows utilizzando PInvoke.
Tale operazione non nasconde, però lo
StartButton.
Per nascondere questo è necessario utilizzare le API FindWindow e
ShowWindow per agire, oltre che sulla TaskBar anche sullo
StartButton.
VB.NET
<DllImport("user32.dll")>
Private Shared Function FindWindow(className As String, windowText As String) As IntPtr
End Function
<DllImport("user32.dll")>
Private Shared Function ShowWindow(hwnd As IntPtr, command As Integer) As Integer
End Function
Private Const SW_HIDE As Integer = 0
Private Const SW_SHOW As Integer = 1
I metodi per nascondere e visualizzare la taskbar sono i
seguenti:
VB.NET
Public Shared Function HideStartButton() As Boolean
Dim retval = False
Dim hwndTaskBar = FindWindow("Shell_TrayWnd", "")
If hwndTaskBar <> IntPtr.Zero Then
ShowWindow(hwndTaskBar, SW_HIDE)
Dim hwndStartButton = FindWindow("Button", "Start")
If hwndStartButton <> IntPtr.Zero Then
retval = ShowWindow(hwndStartButton, SW_HIDE)
End If
End If
Return retval
End Function
Public Shared Function ShowStartButton() As Boolean
Dim retval = False
Dim hwndTaskBar = FindWindow("Shell_TrayWnd", "")
If hwndTaskBar <> IntPtr.Zero Then
ShowWindow(hwndTaskBar, SW_SHOW)
Dim hwndStartButton = FindWindow("Button", "Start")
If hwndStartButton <> IntPtr.Zero Then
retval = ShowWindow(hwndStartButton, SW_SHOW)
End If
End If
Return retval
End Function
Tags: PInvoke,windows 7