Welcome to Dream.In.Code
Become a VB Expert!

Join 137,233 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,793 people online right now. Registration is fast and FREE... Join Now!




Resolution changing- refresh screen needed...

 
Reply to this topicStart new topic

Resolution changing- refresh screen needed...

Episonage
23 Feb, 2007 - 11:52 AM
Post #1

New D.I.C Head
Group Icon

Joined: 10 Feb, 2007
Posts: 22


Dream Kudos: 25
My Contributions
I've been using this snippet to change resolution from my program.... (In VB6)
But when I change resolution, all windows have some black stuff on them... I figure I need ro refresh the screen... But how?
Thanks

CODE

Call with changeResolution(w,h)
--------------------------

'The API's:
Private Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" _
(ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
Private Declare Function ChangeDisplaySettings Lib "user32.dll" Alias "ChangeDisplaySettingsA" _
(lpDevMode As Any, ByVal dwFlags As Long) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

'Types:
Private Type DEVMODE
    dmDeviceName       As String * 32
    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 * 32
    dmUnusedPadding    As Integer
    dmBitsPerPel       As Integer
    dmPelsWidth        As Long
    dmPelsHeight       As Long
    dmDisplayFlags     As Long
    dmDisplayFrequency As Long
End Type

'Now the function itself:
Public Function changeResolution (ByVal width As Integer, ByVal height As Integer)
   Dim dev As DEVMODE
   EnumDisplaySettings 0, 0, dev
   dev.dmFields = &H80000 Or &H100000
   dev.dmPelsWidth = width
   dev.dmPelsHeight = height


This post has been edited by Episonage: 23 Feb, 2007 - 11:52 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:39PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month