CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2002
    Location
    Tenby, Wales
    Posts
    277

    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
    Last edited by brjames32; November 7th, 2006 at 07:34 AM. Reason: wrong spelling - from instead of form <RESOLVED>

  2. #2
    Join Date
    Jun 2004
    Location
    NH
    Posts
    678

    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.
    Last edited by TT(n); January 19th, 2008 at 03:27 AM.

  3. #3
    Join Date
    Dec 2002
    Location
    Tenby, Wales
    Posts
    277

    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

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    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

  5. #5
    Join Date
    Jun 2004
    Location
    NH
    Posts
    678

    Re: Hide Taskbar or Trap mouse in From?

    Yes, Just set the FormBorderStyle property to None
    Likewise!

  6. #6
    Join Date
    Dec 2002
    Location
    Tenby, Wales
    Posts
    277

    Re: Hide Taskbar or Trap mouse in From?

    Cheers guys that work perfectly!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured