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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

screen resolution 1

Status
Not open for further replies.

at51178

Technical User
Joined
Mar 25, 2002
Messages
587
Location
US
Hey Guys

I work in an environment where the screen resolution of the computers are constantly being changed I wouldl like to have my forms in access to automatically adjust to the screen resolution I find that I create a form on my computer and it looks great and when I go to view it on another person's computer it is either too big for the screen or too small is there a way to fix this let me know

thanks
 
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 &quot;Cannot change to that resolution!&quot;
Else
' Change and save to the new settings.
retval = ChangeDisplaySettings(dm, CDS_UPDATEREGISTRY)
Select Case retval
Case DISP_CHANGE_SUCCESSFUL
Debug.Print &quot;Resolution successfully changed!&quot;
Case DISP_CHANGE_RESTART
Debug.Print &quot;A reboot is necessary before the changes will take effect.&quot;
Case Else
Debug.Print &quot;Unable to change resolution!&quot;
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 &quot;Cannot change to that resolution!&quot;
Else
' Change and save to the new settings.
retval = ChangeDisplaySettings(dm, CDS_UPDATEREGISTRY)
Select Case retval
Case DISP_CHANGE_SUCCESSFUL
Debug.Print &quot;Resolution successfully changed!&quot;
Case DISP_CHANGE_RESTART
Debug.Print &quot;A reboot is necessary before the changes will take effect.&quot;
Case Else
Debug.Print &quot;Unable to change resolution!&quot;
End Select
End If
DoCmd.Quit

' END SECTION C
 
Hi,

I have a piece of code that you just cut and paste into each form to automatically resize. If you wish it justsend us an email

LCURRIE@MITSUIBABCOCK.COM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top