Rubrik: System/Windows · Desktop/Bildschirm/Display | VB-Versionen: VB4, VB5, VB6 | 01.11.00 |
Eingestellte Farbtiefe ermitteln Diese Routine ermittelt die in der Systemsteuerung aktuell eingestellte Farbtiefe. | ||
Autor: Dieter Otter | Bewertung: | Views: 17.030 |
www.tools4vb.de | System: Win9x, WinNT, Win2k, WinXP, Win7, Win8, Win10, Win11 | Beispielprojekt auf CD |
Die nachfolgende Routine ermittelt die in der Systemsteuerung aktuell eingestellte Farbtiefe.
' Hier die benötigten API-Deklarationen Declare Function GetDeviceCaps Lib "gdi32" ( _ ByVal hDC As Long, _ ByVal nIndex As Long) As Long Declare Function GetDC Lib "user32" ( _ ByVal hwnd As Long) As Long Declare Function ReleaseDC Lib "user32" ( _ ByVal hwnd As Long, _ ByVal hDC As Long) As Long ' Die nachfolgende Routine ermittelt die aktuell ' eingestellte Farbtiefe Public Function Farbtiefe() As String Dim hDC As Long Dim cPixels As Long Dim lResult As Long Dim Text As String Const BITSPIXEL = 12 Const PLANES = 14 hDC = GetDC(0) cPixels = GetDeviceCaps(hDC, BITSPIXEL) * _ GetDeviceCaps(hDC, PLANES) lResult = ReleaseDC(0, hDC) Select Case cPixels Case 1: Text = "Monchrom" Case 4: Text = "16 Farben" Case 8: Text = "256 Farben" Case 16: Text = "HighColor, " _ + CStr(2 ^ cPixels) + " Farben" Case 32: Text = "TrueColor, " _ + CStr(2 ^ cPixels) + " Farben" End Select Farbtiefe = Text End Function