Well, you can hide both the Taskbar and the Start Orb with the code below (Note this has been adapted from this CodeProject article
A Simplified Solution for Hiding the Taskbar and Start Orb in Vista and Windows 7[
^]
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll")> _
Private Shared Function FindWindow(ByVal className As String, ByVal windowText As String) As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function SetWindowPos(ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function ShowWindow(ByVal hwnd As Integer, ByVal command As Integer) As Integer
End Function
<DllImport("user32.dll")> _
Private Shared Function IsWindowVisible(ByVal hWnd As IntPtr) As Boolean
End Function
Private Const SW_HIDE As Integer = 0
Private Const SW_SHOW As Integer = 1
Private Const SW_TOGGLE As Integer = -1
Private Function TaskBarAndStartShowHide(ByVal ShowHide As Integer) As Boolean
Dim bRet As Boolean = False
Try
Dim TaskBarHwnd As Integer = FindWindow("Shell_traywnd", "")
Dim StartOrbHwnd As Integer = FindWindow("Button", "Start")
Dim action As Integer = ShowHide
If ShowHide = SW_TOGGLE Then action = IIf(IsWindowVisible(TaskBarHwnd), SW_HIDE, SW_SHOW)
If TaskBarHwnd <> 0 Then
ShowWindow(TaskBarHwnd, action)
If StartOrbHwnd <> IntPtr.Zero Then
ShowWindow(StartOrbHwnd, action)
End If
End If
bRet = True
Catch ex As Exception
bRet = False
End Try
Return bRet
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TaskBarAndStartShowHide(SW_TOGGLE)
End Sub
Private Sub Form1_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
TaskBarAndStartShowHide(SW_SHOW)
End Sub
End Class
This will just hide the Start Menu "Orb" and the Taskbar (including the system tray).
However, your user could still hit the Windows key to bring up the Start Menu, or use Alt-Tab to navigate to another program.
I found this code to disable the windows key
on DaniWeb[
^] reproduced below
'Event Info structure
Public Structure KBDLLHOOKSTRUCT
Public vkCode As Integer
Public scanCode As Integer
Public flags As Integer
Public time As Integer
Public dwExtraInfo As Integer
End Structure
'Event types
Private Const WM_KEYUP As Integer = &H101
Private Const WM_KEYDOWN As Short = &H100S
Private Const WM_SYSKEYDOWN As Integer = &H104
Private Const WM_SYSKEYUP As Integer = &H105
'Keyboard hook related functions
Private Declare Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Integer) As Integer
Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" (ByVal idHook As Integer, ByVal lpfn As KeyboardHookDelegate, ByVal hmod As Integer, ByVal dwThreadId As Integer) As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Integer
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Integer, ByVal nCode As Integer, ByVal wParam As Integer, ByVal lParam As KBDLLHOOKSTRUCT) As Integer
Private Delegate Function KeyboardHookDelegate(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Private KeyboardHandle As IntPtr = 0 'Handle of the hook
Private callback As KeyboardHookDelegate = Nothing 'Delegate for the hook
Private Function Hooked()
Return KeyboardHandle <> 0 'If KeyboardHandle = 0 it means that it isn't hooked so return false, otherwise return true
End Function
Public Sub HookKeyboard()
callback = New KeyboardHookDelegate(AddressOf KeyboardCallback)
KeyboardHandle = SetWindowsHookEx(13, callback, Process.GetCurrentProcess.MainModule.BaseAddress, 0)
End Sub
Public Sub UnhookKeyboard()
If (Hooked()) Then
If UnhookWindowsHookEx(KeyboardHandle) <> 0 Then
KeyboardHandle = 0 'We have unhooked successfully
End If
End If
End Sub
Public Function KeyboardCallback(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
'Variable to hold the text describing the key pressed
Dim Key = lParam.vkCode
'If event is KEYDOWN
If wParam = WM_KEYDOWN Or wParam = WM_SYSKEYDOWN Then
'If we can block events
If Code >= 0 Then
If Key = 91 Or Key = 92 Then
Return (1) 'Block event
End If
End If
End If
End Function
You'll need to add
HookKeyboard()
and
UnhookKeyboard()
into the
TaskBarAndStartShowHide
function and don't forget to put UnhookKeyboard() into the
FormClosing
event before you leave!