DisplayResolutionChange Event

Applies to:  Subclasser object, PowerForm control
See also:  Resizing event, Resized event, Event Index

Occurs when the system's display resolution has changed.  This event can occur when the display resolution has been changed by the user via the Display Control Panel, or when the display resolution has been changed by another application.

Syntax:

Private Sub object_DisplayResolutionChange()

The DisplayResolutionChange event syntax has these parts:

Part Description
object The name of an object in the Applies to list.  If object is a SubClasser object, then the object must be declared using WithEvents.

Remarks:

It is generally preferable to re-position controls in response to the Resized event.  If your form is maximized, the Form_Resize event and the Resized event will both fire when the display resolution is changed.

The DisplayResolutionChange event should only be handled if there are specific aspects of your user interface which rely on the screen resolution.

Use the intrinsic Screen object to determine the new screen resolution.

Example:

The following code snippet resets the maximized height of the form to always leave a 100 pixel gap below the form, even when the form is maximized.

Private Sub PowerForm1_DisplayResolutionChange()
    PowerForm1.MaximizedHeight = Screen.TwipsPerPixelY-100
End Sub

 

 

Home

Copyright and Disclaimer