Gå til innhold

Anbefalte innlegg

Videoannonse
Annonse

Det kan jeg ikke si jeg vet helt, men jeg ville tippe at du må bruke skjermkort driverne, det er ikke bare en funksjon i Windows for å gjøre det(etter det jeg vet).

 

Du må i så fall bruke DriverProc(), men den er ikke lett å bruke i VisualBasic(den er ikke i API Viewer engang).

 

Kanskje noen andre har vært borti det? eneste gangene jeg har byttet oppløsning har jeg brukt DirectDraw eller Direct3D.

Lenke til kommentar

Lim dette inn i en form:

 

 

Option Explicit

 

Const WM_DISPLAYCHANGE = &H7E

Const HWND_BROADCAST = &HFFFF&

Const EWX_LOGOFF = 0

Const EWX_SHUTDOWN = 1

Const EWX_REBOOT = 2

Const EWX_FORCE = 4

Const CCDEVICENAME = 32

Const CCFORMNAME = 32

Const DM_BITSPERPEL = &H40000

Const DM_PELSWIDTH = &H80000

Const DM_PELSHEIGHT = &H100000

Const CDS_UPDATEREGISTRY = &H1

Const CDS_TEST = &H4

Const DISP_CHANGE_SUCCESSFUL = 0

Const DISP_CHANGE_RESTART = 1

Const BITSPIXEL = 12

 

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 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 Declare Function SHRestartSystemMB Lib "shell32" Alias "#59" (ByVal hOwner As Long, ByVal sExtraPrompt As String, ByVal uFlags As Long) As Long

Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long

Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As Any) As Long

Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

 

Sub ChangeRes(X As Long, Y As Long, Bits As Long)

 

Dim DevM As DEVMODE, ScInfo As Long, erg As Long, an As VbMsgBoxResult

 

erg = EnumDisplaySettings(0&, 0&, DevM)

 

DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL

DevM.dmPelsWidth = X 'ScreenWidth

DevM.dmPelsHeight = Y 'ScreenHeight

DevM.dmBitsPerPel = Bits '(can be 8, 16, 24, 32 or even 4)

 

erg = ChangeDisplaySettings(DevM, CDS_TEST)

 

Select Case erg&

Case DISP_CHANGE_RESTART

SHRestartSystemMB Me.hwnd, vbNullString, EWX_REBOOT

 

Case DISP_CHANGE_SUCCESSFUL

erg = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)

ScInfo = Y * 2 ^ 16 + X

SendMessage HWND_BROADCAST, WM_DISPLAYCHANGE, ByVal Bits, ByVal ScInfo

MsgBox "Everything's ok", vbOKOnly + vbSystemModal, "It worked!"

 

Case Else

MsgBox "Mode not supported", vbOKOnly + vbSystemModal, "Error"

End Select

 

End Sub

 

Private Sub Command1_Click()

 

Dim nDC As Long

 

OldX = Screen.Width / Screen.TwipsPerPixelX

OldY = Screen.Height / Screen.TwipsPerPixelY

nDC = CreateDC("DISPLAY", vbNullString, vbNullString, ByVal 0&)

ChangeRes 800, 600, GetDeviceCaps(nDC, BITSPIXEL)

 

End Sub

Lenke til kommentar
  • 1 år senere...

Finnes det noen måte å forandre oppdateringsfrekvensen (Hz) på samme måte også?

 

Har et lite "problem" med at Windows tilbakestiller skjerminnstillingene til 1152x864@75 Hz, og det går ikke an å forandre oppløsningen før frekvensen er satt til 60 Hz.

 

Kunne da bare laget en oppstartsfil som først forandret frekvensen til 60 Hz og deretter oppløsningen til 1280x1024.

Lenke til kommentar

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
×
×
  • Opprett ny...