Table of Contents

Class Gdi

Namespace
CADability
Assembly
CADability.dll

P/Invoke declarations of the Windows GDI functions (gdi32.dll) with the related constants and structures which the OpenGL display and the text rendering need: choosing and setting the pixel format of a device context, creating fonts and querying character widths and kerning pairs. Only usable on Windows. Internal helper, not an entry point of the API.

public static class Gdi
Inheritance
Gdi
Inherited Members

Fields

PFD_DOUBLEBUFFER

The buffer is double-buffered. This flag and PFD_SUPPORT_GDI are mutually exclusive in the current generic implementation.

public const int PFD_DOUBLEBUFFER = 1

Field Value

int

PFD_DRAW_TO_BITMAP

The buffer can draw to a memory bitmap.

public const int PFD_DRAW_TO_BITMAP = 8

Field Value

int

PFD_DRAW_TO_WINDOW

The buffer can draw to a window or device surface.

public const int PFD_DRAW_TO_WINDOW = 4

Field Value

int

PFD_GENERIC_ACCELERATED

The pixel format is supported by a device driver that accelerates the generic implementation. If this flag is clear and the PFD_GENERIC_FORMAT flag is set, the pixel format is supported by the generic implementation only.

public const int PFD_GENERIC_ACCELERATED = 4096

Field Value

int

PFD_GENERIC_FORMAT

The pixel format is supported by the GDI software implementation, which is also known as the generic implementation. If this bit is clear, the pixel format is supported by a device driver or hardware.

public const int PFD_GENERIC_FORMAT = 64

Field Value

int

PFD_MAIN_PLANE

The layer is the main plane.

public const int PFD_MAIN_PLANE = 0

Field Value

int

PFD_NEED_PALETTE

The buffer uses RGBA pixels on a palette-managed device. A logical palette is required to achieve the best results for this pixel type. Colors in the palette should be specified according to the values of the cRedBits, cRedShift, cGreenBits, cGreenShift, cBluebits, and cBlueShift members. The palette should be created and realized in the device context before calling wglMakeCurrent(nint, nint).

public const int PFD_NEED_PALETTE = 128

Field Value

int

PFD_NEED_SYSTEM_PALETTE

Defined in the pixel format descriptors of hardware that supports one hardware palette in 256-color mode only. For such systems to use hardware acceleration, the hardware palette must be in a fixed order (for example, 3-3-2) when in RGBA mode or must match the logical palette when in color-index mode.

When this flag is set, you must call SetSystemPaletteUse in your program to force a one-to-one mapping of the logical palette and the system palette. If your OpenGL hardware supports multiple hardware palettes and the device driver can allocate spare hardware palettes for OpenGL, this flag is typically clear.

This flag is not set in the generic pixel formats.

public const int PFD_NEED_SYSTEM_PALETTE = 256

Field Value

int

PFD_STEREO

The buffer is stereoscopic. This flag is not supported in the current generic implementation.

public const int PFD_STEREO = 2

Field Value

int

PFD_SUPPORT_DIRECTDRAW

The buffer supports DirectDraw drawing.

public const int PFD_SUPPORT_DIRECTDRAW = 8192

Field Value

int

PFD_SUPPORT_GDI

The buffer supports GDI drawing. This flag and PFD_DOUBLEBUFFER are mutually exclusive in the current generic implementation.

public const int PFD_SUPPORT_GDI = 16

Field Value

int

PFD_SUPPORT_OPENGL

The buffer supports OpenGL drawing.

public const int PFD_SUPPORT_OPENGL = 32

Field Value

int

PFD_SWAP_COPY

Specifies the content of the back buffer in the double-buffered main color plane following a buffer swap. Swapping the color buffers causes the content of the back buffer to be copied to the front buffer. The content of the back buffer is not affected by the swap. PFD_SWAP_COPY is a hint only and might not be provided by a driver.

public const int PFD_SWAP_COPY = 1024

Field Value

int

PFD_SWAP_EXCHANGE

Specifies the content of the back buffer in the double-buffered main color plane following a buffer swap. Swapping the color buffers causes the exchange of the back buffer's content with the front buffer's content. Following the swap, the back buffer's content contains the front buffer's content before the swap. PFD_SWAP_EXCHANGE is a hint only and might not be provided by a driver.

public const int PFD_SWAP_EXCHANGE = 512

Field Value

int

PFD_SWAP_LAYER_BUFFERS

Indicates whether a device can swap individual layer planes with pixel formats that include double-buffered overlay or underlay planes. Otherwise all layer planes are swapped together as a group. When this flag is set, wglSwapLayerBuffers is supported.

public const int PFD_SWAP_LAYER_BUFFERS = 2048

Field Value

int

PFD_TYPE_COLORINDEX

Color-index pixels. Each pixel uses a color-index value.

public const int PFD_TYPE_COLORINDEX = 1

Field Value

int

PFD_TYPE_RGBA

RGBA pixels. Each pixel has four components in this order: red, green, blue, and alpha.

public const int PFD_TYPE_RGBA = 0

Field Value

int

Methods

ChoosePixelFormat(nint, ref PIXELFORMATDESCRIPTOR)

public static extern int ChoosePixelFormat(nint deviceContext, ref Gdi.PIXELFORMATDESCRIPTOR pixelFormatDescriptor)

Parameters

deviceContext nint
pixelFormatDescriptor Gdi.PIXELFORMATDESCRIPTOR

Returns

int

CreateCompatibleDC(nint)

public static extern nint CreateCompatibleDC(nint hdc)

Parameters

hdc nint

Returns

nint

CreateFont(int, int, int, int, int, bool, bool, bool, int, int, int, int, int, string)

public static extern nint CreateFont(int height, int width, int escapement, int orientation, int weight, bool italic, bool underline, bool strikeOut, int charSet, int outputPrecision, int clipPrecision, int quality, int pitchAndFamily, string typeFace)

Parameters

height int
width int
escapement int
orientation int
weight int
italic bool
underline bool
strikeOut bool
charSet int
outputPrecision int
clipPrecision int
quality int
pitchAndFamily int
typeFace string

Returns

nint

DeleteDC(nint)

public static extern bool DeleteDC(nint hdc)

Parameters

hdc nint

Returns

bool

DeleteObject(nint)

public static extern bool DeleteObject(nint objectHandle)

Parameters

objectHandle nint

Returns

bool

GetCharABCWidths(nint, uint, uint, ABC[])

[CLSCompliant(false)]
public static extern bool GetCharABCWidths(nint hdc, uint uFirstChar, uint uLastChar, Gdi.ABC[] lpabc)

Parameters

hdc nint
uFirstChar uint
uLastChar uint
lpabc ABC[]

Returns

bool

GetCharWidth32(nint, uint, uint, int[])

[CLSCompliant(false)]
public static extern bool GetCharWidth32(nint hdc, uint uFirstChar, uint uLastChar, int[] lpwidth)

Parameters

hdc nint
uFirstChar uint
uLastChar uint
lpwidth int[]

Returns

bool

GetKerningPairs(nint, int, KERNINGPAIR[])

public static extern int GetKerningPairs(nint hDC, int cPairs, Gdi.KERNINGPAIR[] lpkrnpair)

Parameters

hDC nint
cPairs int
lpkrnpair KERNINGPAIR[]

Returns

int

GetPixelFormat(nint)

public static extern int GetPixelFormat(nint deviceContext)

Parameters

deviceContext nint

Returns

int

SelectObject(nint, nint)

public static extern nint SelectObject(nint deviceContext, nint objectHandle)

Parameters

deviceContext nint
objectHandle nint

Returns

nint

SetPixelFormat(nint, int, ref PIXELFORMATDESCRIPTOR)

public static bool SetPixelFormat(nint deviceContext, int pixelFormat, ref Gdi.PIXELFORMATDESCRIPTOR pixelFormatDescriptor)

Parameters

deviceContext nint
pixelFormat int
pixelFormatDescriptor Gdi.PIXELFORMATDESCRIPTOR

Returns

bool

SwapBuffersFast(nint)

public static extern int SwapBuffersFast(nint deviceContext)

Parameters

deviceContext nint

Returns

int

_SetPixelFormat(nint, int, ref PIXELFORMATDESCRIPTOR)

[CLSCompliant(false)]
public static extern bool _SetPixelFormat(nint deviceContext, int pixelFormat, ref Gdi.PIXELFORMATDESCRIPTOR pixelFormatDescriptor)

Parameters

deviceContext nint
pixelFormat int
pixelFormatDescriptor Gdi.PIXELFORMATDESCRIPTOR

Returns

bool