Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitlePut a form in the lower right corner accounting for the task bar
Keywordsposition form, taskbar, lower right
CategoriesTips and Tricks
 
Use the SystemParametersInfo API function with the SPI_GETWORKAREA parameter to get the work area size. Use that to position the form.
 
' Position the form in the lower right corner.
Private Sub PutFormInLowerRight(ByVal frm As Form, ByVal _
    right_margin As Single, ByVal bottom_margin As Single)
Dim wa_info As RECT

    If SystemParametersInfo(SPI_GETWORKAREA, _
        0, wa_info, 0) <> 0 _
    Then
        ' We got the information. Position the form.
        ' Position the form.
        frm.Left = ScaleX(wa_info.Right, vbPixels, vbTwips) _
            - _
            Width - right_margin
        frm.Top = ScaleY(wa_info.Bottom, vbPixels, vbTwips) _
            - _
            Height - bottom_margin
    Else
        ' We did not get the work area bounds.
        ' Use the entire screen.
        frm.Left = Screen.Width - Width - right_margin
        frm.Top = Screen.Height - Height - bottom_margin
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated