Full Version: Graphic properties on frms..
UtterAccess Forums > MicrosoftŪ Access > Access Forms
mixodorians190
Hi.. quick question.
Is there any code that will allows me to detect the users "screen resolution", so I can then import the relevant graphic from a folder - into a form?
And How do you prepare a graphics for all the various screen resolutions?
Thanks in advance.
freakazeud
Hi,
search UA for screen resolution and you should find many samples. One would be here.
To prepare the graphics ahead of time you need to modify your own screen resolution to the once you want to support and then edit (adjust size) the graphics in some graphic editor (MS Paint, PhotoShop, PhotoImpact...).
HTH
Good luck
t0nka
CODE
Option Compare Database
Option Explicit
Type RECT
x1 As Long
y1 As Long
x2 As Long
y2 As Long
End Type
' NOTE: The following declare statements are case sensitive.
Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function GetWindowRect Lib "user32" _
(ByVal hwnd As Long, rectangle As RECT) As Long
'================================================= =====
'This code shows how to change the screen resolution.
'Call the function like this:
' ChangeResolution 640, 480
'This would change the screen resolution to 640 pixels x 480 pixels.
'Note
'that
'you can only change the resolution to values supported by the display.
Paste the following code into a module:'
Public Declare Function ChangeDisplaySettings Lib "user32" _
    Alias "ChangeDisplaySettingsA" _
   (lpDevMode As Any, _
    ByVal dwflags As Long) As Long
Public Declare Function EnumDisplaySettings Lib "user32" _
    Alias "EnumDisplaySettingsA" _
   (ByVal lpszDeviceName As Long, _
    ByVal iModeNum As Long, _
    lpDevMode As Any) As Long
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000
Const CCFORMNAME = 32
Const CCDEVICENAME = 32
Private Type DEVMODE
dmDeviceName As String * CCDEVICENAME
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 * CCFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Public Function Change_Resolution(iWidth As Single, iHeight As Single)
Dim DevM As DEVMODE
Dim a As Boolean
Dim i As Long
Dim b As Long
O= 0
'Enumerate settings
Do
a = EnumDisplaySettings(0&, i&, DevM)
i = i + 1
Loop Until (a = False)
'Change settings
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = iWidth
DevM.dmPelsHeight = iHeight
b = ChangeDisplaySettings(DevM, 0)
End Function
'************************************************* ****************
' FUNCTION: GetScreenResolution()
'
' PURPOSE:
' To determine the current screen size or resolution.
'
' RETURN:
' The current screen resolution. Typically one of the following:
' 640 x 480
' 800 x 600
' 1024 x 768
'
'************************************************* ****************
Function GetScreenResolution() As String
Dim R As RECT
Dim hwnd As Long
Dim RetVal As Long
hwnd = GetDesktopWindow()
RetVal = GetWindowRect(hwnd, R)
GetScreenResolution = (R.x2 - R.x1) & "x" & (R.y2 - R.y1)
End Function

THere is another it also includes the code to change the user's resolution if you wanted to.
Credit to the original author whoever it was.
t0nka
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.