Results 1 to 7 of 7

Thread: [RESOLVED] VB6: Make program cover the taskbar

  1. #1

    Thread Starter
    Hyperactive Member metalmidget's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    342

    Resolved [RESOLVED] VB6: Make program cover the taskbar

    I'm making a game and running out of room at the bottom of my first form. How do I make the form go full screen and cover the taskbar at the bottom of the screen?
    I have one solution: right-click taskbar, properties, then uncheck "Keep the taskbar on top of other windows." The problem with that is that I don't want to have to keep turning that setting off and on when the game is or isn't running. Plus I don't want my users to have to do it either, especially if it's at school where you can't get into those sorts of menus.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VB6: Make program cover the taskbar

    Try this
    Code:
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
    ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, _
    ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    
    Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
       
    Private Const SM_CXSCREEN = 0
    Private Const SM_CYSCREEN = 1
    Private Const HWND_TOP = 0
    Private Const SWP_SHOWWINDOW = &H40
    
    Private Sub Form_Load()
    'This code will maximize the window covering the task bar
    Dim ll_Width As Long
        Dim ll_Height As Long
        
        If Me.WindowState = vbMaximized Then
            WindowState = vbNormal
        End If
       
        'work out full screen dimensions
        ll_Width = GetSystemMetrics(SM_CXSCREEN)
        ll_Height = GetSystemMetrics(SM_CYSCREEN)
       
        'use SetWindowPos to resize window
        Call SetWindowPos(Me.hwnd, HWND_TOP, 0, 0, ll_Width, _
            ll_Height, SWP_SHOWWINDOW)
    End Sub

  3. #3
    Interweb adm/o/distrator Paul M's Avatar
    Join Date
    Nov 2006
    Location
    Australia, Melbourne
    Posts
    2,306

    Re: VB6: Make program cover the taskbar

    You cna also use the SystemParametersInfo API

  4. #4

    Thread Starter
    Hyperactive Member metalmidget's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    342

    Re: VB6: Make program cover the taskbar

    1- That didn't work, the only difference is that the form is no longer maximised.
    2- Is there a reason for using the Constants at the top, then using their names as the parameters? Why not just use 0, 1 and &H40 for the parameters?
    3- How does this mysterious "SystemParametersInfo" of which you speak work?

  5. #5
    Fanatic Member
    Join Date
    Jul 2007
    Location
    Essex, UK.
    Posts
    579

    Re: VB6: Make program cover the taskbar

    I always use a form whose Borderstyle is set to 1 - Fixed Single.

    Then in the Form_Load Event put;

    Code:
    Me.Move 0, 0, Screen.Width, Screen.Height
    This always sizes to the exact dimensions of the screen and overlays the TaskBar. No need to set the forms windowstate to maximum.

  6. #6
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: VB6: Make program cover the taskbar

    Try this:
    Code:
    Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
    
    ' Set/unset a form as AlwaysOnTop
    Public Sub SetAlwaysOnTop(ByVal hwnd As Long, Optional ByVal AlwaysOnTop As Boolean = True)
        Const SWP_NOSIZE = &H1
        Const SWP_NOMOVE = &H2
        Const SWP_SHOWWINDOW = &H40
        Const HWND_NOTOPMOST = -2
        Const HWND_TOPMOST = -1
        
        If AlwaysOnTop Then
            SetWindowPos hwnd, HWND_TOPMOST, 0&, 0&, 0&, 0&, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW
        Else
            SetWindowPos hwnd, HWND_NOTOPMOST, 0&, 0&, 0&, 0&, SWP_NOMOVE Or SWP_NOSIZE Or SWP_SHOWWINDOW
        End If
    End Sub
    Usage:
    Code:
    Private Sub Form_Load()
        Me.Move 0, 0, Screen.Width, Screen.Height
        SetAlwaysOnTop Me.hwnd
    End Sub

  7. #7

    Thread Starter
    Hyperactive Member metalmidget's Avatar
    Join Date
    Mar 2007
    Location
    Melbourne, Australia
    Posts
    342

    Re: VB6: Make program cover the taskbar

    I just stumbled across a much easier solution. make the border fixed single and the windowstate maximised. yay

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