|
-
Nov 28th, 2000, 02:03 PM
#1
Thread Starter
New Member
I have not found an API etc. that can actually change the color palette which will allow you to change the system color resolution.
For example if I wanted to change the system color palette from 256 colors to 16bit.
I have found plenty of API's that change screen resolutiuons or the Border & Background colors:
GetSystemMetrics
ChangeDisplaySettings
Any help would be appreciated.
Doug
-
Nov 28th, 2000, 02:49 PM
#2
Sure thing!
Code:
Private Const CCDEVICENAME As Long = 32
Private Const CCFORMNAME As Long = 32
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 GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long
Private Const DM_BITSPERPEL As Long = &H40000
Private Const DM_PELSWIDTH As Long = &H80000
Private Const DM_PELSHEIGHT As Long = &H100000
Private Const DM_DISPLAYFLAGS As Long = &H200000
Private Const CDS_FORCE As Long = &H80000000
Private Const BITSPIXEL As Long = 12
Private Const HORZRES As Long = 8
Private Const VERTRES As Long = 10
Private Sub Command1_Click()
Dim dm As DEVMODE
Dim lngWidth As Long
Dim lngHeight As Long
Dim lngBtPxl As Long
'Get current resolution
lngWidth = GetDeviceCaps(hdc, HORZRES)
lngHeight = GetDeviceCaps(hdc, VERTRES)
lngBtPxl = GetDeviceCaps(hdc, BITSPIXEL)
'If it's not 16bit then change it, but keep the same resolution (height and width)
If lngBtPxl <> 16 Then
With dm
.dmPelsWidth = lngWidth
.dmPelsHeight = lngHeight
.dmBitsPerPel = 16
.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL
.dmSize = LenB(dm)
End With
If ChangeDisplaySettings(dm, CDS_FORCE) <> 0 Then
MsgBox "Error! The video board may have problems displaying this resolution.", vbCritical, "Resolution Error"
Exit Sub
End If
End If
End Sub
-
Nov 28th, 2000, 05:06 PM
#3
Thread Starter
New Member
I tried this code and it appears to work; however the settings go away after I end the program.
Should I use some form of CDS_UPDATEREGISTRY
Any advice?
Doug
-
Nov 28th, 2000, 06:09 PM
#4
Yeap, you have to use CDS_UPDATEREGISTRY .
The reason I had CDS_FORCE is because I was teting something else as well.
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
|