Hide Taskbar or Trap mouse in Form?
I have a bit of a dilemma. I have written a program that allows users to view videos of the Lifeboats that we have - in action. The users only have the use of a mouse and no keyboard. I want the form to cover the taskbar when run so that the users cannot get into Windows XP.
Is this easy to do? I am already runnng the forms Maximised but it doesn't cover the taskbar.
Woulod it be easier to 'trap' the mouse so that it cannot get out of the current form?
Thanks in advance :ehh:
Re: Hide Taskbar or Trap mouse in From?
Depending on the level of your users, (never known really) you'll have to cover additional conditions.
For example double clicking the Title bar, etc...
You can make the taskbar invisible pretty easy.
Code:
Private Declare Function apiFindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Int32
Private Declare Function apiFindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Int32, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As Int32
Private Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" (ByVal hwnd As Int32, ByVal nCmdShow As Int32) As Int32
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
On Error Resume Next
Dim tWnd As Int32 = apiFindWindow("Shell_TrayWnd", vbNullString)
Dim bWnd As Int32 = apiFindWindowEx(tWnd, bWnd, "BUTTON", vbNullString)
apiShowWindow(tWnd, 0)
apiShowWindow(bWnd, 0)
'Some additional windows to mess with
'twnd = apiFindWindow("Shell_TrayWnd", vbNullString)
'twnd = apiFindWindowEx(twnd, 0, "ReBarWindow32", vbNullString)
'twnd = apiFindWindowEx(twnd, 0, "MsTaskSwWClass", vbNullString)
' twnd = apiFindWindowEx(twnd, 0, "ToolbarWindow32", vbNullString)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
On Error Resume Next
Dim tWnd As Int32 = apiFindWindow("Shell_TrayWnd", vbNullString)
Dim bWnd As Int32 = apiFindWindowEx(tWnd, bWnd, "BUTTON", vbNullString)
apiShowWindow(bWnd, 1)
apiShowWindow(tWnd, 1)
End Sub
If the taskbar is already hidden or locked you might need some extra code to get, and unlock it. Not sure.
Re: Hide Taskbar or Trap mouse in From?
Cheers for that. Will try it out later on and let you knwo how I get on.
I am sure that years ago, with VB6 (Iam now using VB 2005 express) I was able to turn off the TtileBar. Is this still possible?
Thanks again
Re: Hide Taskbar or Trap mouse in From?
Great code TT(n)!!
Quote:
Originally Posted by brjames32
I was able to turn off the TtileBar. Is this still possible?
Yes, Just set the FormBorderStyle property to None :)
Re: Hide Taskbar or Trap mouse in From?
Quote:
Yes, Just set the FormBorderStyle property to None
Likewise! :)
Re: Hide Taskbar or Trap mouse in From?
Cheers guys that work perfectly!!!