I am trying to hide the taskbar and the start button when my app opens and show them back on when i close it. I manage to do this for an 64bit version of the app, but when i set it to 32bit in visual studio in target cpu i get an exception 'Arithmetic operation resulted in an overflow'.
Here are the methods i use and work for 64bit.
Public Class frmShowHideStartBar
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const SW_HIDE = 0
Private Const SW_SHOW = 1
Public Function HideStartButton() As Boolean
Dim retval = False
Try
HideTaskBar()
Dim hwndStartButton = FindWindow("Button", "Start")
If hwndStartButton <> IntPtr.Zero Then
retval = ShowWindow(hwndStartButton, SW_HIDE)
End If
Catch ex As Exception
MsgBox("HideStartButton " + ex.Message)
End Try
Return retval
End Function
Public Function HideTaskBar() As Boolean
Dim retval = False
Try
Dim hwndTaskBar = FindWindow("Shell_TrayWnd", "")
If hwndTaskBar <> IntPtr.Zero Then
retval = ShowWindow(hwndTaskBar, SW_HIDE)
End If
Catch ex As Exception
MsgBox("HideTaskBar " + ex.Message)
End Try
Return retval
End Function
Public Function ShowStartButton() As Boolean
Dim retval1 = False
Try
ShowHideTaskBar()
Dim hwndstartbutton = FindWindow("Button", "Start")
If hwndstartbutton <> IntPtr.Zero Then
retval1 = ShowWindow(hwndstartbutton, SW_SHOW)
End If
Catch ex As Exception
MsgBox("ShowStartButton " + ex.Message)
End Try
Return retval1
End Function
Public Function ShowHideTaskBar() As Boolean
Dim retval2 = False
Try
Dim hwndTaskBar = FindWindow("Shell_TrayWnd", "")
If hwndTaskBar <> IntPtr.Zero Then
retval2 = ShowWindow(hwndTaskBar, SW_SHOW)
End If
Catch ex As Exception
MsgBox("ShowHideTaskBar " + ex.Message)
End Try
Return retval2
End Function
End Class
I tried setting these instead of long to integer, and it works for the hide, but its not working for the unhide. Any ideas on how to do it for 32bit?