|
-
Aug 14th, 2007, 06:39 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Aug 14th, 2007, 06:46 AM
#2
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
-
Aug 14th, 2007, 06:50 AM
#3
Re: VB6: Make program cover the taskbar
You cna also use the SystemParametersInfo API
-
Aug 14th, 2007, 07:07 AM
#4
Thread Starter
Hyperactive Member
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?
-
Aug 14th, 2007, 07:50 AM
#5
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.
-
Aug 14th, 2007, 09:11 AM
#6
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
-
Aug 16th, 2007, 12:19 AM
#7
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|