Visual Basic Concepts
Using a few of the operating system properties and events provided by the SysInfo control, you can detect and respond to changes in screen size and resolution.
The following example tests the size of the active form after a change in screen resolution and adjusts the size of the form if it exceeds the visible screen area.
To resize a form after screen resolution changes, use the DisplayChanged event with the WorkAreaWidth, WorkAreaLeft, and WorkAreaTop properties.
To resize a form after screen resolution changes
Private Sub sysDetectOS_DisplayChanged()
If Screen.ActiveForm.Width > _
sysDetectOS.WorkAreaWidth Then
Screen.ActiveForm.Left = _
sysDetectOS.WorkAreaLeft
Screen.ActiveForm.Width = _
sysDetectOS.WorkAreaWidth
End If
If Screen.ActiveForm.Height > _
sysDetectOS.WorkAreaHeight Then
Screen.ActiveForm.Top = _
sysDetectOS.WorkAreaTop
Screen.ActiveForm.Height = _
sysDetectOS.WorkAreaHeight
End If
End Sub