【发布时间】:2016-02-24 10:11:48
【问题描述】:
我试图在我的应用程序打开时隐藏任务栏和开始按钮,并在我关闭它时重新显示它们。我设法为 64 位版本的应用程序执行此操作,但是当我在目标 cpu 的 Visual Studio 中将其设置为 32 位时,出现异常“算术运算导致溢出”。
这是我在 64 位上使用和工作的方法。
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
我尝试将这些而不是 long 设置为整数,它适用于隐藏,但不适用于取消隐藏。 关于如何为 32 位执行此操作的任何想法?
【问题讨论】:
-
这可能是XY Problem,而不是隐藏任务栏/菜单,而是想要make your form full screen?。如果/当您的应用崩溃时,用户将如何恢复任务栏/开始菜单?
-
你在哪一行得到错误?
标签: vb.net