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
 
 
 
 
 
 
TitlePlace a form along an edge of the screen using the SysInfo control
Keywordsform, screen, edge, SysInfo
CategoriesTips and Tricks, Controls
 
Use the SysInfo control to tell where the work area is. Position the form across the top of the work area.
 
Private Sub Form_Load()
    ' Position the form.
    PositionForm
End Sub

' Put the form along the right edge of the work area.
Private Sub PositionForm()
    Move SysInfo1.WorkAreaLeft, _
        SysInfo1.WorkAreaTop, _
        SysInfo1.WorkAreaWidth
End Sub
 
When the SysInfo control receives the SettingChanged event, some setting changed. It might have been the location of the task bar so reposition the form.
 
' Some setting changed, possibly the location of the
' task bar. Reposition the form.
Private Sub SysInfo1_SettingChanged(ByVal Item As Integer)
    PositionForm
End Sub
 
To prevent the user from moving or resizing the form, either set BorderStyle = None or subclass to ignore form moving events. See also Make a form stick to an edge of the screen.

Note: I have been told this does not work properly in Windows 2000. The SysInfo control seems to ignore the task bar when calculating the work area. For an example that doesn't use the SysInfo control, see Center a form taking the taskbar into account.

 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated