Click to See Complete Forum and Search --> : Adust the screen size
Eswar
Dec 12th, 2000, 11:14 PM
Hi Everybody,
Can the screen resolution be changed from 800x600 to 800x400 or from 640x480 to 640x280
Please do help me ASAP.
With Thanks,
Eswar.
steve7946
Dec 13th, 2000, 02:47 AM
Hi, i found this on the web, i think it should help you. i have not tryed the code so i don't know.
'**************************************
'Windows API/Global Declarations for :Ch
' angeRes
'**************************************
Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long
Private Const CCDEVICENAME = 32
Private Const CCFORMNAME = 32
Private Const DM_BITSPERPEL = &H60000
Private Const DM_PELSWIDTH = &H80000
Private Const DM_PELSHEIGHT = &H100000
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
'**************************************
' Name: ChangeRes
' Description:This Function will change
' your Windows Resolution. It is very simp
' le, and it does what most Resolution Cha
' nge Functions don't do, it changes the t
' he Bits Per Pixels as well as the Screen
' Width and Height.
' By: ScAnFrEaK
'
'
' Inputs:Dim RetValue As Integer
RetValue = ChangeRes(800, 600, 32)
'
' Returns:1 = Resolution Successfully Ch
' anged
0 = Resolution Was Not Changed
'
'Assumes:None
'
'Side Effects:None
'This code is copyrighted and has limite
' d warranties.
'Please see http://www.Planet-Source-Cod
' e.com/xq/ASP/txtCodeId.1943/lngWId.1/qx/
' vb/scripts/ShowCode.htm
'for details.
'**************************************
Function ChangeRes(Width As Single, Height As Single, BPP As Integer) As Integer
On Error GoTo ERROR_HANDLER
Dim DevM As DEVMODE, I As Integer, ReturnVal As Boolean, _
RetValue, OldWidth As Single, OldHeight As Single, _
OldBPP As Integer
Call EnumDisplaySettings(0&, -1, DevM)
OldWidth = DevM.dmPelsWidth
OldHeight = DevM.dmPelsHeight
OldBPP = DevM.dmBitsPerPel
I = 0
Do
ReturnVal = EnumDisplaySettings(0&, I, DevM)
I = I + 1
Loop Until (ReturnVal = False)
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL
DevM.dmPelsWidth = Width
DevM.dmPelsHeight = Height
DevM.dmBitsPerPel = BPP
Call ChangeDisplaySettings(DevM, 1)
RetValue = MsgBox("Do You Wish To Keep Your Screen Resolution To " & Width & "x" & Height & " - " & BPP & " BPP?", vbQuestion + vbOKCancel, "Change Resolution Confirm:")
If RetValue = vbCancel Then
DevM.dmPelsWidth = OldWidth
DevM.dmPelsHeight = OldHeight
DevM.dmBitsPerPel = OldBPP
Call ChangeDisplaySettings(DevM, 1)
MsgBox "Old Resolution(" & OldWidth & " x " & OldHeight & ", " & OldBPP & " Bit) Successfully Restored!", vbInformation + vbOKOnly, "Resolution Confirm:"
ChangeRes = 0
Else
ChangeRes = 1
End If
Exit Function
ERROR_HANDLER:
ChangeRes = 0
End Function
Eswar
Dec 14th, 2000, 02:50 AM
Hi Steve7946, Thanks for your help, it is quite helpful to me, but there is only one problem with ChangeDisplaySettings, i think it will work with 16-bit only, but i want the same to work with 32-bit and i found out that the function should be ChangeDisplaySettingsEX, but i found that there is no entry in my Win32api.txt file which is there with me... could you please help out to solve the problem.. With Thanks Eswar.
V(ery) Basic
Dec 14th, 2000, 03:19 AM
The declare is
Public Declare Function ChangeDisplaySettingsEx _
Lib "user32.dll" Alias "ChangeDisplaySettingsExA" (ByVal _
lpszDeviceName As String, ByRef lpDevMode As DEVMODE, _
ByVal hwnd As Long, ByVal dwflags As Long, lParam As Any) As Long
and the site explaining how to use it is:
http://msdn.microsoft.com/library/psdk/gdi/devcons_3tfc.htm
Sorry I couldn't provide my own example, but it's WAY too early in the morning.
Me.
Eswar
Dec 15th, 2000, 12:55 AM
Hi,
Thanks for the code help given to me, but actually it is not working in my code properly... can you please send me the example you have done...
With Thanks and Regards,
Eswar.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.