-
December 31st, 2005, 10:57 PM
#1
Setting the screen to 1024x768 Please Help!!
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
Last edited by duplincomputers; December 31st, 2005 at 11:30 PM.
-
January 1st, 2006, 12:37 AM
#2
Re: Setting the screen to 1024x768
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
Last edited by WizBang; January 2nd, 2006 at 03:07 AM.
Reason: Added [code] tags
-
January 1st, 2006, 06:30 AM
#3
Re: Setting the screen to 1024x768
Hi Dublin !
First Thx for your code and a Happy new Year !
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 )
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
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.
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.
Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
January 1st, 2006, 10:09 AM
#4
Re: Setting the screen to 1024x768
Code:
Oh thank you figured it out this looks so much better
-
January 1st, 2006, 11:43 AM
#5
Re: Setting the screen to 1024x768
Originally Posted by duplincomputers
Code:
Oh thank you figured it out this looks so much better
Yea Great, You got it Have a good time in this forum. Every questions and posts to help others are welcome.
Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|