uLib  User mode C/C++ extended API library for Win32 programmers.
Supplementary WinGDI APIs

Module Description

GDI related functions... (GdiUtil.cpp)

Groups

 FIXED 16.16 math support
 
 Color Support
 
 Font Support
 
 Display Context Support
 
 Bitmap Support
 
 Gradient Support
 
 Region Support
 
 XFORM Support
 

Macros

#define SYSHBR(id)   GetSysColorBrush( COLOR_##id )
 
#define SYSRGB(id)   GetSysColor( COLOR_##id )
 
#define BKGHBR(id)   (HBRUSH)( 1 + COLOR_##id )
 
#define RGBA(R, G, B, A)   ((COLORREF) ((BYTE)(R)|((WORD)((BYTE)(G))<<8)|(((DWORD)(BYTE)(B))<<16)|(((DWORD)(BYTE)(A))<<24)))
 
#define GetAValue(rgba)   ((BYTE)((COLORREF)(rgba) >> 24))
 
#define GetRGBValue(rgba)   ((COLORREF)((rgba) & 0x00FFFFFF))
 
#define R4_MASKBLT   MAKEROP4( SRCCOPY, DSTCOPY )
 
#define DSTCOPY   0x00AA0029L
 
#define VLine(dc, x, y1, y2)   Line( dc, x,y1, x,y2 )
 
#define HLine(dc, y, x1, x2)   Line( dc, x1,y, x2,y )
 
#define GetSystemPalette()   (HPALETTE)GetStockObject( DEFAULT_PALETTE )
 
#define GetPaletteLength(hPal)   GetPaletteEntries( hPal,0,0,NULL )
 
#define DeleteFontEx(h)   (HFONT) DeleteObjectEx( (HFONT)h )
 
#define DeletePenEx(h)   (HPEN) DeleteObjectEx( (HPEN)h )
 
#define DeleteBrushEx(h)   (HBRUSH) DeleteObjectEx( (HBRUSH)h )
 
#define DeleteBitmapEx(h)   (HBITMAP) DeleteObjectEx( (HBITMAP)h )
 
#define DeleteRegionEx(h)   (HRGN) DeleteObjectEx( (HRGN)h )
 

Functions

HGDIOBJ WINAPI DeleteObjectEx (HGDIOBJ hObj)
 
void WINAPI Line (HDC hdc, int x1, int y1, int x2, int y2)
 
void WINAPI DrawIsoTriangle (HDC hdc, int xOrg, int yOrg, int Radius, double Orientation)
 
void WINAPI GetIsoTriangleVertices (POINT *Vtx, int xOrg, int yOrg, int Radius, double Orientation)
 

Macro Definition Documentation

◆ SYSHBR

#define SYSHBR (   id)    GetSysColorBrush( COLOR_##id )

Definition at line 1726 of file UtilFunc.h.

◆ SYSRGB

#define SYSRGB (   id)    GetSysColor( COLOR_##id )

Definition at line 1727 of file UtilFunc.h.

◆ BKGHBR

#define BKGHBR (   id)    (HBRUSH)( 1 + COLOR_##id )

Use this for WNDCLASS::hbrBackground.

Note
[MSDN] Apps must NOT use a GetSysColorBrush as a window background brush,
since the system deletes background brushes when the class is unregistered.
(Alas, this restriction seems to have been lifted in later Windows versions.)

Definition at line 1734 of file UtilFunc.h.

◆ RGBA

#define RGBA (   R,
  G,
  B,
 
)    ((COLORREF) ((BYTE)(R)|((WORD)((BYTE)(G))<<8)|(((DWORD)(BYTE)(B))<<16)|(((DWORD)(BYTE)(A))<<24)))

COLORREF with MSB alpha channel. Format = 0xAARRGGBB.

Definition at line 1738 of file UtilFunc.h.

◆ GetAValue

#define GetAValue (   rgba)    ((BYTE)((COLORREF)(rgba) >> 24))

Get alpha from RGBA COLORREF value.

Definition at line 1740 of file UtilFunc.h.

◆ GetRGBValue

#define GetRGBValue (   rgba)    ((COLORREF)((rgba) & 0x00FFFFFF))

Get RGB from RGBA COLORREF value.

Definition at line 1741 of file UtilFunc.h.

◆ R4_MASKBLT

#define R4_MASKBLT   MAKEROP4( SRCCOPY, DSTCOPY )

Quaternary raster op for a standard MaskBlt().
See also CreateMaskBitmap().

Definition at line 1747 of file UtilFunc.h.

◆ DSTCOPY

#define DSTCOPY   0x00AA0029L

Ternary raster op: Copy destination to destination, i.e. NOP.
2nd argument for MAKEROP4 to leave background bits as-is.

Definition at line 1752 of file UtilFunc.h.

◆ VLine

#define VLine (   dc,
  x,
  y1,
  y2 
)    Line( dc, x,y1, x,y2 )

Definition at line 1756 of file UtilFunc.h.

◆ HLine

#define HLine (   dc,
  y,
  x1,
  x2 
)    Line( dc, x1,y, x2,y )

Definition at line 1757 of file UtilFunc.h.

◆ GetSystemPalette

#define GetSystemPalette ( )    (HPALETTE)GetStockObject( DEFAULT_PALETTE )

Definition at line 1761 of file UtilFunc.h.

◆ GetPaletteLength

#define GetPaletteLength (   hPal)    GetPaletteEntries( hPal,0,0,NULL )

Definition at line 1764 of file UtilFunc.h.

◆ DeleteFontEx

#define DeleteFontEx (   h)    (HFONT) DeleteObjectEx( (HFONT)h )

Definition at line 1771 of file UtilFunc.h.

◆ DeletePenEx

#define DeletePenEx (   h)    (HPEN) DeleteObjectEx( (HPEN)h )

Definition at line 1772 of file UtilFunc.h.

◆ DeleteBrushEx

#define DeleteBrushEx (   h)    (HBRUSH) DeleteObjectEx( (HBRUSH)h )

Definition at line 1773 of file UtilFunc.h.

◆ DeleteBitmapEx

#define DeleteBitmapEx (   h)    (HBITMAP) DeleteObjectEx( (HBITMAP)h )

Definition at line 1774 of file UtilFunc.h.

◆ DeleteRegionEx

#define DeleteRegionEx (   h)    (HRGN) DeleteObjectEx( (HRGN)h )

Definition at line 1775 of file UtilFunc.h.

Function Documentation

◆ DeleteObjectEx()

HGDIOBJ WINAPI DeleteObjectEx ( HGDIOBJ  hObj)

Delete a GDI object and return NULL on success, else hObj.

Definition at line 290 of file GdiUtil.cpp.

◆ Line()

void WINAPI Line ( HDC  hdc,
int  x1,
int  y1,
int  x2,
int  y2 
)

Draw a line, using the current pen.
(Simply combines MoveToEx and LineTo.)

Definition at line 506 of file GdiUtil.cpp.

◆ DrawIsoTriangle()

void WINAPI DrawIsoTriangle ( HDC  hdc,
int  xOrg,
int  yOrg,
int  Radius,
double  Orientation 
)

DrawIsoTriangle() draws an isosceles triangle using the current pen and brush.
See GetIsoTriangleVertices() for parameter details.

HBRUSH hbr = SelectBrush( hdc, GetStockBrush( HOLLOW_BRUSH ));
HPEN hpen = SelectPen( hdc, GetStockPen( WHITE_PEN ));
int x = rDisp.left + (rDisp.right - rDisp.left) / 2;
int y = rDisp.top + (rDisp.bottom - rDisp.top) / 2;
DrawIsoTriangle( hdc, x, y, 100, -M_PI/2.0 );
SelectPen( hdc, hpen );
SelectBrush( hdc, hbr );

Definition at line 529 of file GdiUtil.cpp.

◆ GetIsoTriangleVertices()

void WINAPI GetIsoTriangleVertices ( POINT *  Vtx,
int  xOrg,
int  yOrg,
int  Radius,
double  Orientation 
)

GetIsoTriangleVertices() computes the vertices of an isosceles triangle.

Parameters
Vtx[out] Three POINT array that recieves the vertices.
xOrgCircumcenter x coordinate.
yOrgCircumcenter y coordinate.
RadiusDistance from circumcenter to vertices.
OrientationDirection to first vertex, in radians.

Definition at line 512 of file GdiUtil.cpp.