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

Resize the desktop

Status
Not open for further replies.

sixsmithc

Technical User
Feb 2, 2001
21
GB
Is there any way to resize the users resolution through VB code, I have a program that needs to be run at 1024 x 768 and most of our computers run at 800*600.

All the machines can handle the resolution it would just save me the hassle of resizing every computer running this program.


Thanks In Advanve


Carl

:)


 
Well i am no wizard and the only way that i am aware of is by using direct x but the diplay properties change back after app is closed.

Probly not what you need to know but just trying to help.

You can d/l dx8 sdk from microsoft 144 meg
It took me 2 days

c ya
 
To try out this example, create a form with two command buttons on it. Note that selecting an incorrect frequency for a selected resolution may cause dmage to your monitor (although most modern monitors are fairly resilient), and so I take no responsibility for any misuse of this code...

Option Explicit

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_BITSPERPEL = &H40000
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000
Const DM_DISPLAYFREQUENCY = &H400000
Const ENUM_CURRENT_SETTINGS = -1


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
Private OriginalDevM As DEVMODE
Private NewDevM As DEVMODE
'Dim DevM As DEVMODE


Private Sub Command1_Click()
OriginalDevM.dmSize = LenB(OriginalDevM)
EnumDisplaySettings 0&, ENUM_CURRENT_SETTINGS, OriginalDevM
NewDevM = OriginalDevM
NewDevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_DISPLAYFREQUENCY

NewDevM.dmPelsWidth = 1280
NewDevM.dmPelsHeight = 1024
' NewDevM.dmDisplayFrequency = 70 'Danger: try to make sure that you use an acceptable frequency.
ChangeDisplaySettings NewDevM, 0

End Sub

Private Sub Command2_Click()
ChangeDisplaySettings OriginalDevM, 0
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top