Share via


Visual Basic: SysInfo Control

WorkAreaWidth Property Example

This 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 run this example, put a SysInfo control on a form. Paste this code into the DisplayChanged event of the SysInfo control. Run the example, then change the screen resolution.

  Private Sub SysInfo1_DisplayChanged()
    If Screen.ActiveForm.Width > SysInfo1.WorkAreaWidth Then
        Screen.ActiveForm.Left = SysInfo1.WorkAreaLeft
        Screen.ActiveForm.Width = SysInfo1.WorkAreaWidth
    End If
    If Screen.ActiveForm.Height > SysInfo1.WorkAreaHeight Then
        Screen.ActiveForm.Top = SysInfo1.WorkAreaTop
        Screen.ActiveForm.Height = SysInfo1.WorkAreaHeight
    End If
End Sub