Total Visual SourceBook

Total Visual SourceBook CD and Printed Manual

Microsoft Access/ Office 2016, 2013, 2010, and 2007 Version
is Shipping!

New features in Total Visual SourceBook for Access, Office 2007 and VB6

Supports Access/Office 2016, 2013, 2010 and 2007, and Visual Basic 6.0!

Separate version for Access/Office 2003, 2002, and 2000.

Separate version for:
Access 97/95


View all FMS products for Microsoft AccessAll Our Microsoft Access Products

SourceBook Info:

Why SourceBook?

 

"The code is exactly how I would like to write code and the algorithms used are very efficient and well-documented."

Van T. Dinh, Microsoft MVP

 

 

 

Microsoft Access, Office/VBA, VB6 Modules royalty-free source code libraryMicrosoft Access Modules royalty-free source code libraryMicrosoft Access VBA and VB6 Module Library Free trial of Total Visual SourceBook for Microsoft Access, Office, VB6 and VBA

Class: ChangeRes in Category Microsoft Visual Basic 6 : Graphics from Total Visual SourceBook

Changing monitor screen resolutions in VB6.

This class supports functionality to list all available video modes and switch to the desired mode. Since some mode changes require a shutdown of Windows, this is also supported.

Procedure List

Procedure Name

Type

Description

(Declarations) Declarations Declarations and private variables for the CChangeRes class
AllowReboot Property Get whether or not the class offers the option to reboot Windows if a display mode change requires it. Certain mode changes may require a reboot. For example, changing the color depth on some systems requires a reboot for the changes to take effect. If you set this property to True, the class will prompt for a reboot as needed. If this property is set to False, the class will not prompt for reboot, nor will it reboot.
ForceMode Property Get whether or not the video mode is reset when the mode requested is the same as the current mode.
hDC Property Set the hDC of a form in the app. This is required to get the list of supported modes.
Mode Property Retrieve the video mode at the specified position in the collection. This property is only valid after calling the LoadModes method. After calling the LoadModes method, the class Modes collection contains a 1-based list of available modes. Use the Mode property with a long integer index value to retrieve a specific mode.
ModeCount Property A 1-based count of available video modes. This property is only valid after calling the LoadModes method.
Class_Initialize Initialize Code called when the class is instantiated.
ChangeResolution Method Changes resolution to the selected value. The lngSelMode argument corresponds to an available video mode. Since this property is 0-based and the Mode collection is one-based, subtract 1 from a Mode collection item to get the corresponding value to pass to this method.
LoadModes Method Loads the modes supported by the current display adapter into the class collection, along with strings describing the available modes
IsNT Private Determine if the OS is Windows NT

Example Code for Using Class: ChangeRes

' Example of the CChangeRes class
'
' To use this example:
' 1. Create a new form.
' 2. Create a list box called lstModes
' 3. Create a command button called cmdTest
' 4. Create a checkbox called chkForce
' 5. Paste the entire contents of this module into the new form's module.

Private mChangeRes As CChangeRes

Private Sub chkNT_Click()

  Call LoadList

End Sub

Private Sub cmdTest_Click()
  Dim lngCurrent As Long

  ' Get the selected item from the list box.
  ' Increment by one to synchronize with the CChangeRes class's 1-based mode collection.
  lngCurrent = lstModes.ListIndex + 1

  ' Prompt for change
  If MsgBox("Change resolution?", vbYesNo) = vbYes Then
    ' Set the Force property
    mChangeRes.ForceMode = chkForce.Value

    ' Call the method to change the resolution
    mChangeRes.ChangeResolution (lngCurrent - 1)
  End If

End Sub

Private Sub Form_Load()

  ' Set up the form

  With lstModes
    .Left = 45
    .Top = 45
    .Height = 3960
    .Width = 2865
  End With

  With chkForce
    .Left = 3015
    .Top = 45
    .Height = 600
    .Width = 1545
  End With

  With cmdTest
    .Caption = "Change Resolution"
    .Left = 3015
    .Top = chkForce.Top + chkForce.Height + 100
    .Height = 495
    .Width = 1530
  End With

  ' Instantiate the class
  Set mChangeRes = New CChangeRes

  ' Allow reboots if necessary
  mChangeRes.AllowReboot = True

  ' Pass this form's hDC
  mChangeRes.hDC = Me.hDC

  Call LoadList

End Sub

Private Sub LoadList()
  Dim lngCounter As Long

  lstModes.Clear

  ' Load the modes
  mChangeRes.LoadModes

  ' Show the modes in the list box

  For lngCounter = 1 To mChangeRes.ModeCount
    lstModes.AddItem mChangeRes.Mode(lngCounter)
  Next lngCounter

End Sub

Microsoft Access Module LibraryOverview of Total Visual SourceBook

The source code in Total Visual SourceBook includes modules and classes for Microsoft Access, Visual Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily add this professionally written, tested, and documented royalty-free code into your applications to simplify your application development efforts.

Additional Resources