VB and VBA Users Source Code: Creating a dialog to cover the entire desktop
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Creating a dialog to cover the entire desktop
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Tuesday, October 15, 2002
Hits:
911
Category:
Windows API
Article:
The following code shows how to set a dialog to cover the entire desktop area including the taskbar. This is useful when making an installation program. 'Add to Module Option Explicit Public Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal lWinIni As Long) As Long Private Type APPBARDATA lSize As Long lHwnd As Long lCallbackMessage As Long lEdge As Long tPos As RECT lParam As Long End Type Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long 'Purpose : The routine below with give you the full coordinates of the desktop, inc. the taskbar. ' This is useful when creating an installation program which you want to cover the Startbar. 'Inputs : N/A 'Outputs : Returns the coordinates of the desktop area (inc. the taskbar) 'Author : Andrew Baker (VBUsers.com) 'Date : 30/05/2000 'Example : 'Private Sub Form_Load() ' 'Set the dialog as floating (obtain this function from the by searching the sourcecode) ' DialogToTopVB Me.hwnd ' 'Move the screen to fill the desktop ' With DesktopWorkArea ' Me.Move .Left, .Top, .Right - .Left, .Bottom - .Top ' End With 'End Sub 'Notes : 'Revisions : Function DesktopWorkArea() As RECT Const SPI_GETWORKAREA = 48, ABS_ALWAYSONTOP = &H2, ABS_AUTOHIDE = &H1 Const ABS_BOTH = &H3, ABM_GETSTATE = &H4, ABM_GETTASKBARPOS = &H5 Const ABE_BOTTOM = 3, ABE_LEFT = 0, ABE_RIGHT = 2, ABE_TOP = 1 Dim tDeskPos As RECT, tTaskBarPos As APPBARDATA Call SystemParametersInfo(SPI_GETWORKAREA, vbNull, tDeskPos, 0) 'Set the coordinates of the desktop (ignoring the task bar) With DesktopWorkArea .Left = tDeskPos.Left * Screen.TwipsPerPixelX .Right = tDeskPos.Right * Screen.TwipsPerPixelX .Top = tDeskPos.Top * Screen.TwipsPerPixelY .Bottom = tDeskPos.Bottom * Screen.TwipsPerPixelY End With 'Calculate taskbar position Call SHAppBarMessage(ABM_GETTASKBARPOS, tTaskBarPos) Select Case tTaskBarPos.lEdge Case ABE_BOTTOM 'Taskbar is on the bottom DesktopWorkArea.Bottom = tTaskBarPos.tPos.Bottom * Screen.TwipsPerPixelY Case ABE_LEFT 'Taskbar is to the left DesktopWorkArea.Left = tTaskBarPos.tPos.Left * Screen.TwipsPerPixelX Case ABE_RIGHT 'Taskbar is to the right DesktopWorkArea.Right = tTaskBarPos.tPos.Right * Screen.TwipsPerPixelX Case ABE_TOP 'Taskbar is to the top DesktopWorkArea.Top = tTaskBarPos.tPos.Top * Screen.TwipsPerPixelY End Select End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder