Forms resolution

  • Thread starter Thread starter andreja_zivkovich
  • Start date Start date
A

andreja_zivkovich

Guest
I create database (15 forms) in Access 2000 whit resolution 1024x768...
I want to create form with optional button for changing the resolution ... Buttons with 1024x768;640x780;600x800...
Please help me!!!
 
Are you wanting to change the users PC screen resolution?

Changing desktop settings on a users computer is normally discouraged. I have the code that can do what you want but be warned that your resolution changes can have adverse affects on a users computer and the other programs that they have open. Also, changing the screen resolution on older Windows 95 machines requires the user to reboot their PC.

HTH
ghudson

-------------------------------------------------------------------------------------
Below is the code you want to change the users system resolution settings. The users display screen will black out and appear in the new resolution when you run either public function. You will need to test what the users current settings are so that you can change them back when they close your application. Most Windows 95 PC's require a reboot when changing the screen settings! This routine works flawlessly on my Windows 98 OS with Access 97.

HTH

'Place this in a public module and call either public function to change the resolution.

'*** These two lines to be added if OS is Windows 2000 ***
'*** in DEVMODE declaration ***

' dmPanningWidth As Long
' dmPanningHeight As Long

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
dmICMMethod As Long
dmICMIntent As Long
dmMediaType As Long
dmDitherType As Long
dmReserved1 As Long
dmReserved2 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 Function ChangeResolution1024x768()

DoCmd.Echo False

Dim dm As DEVMODE
Dim retval As Long

dm.dmSize = Len(dm)
retval = EnumDisplaySettings(vbNullString, ENUM_CURRENT_SETTINGS, dm)

dm.dmPelsWidth = 1024 ' Width should be numeric (e.g. 800 or 1024)
dm.dmPelsHeight = 768 ' Height should be numeric (e.g. 600 or 768)

retval = ChangeDisplaySettings(dm, CDS_TEST)
If retval <> DISP_CHANGE_SUCCESSFUL Then
Debug.Print "Cannot change to that resolution!"
Else

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.Echo True

End Function

'***************************************
Public Function ChangeResolution800x600()

DoCmd.Echo False

Dim dm As DEVMODE
Dim retval As Long

dm.dmSize = Len(dm)
retval = EnumDisplaySettings(vbNullString, ENUM_CURRENT_SETTINGS, dm)

dm.dmPelsWidth = 800 ' Width should be numeric (e.g. 800 or 640)
dm.dmPelsHeight = 600 ' Height should be numeric (e.g. 600 or 480)

retval = ChangeDisplaySettings(dm, CDS_TEST)
If retval <> DISP_CHANGE_SUCCESSFUL Then
Debug.Print "Cannot change to that resolution!"
Else

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.Echo True

End Function
 
Are you trying instead to change the resolution of your form based on the user's screen size? There is code on this site in a LONG post that shows how to do this - check the archives...
 

Users who are viewing this thread

Back
Top Bottom