In my program screen has to be set at 1024x768 some people use other res how can i set the screen when the program starts to 1024x768
thanks for any help
Printable View
In my program screen has to be set at 1024x768 some people use other res how can i set the screen when the program starts to 1024x768
thanks for any help
i got it to work here the code
Code:'Changes resolution on the fly, without rebooting
'Call with:
'Call ChangeRes(800,600)
'or Call ChangeRes(640,480) for example
' if resolution is not possible, a dialog is displayed
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
Const CCDEVICENAME = 32
Const CCFORMNAME = 32
Const DM_PELSWIDTH = &H80000
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
Dim DevM As DEVMODE
Sub ChangeRes(iWidth As Single, iHeight As Single)
Dim a As Boolean
Dim i As Integer
i = 0
Do
a = EnumDisplaySettings(0&, i, DevM)
i = i + 1
Loop Until (a = False)
Dim b&
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = iWidth
DevM.dmPelsHeight = iHeight
ChangeDisplaySettings DevM, 0
End Sub
Hi Dublin !
First Thx for your code and a Happy new Year ! :wave:
May all your wishes and good postulates for 2006 come true.
I have a small wish too. Please use code tags. Your code would be much easier to read. Here is a small example of your code written with a code Tag in begin and end of code. Its nearly no work and makes you code much easier to read. ( In most Cases )
Additional you get it into a frame so everybode can see code on one shot. To help is easier then. Additional it could happen, that some helpers like me, often don't look to much into a thread when there are no Code Tags in use. Its easier to help another one in the same time where i would have only to read code which looks like a sausage of letters. And maybe you dont know: LeftSpaces and Tabs, which are in a code are elininated, when you dont use code Tags.Code:Sub ChangeRes(iWidth As Single, iHeight As Single)
Dim a As Boolean
Dim i As Integer
i = 0
Do
a = EnumDisplaySettings(0&, i, DevM)
i = i + 1
Loop Until (a = False)
Dim b&
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = iWidth
DevM.dmPelsHeight = iHeight
ChangeDisplaySettings DevM, 0
End Sub
If you dont know how to do, then quote to this post and when it opens, you can find the tags easily. its simple [ code ] and [/ code ] but without any spaces in it.
Code:Oh thank you figured it out this looks so much better
Yea Great, You got it :lol: Have a good time in this forum. Every questions and posts to help others are welcome.Quote:
Originally Posted by duplincomputers
:wave: