Form size to fill in screen sizes minus taskbar

How do you resize your form in vb6 so that the bottom border of the form is at the top of the taskbar

+5
source share
3 answers

Is there a reason you can't just maximize your shape? This will be my first impression.

If this is not a runner, you can try to get the height of the taskbar as follows:

Private Const ABM_GETTASKBARPOS = &H5

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
End Type

Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long


Function GetTaskBarSize()
    Dim ABD As APPBARDATA

    SHAppBarMessage ABM_GETTASKBARPOS, ABD

    MsgBox "Width:" & ABD.rc.Right - ABD.rc.Left 
    MsgBox " Height:" & ABD.rc.Bottom -    ABD.rc.Top

End Sub

and then set the height of the form to the height of the screen, except for the height of the taskbar.

+4
source

? , , . , "" . , , , .

Galwegian , , , SystemParametersInfo spi_GetWorkArea. , . MSDN , , -, , GetMonitorInfo; , - .

, . , , , ( " " , ). GetSystemMetrics sm_CXFrame sm_CYFrame .

+4

, , , .

, ( , Microsoft Office ..), VB6 SystemParametersInfo , , . 101 tech tips (PDF) Visual Basic.

Private Const SPI_GETWORKAREA = 48
Private Declare Function SystemParametersInfo& Lib "User32" Alias "SystemParametersInfoA" ( _
ByVal uAction As Long, _
ByVal uParam As Long, lpvParam As Any, _
ByVal fuWinIni As Long)

Private Type RECT
  Left As Long
  Top As Long
  Right As Long
  Bottom As Long
End Type

Public Function CenterForm32 (frm As Form)
  Dim ScreenWidth&, ScreenHeight&, ScreenLeft&, ScreenTop&
  Dim DesktopArea As RECT
  Call SystemParametersInfo (SPI_GETWORKAREA, 0, DesktopArea, 0)

  ScreenHeight = (DesktopArea.Bottom - DesktopArea.Top) * Screen.TwipsPerPixelY
  ScreenWidth = (DesktopArea.Right - DesktopArea.Left) * Screen.TwipsPerPixelX
  ScreenLeft = DesktopArea.Left * Screen.TwipsPerPixelX
  ScreenTop = DesktopArea.Top * Screen.TwipsPerPixelY

  frm.Move (ScreenWidth - frm.Width) / 2 + ScreenLeft, _
    (ScreenHeight - frm.Height) / 2 + ScreenTop
End Function
+4

All Articles