Using GetSystemPaletteEntries

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Just Me (groups_at_a-znet.com)
Date: 02/18/05


Date: Thu, 17 Feb 2005 19:55:49 -0500

I've been trying to debug this but when it executes GetSystemPaletteEntries
it bombs. I mean it just dies.

I set a breakpoint an try to get QuickWatch to evaluate
GetSystemPaletteEntries(...) and it say - Evaluation stopped..

Any ideas?

Thanks

Dim lHDCMemory As IntPtr

Dim lHBmp As IntPtr

Dim lHPal As IntPtr

Dim lHBmpPrev As IntPtr

Dim lHPalPrev As IntPtr

Dim lHDCSrc As IntPtr

Dim lRasterCapabilities As Integer

Dim lHasPalette As Boolean

Dim lPaletteSize As Integer

Dim lLogPal As GDI.LOGPALETTE

lHDCSrc = User.GetWindowDC(hWndSrc)

lHDCMemory = GDI.CreateCompatibleDC(lHDCSrc)

lHBmp = GDI.CreateCompatibleBitmap(lHDCSrc, widthSrc, heightSrc)

lHBmpPrev = GDI.SelectObject(lHDCMemory, lHBmp)

lRasterCapabilities = GDI.GetDeviceCaps(lHDCSrc, GDI.RASTERCAPS)

lHasPalette = (lRasterCapabilities And GDI.RC_PALETTE) = GDI.RC_PALETTE

lPaletteSize = GDI.GetDeviceCaps(lHDCSrc, User.SIZEPALETTE)

If lHasPalette AndAlso (lPaletteSize = 256) Then

lLogPal.palVersion = &H300S

lLogPal.palNumEntries = 256

ReDim lLogPal.palPalEntry(255)

Try

Dim zz As Integer = GDI.GetSystemPaletteEntries(lHDCSrc, 0, 256,
lLogPal.palPalEntry)

Catch ex As Exception

Console.WriteLine(ex.ToString)

End Try



Relevant Pages

  • Help with Marshaling an Array of Pointers from COM to Managed Objects
    ... Dim pDesktop As IntPtr ... Dim pidlRecyclebin As IntPtr ... ByRef pceltFetched As IntPtr) As UInt32 ... 'Requests a pointer to an interface that allows a client to enumerate ...
    (microsoft.public.dotnet.framework.interop)
  • Re: A little C# -> VB.Net conversion help?
    ... > lpSecurityAttributes As IntPtr, ByVal dwCreationDisposition As ... > Dim hDevice As IntPtr ... > Dim hFile As IntPtr ... > pAlloc = Marshal.AllocHGlobal) ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: A little C# -> VB.Net conversion help?
    ... > lpSecurityAttributes As IntPtr, ByVal dwCreationDisposition As ... > Dim hDevice As IntPtr ... > Dim hFile As IntPtr ... > pAlloc = Marshal.AllocHGlobal) ...
    (microsoft.public.dotnet.languages.vb)
  • Re: A little C# -> VB.Net conversion help?
    ... > lpSecurityAttributes As IntPtr, ByVal dwCreationDisposition As ... > Dim hDevice As IntPtr ... > Dim hFile As IntPtr ... > pAlloc = Marshal.AllocHGlobal) ...
    (microsoft.public.dotnet.general)
  • SetPrinter for network printers
    ... Public dmDeviceName As String ... Public pSecurityDescriptor As IntPtr ... Dim pPrinterInfo As IntPtr ...
    (microsoft.public.dotnet.languages.vb)