Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Windows's configuration

Status
Not open for further replies.

Fabiana

Programmer
Mar 5, 2000
4
0
0
AR
I'm programming in Visual Basic and I have problems when users change the windows's configuration (date's format, decimal separator, separator of thousands). How can I do in Visual Basic to change theese settings according to my needs? <br><br><br>Thanks.<br><br>Fabiana
 
Fabiana -<br><br>Not much you can do.&nbsp;&nbsp;You can put the burden in one of two places -- on yourself, or on the user.<br><br>If you put the burden on yourself, you would use the standard Windows controls for date, currency, etc., and have to parse them out into year/month/day, and whole part/decimal part/currency symbol, etc. yourself.&nbsp;&nbsp;The good news is you can centralize this into a function.&nbsp;&nbsp;The bad news is it's a real pain to get it 100% correct.<br><br>If you put the burden on the user, you would design your own controls for date/time and currency.&nbsp;&nbsp;The user would have to conform to your format for entering values.&nbsp;&nbsp;The good news is your coding becomes much easier.&nbsp;&nbsp;The bad news is the users hate you for it.<br><br>We chose to use the 2nd method, because we don't anticipate our application being used in Europe or the Far East.&nbsp;&nbsp;We can enforce the m/d/y (vs. the European style d/m/y) date format without too much danger of cheesing off the residents of Quebec (since we don't provide a French-Canadian version, that's OK with us).<br><br>Chip H.<br>
 
I've had similar problems with users changeing screen resolution. I found this code posted on a site somewhere. Hope it helps.<br><br><b> Changing the Display Resolution from Visual Basic </b><br><br>Visual Basic System Services<br>Posted Tuesday September 1, 1998<br>Updated Saturday June 12, 1999<br>Applies to: VB4-32, VB5, VB6<br><br>&nbsp;Prerequisites:<br><br>none.<br><br>This routine,like the ListView method in Enumerating the Available Display Resolutions, uses Windows' EnumDisplaySettings API to retrieve all the available screen resolutions supported by the display. Here, the results are used to createa &quot;QuickRes-style menu&quot;, replete with the option of displaying the users display settings dialog.<br><br>While changing form one screen resolution to another within the same screen depth poses no problems, changing to another display depth may produce undesirable results. Memorize the locations of the settings option on the display properties in case you find yourself fumbling in the dark, so to speak.<br><br>The display enum and resolution changing code contained here was authored by Joe LeVasseur.<br><br>&nbsp;BAS Module Code<br><br>Add the following code to a BAS module:<br><br>Option Explicit<br><br>Public Declare Function EnumDisplaySettings Lib &quot;user32&quot; _<br>&nbsp;&nbsp;&nbsp;&nbsp;Alias &quot;EnumDisplaySettingsA&quot; _<br>&nbsp;&nbsp;&nbsp;(ByVal lpszDeviceName As Long, _<br>&nbsp;&nbsp;&nbsp;&nbsp;ByVal iModeNum As Long, _<br>&nbsp;&nbsp;&nbsp;&nbsp;lpDevMode As Any) As Boolean<br><br>Public Declare Function GetDeviceCaps Lib &quot;gdi32&quot; _<br>&nbsp;&nbsp;&nbsp;(ByVal hdc As Long, _<br>&nbsp;&nbsp;&nbsp;&nbsp;ByVal nIndex As Long) As Long<br><br>Public Declare Function ChangeDisplaySettings Lib &quot;user32&quot; _<br>&nbsp;&nbsp;&nbsp;&nbsp;Alias &quot;ChangeDisplaySettingsA&quot; _<br>&nbsp;&nbsp;&nbsp;(lpDevMode As Any, _<br>&nbsp;&nbsp;&nbsp;&nbsp;ByVal dwflags As Long) As Long<br><br>Public Declare Function SetMenuDefaultItem Lib &quot;user32&quot; _<br>&nbsp;&nbsp;&nbsp;(ByVal hMenu As Long, _<br>&nbsp;&nbsp;&nbsp;&nbsp;ByVal uItem As Long, _<br>&nbsp;&nbsp;&nbsp;&nbsp;ByVal fByPos As Long) As Long<br><br>Public Declare Function GetMenu Lib &quot;user32&quot; _<br>&nbsp;&nbsp;&nbsp;(ByVal hWnd As Long) As Long<br><br>Public Declare Function GetSubMenu Lib &quot;user32&quot; _<br>&nbsp;&nbsp;&nbsp;(ByVal hMenu As Long, _<br>&nbsp;&nbsp;&nbsp;ByVal nPos As Long) As Long<br><br>Public Const LOGPIXELSX As Long = 88<br>Public Const LOGPIXELSY As Long = 90<br>Public Const BITSPIXEL As Long = 12<br>Public Const HORZRES As Long = 8<br>Public Const VERTRES As Long = 10<br><br>Public Const CCDEVICENAME As Long = 32<br>Public Const CCFORMNAME As Long = 32<br><br>Public Const DM_GRAYSCALE As Long = &H1<br>Public Const DM_INTERLACED As Long = &H2<br><br>Public Const DM_BITSPERPEL As Long = &H40000<br>Public Const DM_PELSWIDTH As Long = &H80000<br>Public Const DM_PELSHEIGHT As Long = &H100000<br>Public Const DM_DISPLAYFLAGS As Long = &H200000<br><br>Public Const CDS_UPDATEREGISTRY As Long = &H1<br>Public Const CDS_TEST As Long = &H2<br>Public Const CDS_FULLSCREEN As Long = &H4<br>Public Const CDS_GLOBAL As Long = &H8<br>Public Const CDS_SET_PRIMARY As Long = &H10<br>Public Const CDS_NORESET As Long = &H10000000<br>Public Const CDS_SETRECT As Long = &H20000000<br>Public Const CDS_RESET As Long = &H40000000<br>Public Const CDS_FORCE As Long = &H80000000<br><br>'Return values for ChangeDisplaySettings<br>'Public Const DISP_CHANGE_SUCCESSFUL = 0<br>'Public Const DISP_CHANGE_RESTART = 1<br>'Public Const DISP_CHANGE_FAILED = -1<br>'Public Const DISP_CHANGE_BADMODE = -2<br>'Public Const DISP_CHANGE_NOTUPDATED = -3<br>'Public Const DISP_CHANGE_BADFLAGS = -4<br>'Public Const DISP_CHANGE_BADPARAM = -5<br><br>Public Type DEVMODE<br>&nbsp;&nbsp;&nbsp;dmDeviceName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As String * CCDEVICENAME<br>&nbsp;&nbsp;&nbsp;dmSpecVersion&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmDriverVersion&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmDriverExtra&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmFields&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Long<br>&nbsp;&nbsp;&nbsp;dmOrientation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmPaperSize&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmPaperLength&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmPaperWidth&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmScale&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmCopies&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmDefaultSource&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmPrintQuality&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmColor&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmDuplex&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmYResolution&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmTTOption&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmCollate&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmFormName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As String * CCFORMNAME<br>&nbsp;&nbsp;&nbsp;dmUnusedPadding&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmBitsPerPel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Integer<br>&nbsp;&nbsp;&nbsp;dmPelsWidth&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Long<br>&nbsp;&nbsp;&nbsp;dmPelsHeight&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;As Long<br>&nbsp;&nbsp;&nbsp;dmDisplayFlags&nbsp;&nbsp;&nbsp;&nbsp;As Long<br>&nbsp;&nbsp;&nbsp;dmDisplayFrequency As Long<br>End Type<br><br>'--end block--'<br><br>&nbsp;Form Code<br><br>To a new form, add a top-level menu item, and name it &quot;mnuDisplayModes&quot;. Add a single submenu item under this, and name this menuitem &quot;mnuModes&quot;. Set it's index to 0 to create the necessary menu array.<br><br>Add the following to the form:<br><br>Option Explicit<br><br>'vars set in load<br>Dim currHRes As Long<br>Dim currVRes As Long<br>Dim currBPP As Long<br><br>'var set in mnuModes<br>Dim currMenuItem As Long<br><br>'array of valid resolutions & colour depths<br>Dim resArray() As Long<br><br>'const for the members of the array<br>'i.e. resArray(resWidth, Index) = 1024<br>'i.e. resArray(resHeight, Index) = 768<br>'i.e. resArray(resDepth, Index)= 16&nbsp;&nbsp;'Bits per pixel<br>Const resWidth = 1<br>Const resHeight = 2<br>Const resDepth = 3<br>Private Sub Form_Load()<br><br>&nbsp;&nbsp;'retrieves the current screen resolution for<br>&nbsp;&nbsp;'later comparison against DEVMODE values in<br>&nbsp;&nbsp;'CompareSettings.<br>&nbsp;&nbsp;&nbsp;currHRes = GetDeviceCaps(hdc, HORZRES)<br>&nbsp;&nbsp;&nbsp;currVRes = GetDeviceCaps(hdc, VERTRES)<br>&nbsp;&nbsp;&nbsp;currBPP = GetDeviceCaps(hdc, BITSPIXEL)<br><br>&nbsp;&nbsp;&nbsp;Dim maxItems As Long<br>&nbsp;&nbsp;&nbsp;InitializeDisplayMenu maxItems<br>&nbsp;&nbsp;&nbsp;FinalizeDisplayMenu maxItems<br><br>End Sub<br>Private Sub FinalizeDisplayMenu(maxItems As Long)<br><br>&nbsp;&nbsp;'This adds a separator and a final menu item,<br>&nbsp;&nbsp;'providing the ability to open the control panel<br>&nbsp;&nbsp;'display settings page from the app.<br><br>&nbsp;&nbsp;&nbsp;If maxItems &gt; 0 Then<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim hMenu As Long<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim r As Long<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'add the separator<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maxItems = maxItems + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Load mnuModes(maxItems)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mnuModes(maxItems).Caption = &quot;-&quot;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'add the final item<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;maxItems = maxItems + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Load mnuModes(maxItems)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mnuModes(maxItems).Caption = &quot;Show Display Settings&quot;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'finally, bold the newly-added menuitem<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hMenu = GetSubMenu(GetMenu(Me.hWnd), 0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call SetMenuDefaultItem(hMenu, maxItems - 1, True)<br><br>&nbsp;&nbsp;&nbsp;End If<br><br>End Sub<br>Private Sub InitializeDisplayMenu(maxItems As Long)<br><br>&nbsp;&nbsp;&nbsp;Dim DM As DEVMODE<br>&nbsp;&nbsp;&nbsp;Dim dMode As Long<br><br>&nbsp;&nbsp;'36 should be enough to hold your settings.<br>&nbsp;&nbsp;'It's trimmed back at the end of this routine.<br>&nbsp;&nbsp;&nbsp;ReDim resArray(1 To 3, 0 To 35)<br><br>&nbsp;&nbsp;'set the DEVMODE flags and structure size<br>&nbsp;&nbsp;&nbsp;DM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL<br>&nbsp;&nbsp;&nbsp;DM.dmSize = LenB(DM)<br><br>&nbsp;&nbsp;'The first mode is 0<br>&nbsp;&nbsp;&nbsp;dMode = 0<br><br>&nbsp;&nbsp;'call the API to retrieve the values for the<br>&nbsp;&nbsp;'specified dMode<br>&nbsp;&nbsp;&nbsp;Do While EnumDisplaySettings(0&, dMode, DM) &gt; 0<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'if the BitsPerPixel is greater than 4<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'(16 colours), then add the item to a menu<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If DM.dmBitsPerPel &gt;= 4 Then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call MenuAdd(DM, resArray(), maxItems)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'increment and call again. Continue until<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'EnumDisplaySettings returns 0 (no more settings)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dMode = dMode + 1<br><br>&nbsp;&nbsp;&nbsp;Loop<br><br>&nbsp;&nbsp;'trim back the resArray to fit the number of actual entries.<br>&nbsp;&nbsp;&nbsp;ReDim Preserve resArray(1 To 3, 0 To maxItems)<br><br>End Sub<br>Private Function CompareSettings(DM As DEVMODE) As Long<br><br>&nbsp;&nbsp;'compares the current screen resolution with<br>&nbsp;&nbsp;'the current DEVMODE values.&nbsp;&nbsp;&nbsp;Returns TRUE if<br>&nbsp;&nbsp;'the horizontal and vertical resolutions, and<br>&nbsp;&nbsp;'the bits per pixel colour depth, are the same.<br><br>&nbsp;&nbsp;&nbsp;CompareSettings = (DM.dmBitsPerPel = currBPP) And _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DM.dmPelsHeight = currVRes And _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DM.dmPelsWidth = currHRes<br><br>End Function<br>Private Sub MenuAdd(DM As DEVMODE, resArray() As Long, mnuCount As Long)<br><br>&nbsp;&nbsp;&nbsp;Dim mType As String<br><br>&nbsp;&nbsp;'used to determine when the colour depth has<br>&nbsp;&nbsp;'changed, so we can add a separator to the menu.<br>&nbsp;&nbsp;&nbsp;Static lastBitsPerPel As Long<br><br>&nbsp;&nbsp;'select the appropriate text string based on<br>&nbsp;&nbsp;'the colour depth<br>&nbsp;&nbsp;&nbsp;Select Case DM.dmBitsPerPel<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 4:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mType = &quot;16 Color&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 8:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mType = &quot;256 Color&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 16:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mType = &quot;High Color&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case 24, 32: mType = &quot;True Color&quot;<br>&nbsp;&nbsp;&nbsp;End Select<br><br>&nbsp;&nbsp;'if this is the first item, we can't load the menu<br>&nbsp;&nbsp;'array item, and it will not require a separator.<br>&nbsp;&nbsp;&nbsp;If mnuCount &gt; 0 Then<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'load a new menu item to the array<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Load mnuModes(mnuCount)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'determine if the colour depth has changed. If so,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'make the caption a separator, and load a new item<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'to hold the item.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If lastBitsPerPel &lt;&gt; DM.dmBitsPerPel Then<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mnuModes(mnuCount).Caption = &quot;-&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mnuCount = mnuCount + 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Load mnuModes(mnuCount)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;&nbsp;End If<br><br>&nbsp;&nbsp;'create the menu caption<br>&nbsp;&nbsp;&nbsp;mnuModes(mnuCount).Caption = DM.dmPelsWidth & &quot;x&quot; & _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DM.dmPelsHeight & &quot;&nbsp;&nbsp;[&quot; & _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DM.dmBitsPerPel & &quot; bit &quot; & _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mType & &quot;]&quot;<br><br>&nbsp;&nbsp;'see if this is the current resolution,<br>&nbsp;&nbsp;'and if so, check the menu item<br>&nbsp;&nbsp;&nbsp;mnuModes(mnuCount).Checked = CompareSettings(DM)<br>&nbsp;&nbsp;&nbsp;If mnuModes(mnuCount).Checked Then currMenuItem = mnuCount<br><br>&nbsp;&nbsp;&nbsp;resArray(resWidth, mnuCount) = DM.dmPelsWidth<br>&nbsp;&nbsp;&nbsp;resArray(resHeight, mnuCount) = DM.dmPelsHeight<br>&nbsp;&nbsp;&nbsp;resArray(resDepth, mnuCount) = DM.dmBitsPerPel<br><br>&nbsp;&nbsp;'save the current DEVMODE value for depth<br>&nbsp;&nbsp;'and increment the menu item count, ready for<br>&nbsp;&nbsp;'the next call<br>&nbsp;&nbsp;&nbsp;lastBitsPerPel = DM.dmBitsPerPel<br>&nbsp;&nbsp;&nbsp;mnuCount = mnuCount + 1<br><br>End Sub<br>Private Sub cmdLoadMenu_Click()<br><br>&nbsp;&nbsp;&nbsp;Dim maxItems As Long<br><br>&nbsp;&nbsp;&nbsp;InitializeDisplayMenu maxItems<br>&nbsp;&nbsp;&nbsp;cmdLoadMenu.Enabled = False<br><br>&nbsp;&nbsp;&nbsp;FinalizeDisplayMenu maxItems<br><br>End Sub<br>Private Sub mnuModes_Click(Index As Integer)<br><br>&nbsp;&nbsp;&nbsp;Dim DM As DEVMODE<br><br>&nbsp;&nbsp;&nbsp;Select Case Index<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case mnuModes.Count<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'show the display control panel<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call Shell(&quot;rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3&quot;, 1)<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Case Else<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'change the current resolution, no prompting<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'BE CAREFUL .. you could set your system to a<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'setting which renders the display difficult to read.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;With DM<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.dmPelsWidth = resArray(resWidth, Index)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.dmPelsHeight = resArray(resHeight, Index)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.dmBitsPerPel = resArray(resDepth, Index)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.dmSize = LenB(DM)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End With<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If ChangeDisplaySettings(DM, CDS_FORCE) &lt;&gt; 0 Then<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Error! Perhaps your hardware is not up to the task?&quot;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'indicate the current menu selection<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mnuModes(currMenuItem).Checked = False<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mnuModes(Index).Checked = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;currMenuItem = Index<br><br>&nbsp;&nbsp;&nbsp;End Select<br><br>End Sub<br><br>'--end block--'<br>&nbsp;Comments<br><br>On running, the menu should contain all your available settings, similar to<br>those displayed in the ListView example. The current resolution will be<br>checked.<br><br>Selecting another resolution or colour depth will cause the display to<br>change without prompting.&nbsp;&nbsp;Be careful.<br> <p>Colin Chevrier<br><a href=mailto:colin.chevrier@ca.jdsunph.com>colin.chevrier@ca.jdsunph.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top