home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / graphics / gdi / setdisp / readme.txt < prev    next >
Text File  |  1996-04-29  |  3KB  |  69 lines

  1. Dynamically Changing the Display Settings
  2.  
  3.  
  4. The SetDisp sample creates a taskbar notification icon that you can use to
  5. dynamically change your display settings. You can change resolution, color
  6. depth, and refresh rate.
  7.  
  8. The core functions used are:
  9.                                                               
  10.    EnumDisplaySettings -- to get the display settings that are supported by
  11.               the video driver
  12.  
  13.    ChangeDisplaySettings -- to test and set the display  settings dynamically
  14.               and to update the registry with these settings
  15.  
  16.    Shell_NotifyIcon -- to create and maintain the tray icon   
  17.  
  18.    TrackPopupMenu   -- to implement the icon resolution context menu
  19.  
  20.  
  21. Usage
  22. ------
  23.  
  24. To use the sample after building it with NMAKE, run SetDisp.EXE.  This will
  25. display a dialog box with a menu of possible resolutions and a will create a
  26. tray icon. If you right mouse click on the tray icon the dialog will get
  27. the focus.  If you hide the dialog, you can bring it back up with this
  28. technique.  If you left mouse click the tray icon, you will get the list of
  29. available settings. To remove the tray icon, you must close the main dialog.
  30.  
  31. When SetDisp starts up, it enumerates all of the device modes that the current
  32. or default display driver supports.  A #define controls filtering low frequency
  33. refresh rates and limits the number of settings SetDisp reads in.  After
  34. enumerating the settings, they are added to the menu. On NT, we can easily
  35. obtain the current setting with ENUM_CURRENT_SETTINGS, so we set the check
  36. mark on the menu and bold the setting that was in use when SetDisp was
  37. started.
  38.  
  39. When you select a new setting, SetDisp test to be sure the DEVMODE selected
  40. has one of the display attributes set.    All of the DEVMODEs used in SetDisp
  41. should have these set since they came from the system.    It then tests to see if
  42. the system believes the DEVMODE is valid. If the change requires a system
  43. reboot, a dialog notifies the user that this is not implemented. If the screen
  44. change can be dynamic, a resolution changed is attempted.  The user is prompted
  45. to see if the new resolution is acceptable.  This is important since the driver
  46. may support a setting but the monitor is not able to display it correctly.  To
  47. ensure the user does not get stuck with a bad setting, a timer is used to
  48. cancel the change if the user does not respond. The default time out is 10
  49. seconds and is controlled by a #define.    If the new setting is accepted, the
  50. registry is updated.  All of this is done using ChangeDisplaySettings.
  51.  
  52.  
  53. Notes
  54. -----
  55.  
  56. On Windows 95, you cannot use EnumDisplaySettings to get the current settings.
  57. In this sample, this causes the check mark to not be displayed and the
  58. current setting to not be made bold. Also on Windows 95, color depth changes 
  59. require a reboot.
  60.  
  61. Of the possible returns from ChangeDisplaySettings, only success and a reboot
  62. required are currently handled.    For success, a dynamic resolution change is
  63. done.  For a reboot required change, a message is displayed indicating that
  64. the sample does not support a reboot.
  65.  
  66. If your driver has many resolutions, the menu may not fit on some resolutions.
  67. This could be resolved with the use of sub menus for different settings
  68. such as color depth or frequencies.
  69.