1) should you not develop your app to work in a resolution of 800 X 600
2) What are you going to do if someone runs your program. It then changes the resolution and it turns out that their monitor is not capable of running that high. Ooops
3) People may not only have your application running and may be using other programs. Are they going to like you messing about with thier screensizes?

Also, in most cases, a resolution change requires a reboot

Just a thought. Here's the code anyhow

VB Code:
  1. Attribute VB_Name = "modDynamicChange"
  2. Option Explicit
  3.  
  4. Private Const CCDEVICENAME = 32
  5. Private Const CCFORMNAME = 32
  6.  
  7. Private Const DISP_CHANGE_SUCCESSFUL = 0
  8. Private Const DISP_CHANGE_RESTART = 1
  9. Private Const DISP_CHANGE_FAILED = -1
  10. Private Const DISP_CHANGE_BADMODE = -2
  11. Private Const DISP_CHANGE_NOTUPDATED = -3
  12. Private Const DISP_CHANGE_BADFLAGS = -4
  13. Private Const DISP_CHANGE_BADPARAM = -5
  14.  
  15. Private Const CDS_UPDATEREGISTRY = &H1
  16. Private Const CDS_TEST = &H2
  17.  
  18. Private Const DM_BITSPERPEL = &H40000
  19. Private Const DM_PELSWIDTH = &H80000
  20. Private Const DM_PELSHEIGHT = &H100000
  21.  
  22. Private Type DEVMODE
  23.   dmDeviceName As String * CCDEVICENAME
  24.   dmSpecVersion As Integer
  25.   dmDriverVersion As Integer
  26.   dmSize As Integer
  27.   dmDriverExtra As Integer
  28.   dmFields As Long
  29.   dmOrientation As Integer
  30.   dmPaperSize As Integer
  31.   dmPaperLength As Integer
  32.   dmPaperWidth As Integer
  33.   dmScale As Integer
  34.   dmCopies As Integer
  35.   dmDefaultSource As Integer
  36.   dmPrintQuality As Integer
  37.   dmColor As Integer
  38.   dmDuplex As Integer
  39.   dmYResolution As Integer
  40.   dmTTOption As Integer
  41.   dmCollate As Integer
  42.   dmFormName As String * CCFORMNAME
  43.   dmUnusedPadding As Integer
  44.   dmBitsPerPel As Integer
  45.   dmPelsWidth As Long
  46.   dmPelsHeight As Long
  47.   dmDisplayFlags As Long
  48.   dmDisplayFrequency As Long
  49. End Type
  50.  
  51. Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
  52. Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long
  53.  
  54. Function ChangeScreenSettings(lWidth As Integer, lHeight As Integer, lColors As Integer)
  55. Dim tDevMode As DEVMODE, lTemp As Long, lIndex As Long
  56. ' Declare variables
  57. lIndex = 0
  58. Do
  59.   'Instilise Do loop
  60.   lTemp = EnumDisplaySettings(0&, lIndex, tDevMode)
  61.   ' Call the APi function
  62.   If lTemp = 0 Then Exit Do
  63.   ' If there is no more data or an erro occurs
  64.   ' then return 0 and exit do
  65.   lIndex = lIndex + 1
  66.   ' Increase the index to be enumerated
  67.  
  68.   With tDevMode
  69.     If .dmPelsWidth = lWidth And .dmPelsHeight = lHeight And .dmBitsPerPel = lColors Then
  70.       lTemp = ChangeDisplaySettings(tDevMode, CDS_UPDATEREGISTRY)
  71.       Exit Do
  72.     End If
  73.   End With
  74.   ' Set the new data
  75.   ' Change the display type. This depends on the paramter used
  76.   ' It can either be:
  77.   ' 0 - Dynamic change if possible
  78.   ' CDS_UPDATEREGISTRY - Dynamically change if possible
  79.   ' and if not possibel then  update registry for change
  80.   ' on the next boot-up
  81.   ' CDS_TEST - Test the new settings
  82. Loop
  83. Select Case lTemp
  84.     ' Check for errors
  85.   Case DISP_CHANGE_SUCCESSFUL
  86.     MsgBox "The display settings change was successful", vbInformation
  87.   Case DISP_CHANGE_RESTART
  88.     MsgBox "The computer must be restarted in order for the graphics mode to work", vbQuestion
  89.   Case DISP_CHANGE_FAILED
  90.     MsgBox "The display driver failed the specified graphics mode", vbCritical
  91.   Case DISP_CHANGE_BADMODE
  92.     MsgBox "The graphics mode is not supported", vbCritical
  93.   Case DISP_CHANGE_NOTUPDATED
  94.     MsgBox "Unable to write settings to the registry", vbCritical
  95.     ' NB. Windows NT Only
  96.   Case DISP_CHANGE_BADFLAGS
  97.     MsgBox "An invalid set of flags was passed in", vbCritical
  98. End Select
  99. End Function