Re: 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: Fri, 18 Feb 2005 09:46:59 -0500


Played around a little with Pack= since I don't know what it does for sure
and couldn't find out using Help

Most of my code is VB but I also have a C# library

I'm confused about the ByValArray, since I expect a return it seems like it
should be ByRefArray but that does not exists.
// [StructLayout(LayoutKind.Sequential, Pack=1, CharSet=CharSet.Auto)]

public struct PALETTEENTRY

{

public byte peRed;

public byte peGreen;

public byte peBlue;

public byte peFlags;

}

//[StructLayout(LayoutKind.Sequential, Pack=2, CharSet=CharSet.Auto)]

public struct LOGPALETTE

{

public short palVersion;

public short palNumEntries;

[MarshalAs(UnmanagedType.ByValArray, SizeConst=256)] public PALETTEENTRY[]
palPalEntry;

}

[DllImport("gdi32", CharSet=CharSet.Auto)] public static extern int
GetSystemPaletteEntries(HDC hdc, int wStartIndex, int wNumEntries, ref
PALETTEENTRY[] lpPaletteEntries);

"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message
news:uzMbXfYFFHA.1932@TK2MSFTNGP14.phx.gbl...
> >I've been trying to debug this but when it executes
> >GetSystemPaletteEntries
>>it bombs. I mean it just dies.
>
> How did you declare the functions and structures?
>
>
>
>
> Mattias
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.