got it!
I found the vb6 version kickin around in the API-Guide.
Made it work for the desktop with the right Device context.
It will take a few moments to convert this to .NET, so I'll post back.
For giggles, here is the vb6 example.
Code:Option Explicit Private Ramp1(0 To 255, 0 To 2) As Integer Private Ramp2(0 To 255, 0 To 2) As Integer Private Declare Function apiGetDeviceGammaRamp Lib "gdi32" Alias "GetDeviceGammaRamp" (ByVal hdc As Long, ByRef lpv As Any) As Long Private Declare Function apiSetDeviceGammaRamp Lib "gdi32" Alias "SetDeviceGammaRamp" (ByVal hdc As Long, ByRef lpv As Any) As Long Private Declare Function apiCopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long) As Long Private Declare Function apiGetWindowDC Lib "user32" Alias "GetWindowDC" (ByVal hwnd As Long) As Long Private Declare Function apiGetDesktopWindow Lib "user32" Alias "GetDesktopWindow" () As Long Private Sub Form_Load() Dim iCtr As Integer Dim lVal As Long Call apiGetDeviceGammaRamp(apiGetWindowDC(apiGetDesktopWindow), Ramp1(0, 0)) For iCtr = 0 To 255 lVal = Int2Lng(Ramp1(iCtr, 0)) Ramp2(iCtr, 0) = Lng2Int(Int2Lng(Ramp1(iCtr, 0)) / 2) Ramp2(iCtr, 1) = Lng2Int(Int2Lng(Ramp1(iCtr, 1)) / 2) Ramp2(iCtr, 2) = Lng2Int(Int2Lng(Ramp1(iCtr, 2)) / 2) Next iCtr Call apiSetDeviceGammaRamp(apiGetWindowDC(apiGetDesktopWindow), Ramp2(0, 0)) End Sub Private Sub Form_Unload(Cancel As Integer) Call apiSetDeviceGammaRamp(apiGetWindowDC(apiGetDesktopWindow), Ramp1(0, 0)) End Sub Public Function Int2Lng(IntVal As Integer) As Long Call apiCopyMemory(Int2Lng, IntVal, 2) End Function Public Function Lng2Int(Value As Long) As Integer Call apiCopyMemory(Lng2Int, Value, 2) End Function




Reply With Quote