Here's a function I just wrote to size a form to full screen while taking into consideration the taskbar. I'm guessing bushmobile's code does something similar, but since it's a different API call, what the heck. Here ya go:Note that instead of the returning a RECT, I modify the passed parameters. I can't really remember why, which is sad because I wrote this just last week.Code:Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private Type APPBARDATA cbSize As Long hwnd As Long uCallbackMessage As Long uEdge As Long rc As RECT lParam As Long ' message specific End Type Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long ' Supply coords (in twips) of usable desktop ' which will differ from full screen if the taskbar ' is AlwaysOnTop and doesn't autohide Public Sub GetDesktop(Left As Long, Top As Long, Width As Long, Height As Long) Const ABM_GETSTATE = &H4 Const ABM_GETTASKBARPOS = &H5 Const ABS_ALWAYSONTOP = &H2 Dim typBar As APPBARDATA Dim lngState As Long ' Start with full screen coords Left = 0 Top = 0 Width = Screen.Width Height = Screen.Height ' Query the taskbar state lngState = SHAppBarMessage(ABM_GETSTATE, typBar) ' Now shrink down the side with the taskbar if it infringes on desktop space If lngState = ABS_ALWAYSONTOP Then ' AlwaysOnTop and doesn't AutoHide lngState = SHAppBarMessage(ABM_GETTASKBARPOS, typBar) Select Case typBar.uEdge Case 0: Left = typBar.rc.Right * Screen.TwipsPerPixelX Case 1: Top = typBar.rc.Bottom * Screen.TwipsPerPixelY Case 2: Width = typBar.rc.Left * Screen.TwipsPerPixelX ' this is really right, not width Case 3: Height = typBar.rc.Top * Screen.TwipsPerPixelY ' this is really bottom, not height End Select ' Convert right and bottom to width and height Width = Width - Left Height = Height - Top End If End Sub




Reply With Quote