Hi at51178
This should make things happen for you.
Put all of Section A in a Module and save it
Then put Section B in the on open event of your default first form to be opened.
And lastly put Section C in the Onlcick part of your Quit button
Basically what this will do is take a snapshot of the users current resolution and store the details
It will then change the resolution to that, that you have declared in section B and finally when the user quits it will take the earlier resolution and flip it back to what the user originally started with
Awesome...
Have fun
ModeX
PS Not tested on XP, yet, will test this sunday.
'SECTION A Start
' Declarations and such needed for the example:
' (Copy them to the (declarations) section of a module.)
Public Type DEVMODE
dmDeviceName As String * 32
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * 32
dmUnusedPadding As Integer
dmBitsPerPixel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
' The following only appear in Windows 95, 98, 2000
dmICMMethod As Long
dmICMIntent As Long
dmMediaType As Long
dmDitherType As Long
dmReserved1 As Long
dmReserved2 As Long
' The following only appear in Windows 2000
dmPanningWidth As Long
dmPanningHeight As Long
End Type
Public Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, _
ByVal iModeNum As Long, lpDevMode As DEVMODE) As Long
Public Const ENUM_CURRENT_SETTINGS = -1
Public Declare Function ChangeDisplaySettings Lib "user32.dll" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags _
As Long) As Long
Public Const CDS_UPDATEREGISTRY = &H1
Public Const CDS_TEST = &H2
Public Const DISP_CHANGE_SUCCESSFUL = 0
Public Const DISP_CHANGE_RESTART = 1
Public origwidthx1 As Long
Public origheightx1 As Long
Public Once as Integer
'END oF SECTION A
====================================
' START SECTION B
Dim dm As DEVMODE ' display settings
once = once + 1
If once = 1 Then
Dim retval As Long ' return value
' Initialize the structure that will hold the settings.
dm.dmSize = Len(dm)
' Get the current display settings.
retval = EnumDisplaySettings(vbNullString, ENUM_CURRENT_SETTINGS, dm)
origwidthx1 = (dm.dmPelsWidth)
origheightx1 = (dm.dmPelsHeight)
' Change the resolution settings to whatever is valid ie 640 * 480, 800 * 600, 1024 * 768 etc etc.
dm.dmPelsWidth = 1024
dm.dmPelsHeight = 768
' Test to make sure the changes are possible.
retval = ChangeDisplaySettings(dm, CDS_TEST)
If retval <> DISP_CHANGE_SUCCESSFUL Then
Debug.Print "Cannot change to that resolution!"
Else
' Change and save to the new settings.
retval = ChangeDisplaySettings(dm, CDS_UPDATEREGISTRY)
Select Case retval
Case DISP_CHANGE_SUCCESSFUL
Debug.Print "Resolution successfully changed!"
Case DISP_CHANGE_RESTART
Debug.Print "A reboot is necessary before the changes will take effect."
Case Else
Debug.Print "Unable to change resolution!"
End Select
End If
End If
DoCmd.Maximize
'END SECTION B
====================================
'START SECTION C
Dim dm As DEVMODE ' display settings
Dim retval As Long ' return value
' Initialize the structure that will hold the settings.
dm.dmSize = Len(dm)
' Get the current display settings.
retval = EnumDisplaySettings(vbNullString, ENUM_CURRENT_SETTINGS, dm)
' Change the resolution settings to 800x600.
dm.dmPelsWidth = origwidthx1
dm.dmPelsHeight = origheightx1
' Test to make sure the changes are possible.
retval = ChangeDisplaySettings(dm, CDS_TEST)
If retval <> DISP_CHANGE_SUCCESSFUL Then
Debug.Print "Cannot change to that resolution!"
Else
' Change and save to the new settings.
retval = ChangeDisplaySettings(dm, CDS_UPDATEREGISTRY)
Select Case retval
Case DISP_CHANGE_SUCCESSFUL
Debug.Print "Resolution successfully changed!"
Case DISP_CHANGE_RESTART
Debug.Print "A reboot is necessary before the changes will take effect."
Case Else
Debug.Print "Unable to change resolution!"
End Select
End If
DoCmd.Quit
' END SECTION C