Download Source Code

CGrDC Class Reference

Simple wrapper for HDC. Primarily provides static GDI functions. More...

#include <GrDC.h>

List of all members.

Public Member Functions

BOOL DottedBox (LPRECT pRect, COLORREF rgbPen, COLORREF rgbBck)
 Draws a dotted box.
BOOL FillHatchedPolygon (LPPOINT pt, DWORD pts, COLORREF bck, COLORREF lines, int hatch)
 Fills a polygon with a hatch.
BOOL DrawButton (BOOL bPressed, LPPOINT pt, DWORD pts, COLORREF color, HICON hIcon)
 Draws an irregular button shape.
BOOL FillSolidPolygon (LPPOINT pt, DWORD pts, COLORREF rgb)
 Fills a solid polygon.
BOOL Box3d (LPRECT pRect, DWORD size, COLORREF lt, COLORREF rb, BOOL bInvert=FALSE)
 Draws a 3D box.
BOOL RoundedBox3d (LPRECT pRect, DWORD size, COLORREF lt, COLORREF rb, BOOL bInvert=FALSE)
 Draws a 3D rectangle with rounded edges.
BOOL VertGradientFill (LPRECT pRect, COLORREF top, COLORREF bottom)
 Draws a vertical gradient.
BOOL HorzGradientFill (LPRECT pRect, COLORREF left, COLORREF right)
 Draws a horizontal gradient.
BOOL GradientFill (LPRECT pRect, COLORREF lefttop, COLORREF righttop, COLORREF leftbottom, COLORREF rightbottom)
 Draws a gradient that transitions in four directions.
BOOL FillSolidRect (LPRECT pRect, COLORREF rgb)
 Fills a rectangle with a solid color.
BOOL FillSolidEllipse (LPRECT pRect, COLORREF pen, COLORREF bck)
 Fills an ellipse with a solid color.
void Restore ()
 Restores default objects to encapsulated DC.
BOOL SelectObject (HFONT hFont)
 Selects a font in the the encapsulated DC.
BOOL SelectObject (HBRUSH hBrush)
 Selects a brush in to the encapsulated DC.
BOOL SelectObject (HPEN hPen)
 Selects a pen into the encapsulated DC.
BOOL GetRect (LPRECT pRect)
 Gets the size of the encapsulated DC.
BOOL ReleaseDC (HWND hWnd)
 Releases the encapsulated DC.
BOOL GetDC (HWND hWnd)
 Gets the DC for a window.
void Destroy ()
 Restores objects and releases the encapsulated DC.
 CGrDC ()
 Constructor.
 CGrDC (HDC hDC)
 Constructs an object encapsulating the specified DC.
 CGrDC (HDC hDC, BOOL bAutoDelete)
 Constructs object encapsulating specified DC.
 operator HDC ()
 Returns a pointer to the encapsulated Device Context.
HDC GetSafeHdc ()
 Returns a pointer to the encapsulated Device Context.
BOOL IsDC ()
 Returns non-zero if there is a valid encapsulated Device Context.
void Attach (HDC hDC)
 Encapsulates an existing Device Context.
void Detach ()
 Detaches from the encapsulated Device Context with out releasing it.
BOOL MoveTo (long x, long y, LPPOINT pt=NULL)
 Moves the GDI drawing caret to the specified position.
BOOL LineTo (long x, long y)
 Draws a line from the current GDI caret positino to the specified point.
BOOL PutPixel (long x, long y, COLORREF rgb)
 Plots a single pixel of the specified color.
void AutoDelete (BOOL b)
 Sets the Auto delete state.
BOOL FillHatchedRect (LPRECT pRect, COLORREF bck, COLORREF lines, int hatch)
 Fills in a rectangle with a hatch pattern.

Static Public Member Functions

static BOOL DottedBox (HDC hDC, LPRECT pRect, COLORREF rgbPen, COLORREF rgbBck)
 Draws a dotted box.
static BOOL FillHatchedPolygon (HDC hDC, LPPOINT pt, DWORD pts, COLORREF bck, COLORREF lines, int hatch)
 Fills a polygon with a hatch.
static BOOL DrawButton (HDC hDC, BOOL bPressed, LPPOINT pt, DWORD pts, COLORREF color, HICON hIcon)
 Draws an irregular button shape.
static BOOL FillSolidPolygon (HDC hDC, LPPOINT pt, DWORD pts, COLORREF rgb)
 Fills a solid polygon.
static BOOL Box3d (HDC hDC, LPRECT pRect, DWORD size, COLORREF lt, COLORREF rb, BOOL bInvert=FALSE)
 Draws a 3D box.
static BOOL RoundedBox3d (HDC hDC, LPRECT pRect, DWORD size, COLORREF lt, COLORREF rb, BOOL bInvert=FALSE)
 Draws a 3D rectangle with rounded edges.
static BOOL VertGradientFill (HDC hDC, LPRECT pRect, COLORREF top, COLORREF bottom)
 Draws a vertical gradient.
static BOOL HorzGradientFill (HDC hDC, LPRECT pRect, COLORREF left, COLORREF right)
 Draws a horizontal gradient.
static BOOL GradientFill (HDC hDC, LPRECT pRect, COLORREF lefttop, COLORREF righttop, COLORREF leftbottom, COLORREF rightbottom)
 Draws a gradient that transitions in four directions.
static BOOL FillSolidRect (HDC hDC, LPRECT pRect, COLORREF rgb)
 Fills a rectangle with a solid color.
static BOOL FillSolidEllipse (HDC hDC, LPRECT pRect, COLORREF pen, COLORREF bck)
 Fills an ellipse with a solid color.
static HICON CreateIcon (long w, long h, long lSrcW, long lSrcH, COLORREF bck, HDC hDC, HBITMAP hIconBmp, HBITMAP hIconMask)
 Creates an icon with the specified data.
static BOOL PtInPolygon (LPPOINT pt, LPPOINT ppt, DWORD pts)
 Checks to see if the specified point is within the polygon.
static double GetAngle (long x1, long y1, long x2, long y2)
 Returns the angle between the specified points.
static double GetAngle (double x1, double y1, double x2, double y2)
 Returns the angle between the specified points.
static BOOL InflatePolygon (LPPOINT pt, DWORD pts, double mag)
 Scales the size of the polygon by the specified ammount.
static BOOL GetPolygonRect (LPRECT pRect, LPPOINT pt, DWORD pts)
 Returns the smallest rectangle enclosing all specified polygon.
static BOOL InflatePolygon (LPPOINT pt, DWORD pts, long x, long y)
 Linearly inflates the size of a polygon.
static LPRECT AspectCorrect (LPRECT r1, long w, long h)
 Corrects the aspect ratio of a rectangle using the specified sizes.
static LPRECT AspectCorrect (LPRECT r1, LPRECT r2)
 Corrects the aspect ratio of a rectangle using the specified sizes.
static BOOL Center (LPRECT pRect, LPRECT pRef, BOOL x=TRUE, BOOL y=TRUE)
 Centers one rectangle within another.
static COLORREF ScaleColor (COLORREF c1, COLORREF c2, long scale)
 Scales between two colors.
static COLORREF ScaleColor (COLORREF col, long scale)
 Creates a shade of the specified color.
static BOOL Shade (LPBYTE pBuf, long lWidth, long lHeight, LPRECT pRect, COLORREF rgbShade)
 Shades the specified area of the video.
static BOOL ExFill (HDC hDc, LPRECT pInside, LPRECT pOutside, COLORREF rgb)
 Fills the excluded region of two rectangles.
static HCURSOR IconToCursor (HICON hIcon, long lxHotSpot, long lyHotSpot)
 Converts an icon into a cursor.
static BOOL Ellipse (HDC hDC, long sz, COLORREF rgb, LPPOINT pptCenter, long lRadius)
 Draws a circle using a center point and radius.
static BOOL ScalePoints (LPPOINT psrcPts, LPPOINT pdstPts, DWORD dwPts, LPRECT pSrc, LPRECT pDst)
 Scales the specified points.
static BOOL DrawSelectionPolygon (HDC hDC, LPPOINT pPts, DWORD dwPts, COLORREF rgbBck, COLORREF rgbHatch, DWORD dwTranslucency=5000)
 Draws a translucent polygon.
static BOOL DrawPolygonOutline (HDC hDC, LPRECT pRect, LPPOINT ppi, DWORD pts, COLORREF rgb)
 Draws the outline of a polygon.
static BOOL DrawSelectionBox (HDC hDC, LPRECT pRect, COLORREF rgbBck, COLORREF rgbHatch, DWORD dwTranslucency=5000)
 Draws a translucent rectangle.
static BOOL FillHatchedRect (HDC hDC, LPRECT pRect, COLORREF bck, COLORREF lines, int hatch)
 Fills in a rectangle with a hatch pattern.
static float GetAngleDif (float a1, float a2)
 Returns the minimum difference between two angles.
static HICON RotateIcon (HICON hIcon, float angle)
 Rotates the specified icon.
static BOOL DrawGrid (HDC hDC, LPRECT pRect, COLORREF rgb, long cx, long cy, long ox=0, long oy=0, int pentype=PS_SOLID)
 Draws a grid into the specified rectangle.
static BOOL GetIconRect (HICON hIcon, LPRECT pRect)
 Gets the size of an icon.
static HICON CreateDisabledIcon (HICON hIcon, COLORREF bck=RGB(0, 0, 0))
 Creates a disabled icon.
static HICON CreateMonoChromeIcon (HICON hIcon, COLORREF key=MAXDWORD, COLORREF bck=RGB(0, 0, 0))
 Creates a monochrome version of an icon.
static HICON LoadIcon (UINT uIcon, long cx=0, long cy=0)
 Loads icon resource.
static HICON LoadIcon (HINSTANCE hInstance, UINT uIcon, long cx=0, long cy=0)
 Loads icon resource.
static BOOL DrawIcon (HDC hDC, LPRECT pRect, HICON hIcon, long x=0, long y=0, BOOL bDisabled=FALSE)
 Draws the specified icon into a Device Context.
static BOOL Line (HDC hDC, COLORREF rgb, long w, long x1, long y1, long x2, long y2, int nStyle=PS_SOLID, COLORREF rgbBrush=MAXDWORD)
 Draws an arbitrary line.
static DWORD ahtodw (LPCTSTR pBuffer, DWORD dwBytes)
 Converts an ASCII hex string into a DWORD value.
static COLORREF GrayScale (COLORREF rgb)
 Returns grayscale representation of color.
static BOOL IsLightColor (COLORREF rgb)
 Returns non-zero if the specified color is a 'light' color.
static DWORD dwtohstr (DWORD num, LPSTR buf, DWORD index, DWORD pad=2, DWORD max=2)
 Converts a DWORD value into an ASCII hex string.
static LPCTSTR RgbToHtml (COLORREF rgb, LPSTR pHtml)
 Converts an RGB color value into the HTML representation.
static COLORREF HtmlToRgb (LPCTSTR pHtml)


Detailed Description

Simple wrapper for HDC. Primarily provides static GDI functions.

This class primarily provides basic GDI drawing functionality through its static member functions.


Constructor & Destructor Documentation

CGrDC::CGrDC HDC  hDC  ) 
 

Constructs an object encapsulating the specified DC.

Parameters:
[in] hDC - Handle of DC

CGrDC::CGrDC HDC  hDC,
BOOL  bAutoDelete
 

Constructs object encapsulating specified DC.

Parameters:
[in] hDC - Handle to DC
[in] bAutoDelete - Non-zero if DC should be released on object destruction.


Member Function Documentation

DWORD CGrDC::ahtodw LPCTSTR  pBuffer,
DWORD  dwBytes
[static]
 

Converts an ASCII hex string into a DWORD value.

Parameters:
[in] pBuffer - Buffer containing ASCII hex string
[in] dwBytes - Number of byes in pBuffer to convert
Returns:
DWORD value of converted string
See also:

LPRECT CGrDC::AspectCorrect LPRECT  r1,
LPRECT  r2
[static]
 

Corrects the aspect ratio of a rectangle using the specified sizes.

Parameters:
[in] r1 - Rectangle whose aspect ratio is corrected
[in] r2 - Reference aspect ratio
The width of r1 is scaled so the aspect ratio matches w x h of r2

Returns:
The pointer in r1
See also:

LPRECT CGrDC::AspectCorrect LPRECT  r1,
long  w,
long  h
[static]
 

Corrects the aspect ratio of a rectangle using the specified sizes.

Parameters:
[in] r1 - Rectangle whose aspect ratio is corrected
[in] w - Reference width
[in] h - Reference height
The width of r1 is scaled so the aspect ratio matches w x h

Returns:
Returns the pointer in r1
See also:

void CGrDC::Attach HDC  hDC  )  [inline]
 

Encapsulates an existing Device Context.

Parameters:
[in] hDC - Existing DC handle

void CGrDC::AutoDelete BOOL  b  )  [inline]
 

Sets the Auto delete state.

Parameters:
[in] b - Non-zero if encapsulated DC should be deleted on object destruction.

BOOL CGrDC::Box3d LPRECT  pRect,
DWORD  size,
COLORREF  lt,
COLORREF  rb,
BOOL  bInvert = FALSE
[inline]
 

Draws a 3D box.

Parameters:
[in] pRect - Size and position of the box
[in] size - Thickness of the box edges
[in] lt - Highlighted color of box
[in] rb - Shadowed color of box
[in] bInvert - Inverts the highlighted and shadowed colors.
Returns:
Non-zero if success
See also:

BOOL CGrDC::Box3d HDC  hDC,
LPRECT  pRect,
DWORD  size,
COLORREF  lt,
COLORREF  rb,
BOOL  bInvert = FALSE
[static]
 

Draws a 3D box.

Parameters:
[in] hDC - DC handle for drawing
[in] pRect - Size and position of the box
[in] size - Thickness of the box edges
[in] lt - Highlighted color of box
[in] rb - Shadowed color of box
[in] bInvert - Inverts the highlighted and shadowed colors.
Returns:
Non-zero if success
See also:

BOOL CGrDC::Center LPRECT  pRect,
LPRECT  pRef,
BOOL  x = TRUE,
BOOL  y = TRUE
[static]
 

Centers one rectangle within another.

Parameters:
[in] pRect - Rectangle to center
[in] pRef - Reference rectangle
[in] x - Non-zero to center horizontally
[in] y - Non-zero to center vertically
Returns:
Non-zero if success
See also:

HICON CGrDC::CreateDisabledIcon HICON  hIcon,
COLORREF  bck = RGB(0, 0, 0)
[static]
 

Creates a disabled icon.

Parameters:
[in] hIcon - Source icon
[in] bck - Shading color
Warning:
You must release this icon when done by calling DestroyIcon()
Returns:
Handle to newly created disabled icon
See also:

HICON CGrDC::CreateIcon long  w,
long  h,
long  lSrcW,
long  lSrcH,
COLORREF  bck,
HDC  hDC,
HBITMAP  hIconBmp,
HBITMAP  hIconMask
[static]
 

Creates an icon with the specified data.

Parameters:
[in] w - Width of the new icon
[in] h - Height of the new icon
[in] lSrcW - Width of the source images
[in] lSrcH - Height of the source images
[in] bck - Background color
[in] hDC - Handle to DC containing image
[in] hIconBmp - HBITMAP handle to icon image
[in] hIconMask - HBITMAP handle to icon mask
Returns:
HICON handle to icon
See also:

HICON CGrDC::CreateMonoChromeIcon HICON  hIcon,
COLORREF  key = MAXDWORD,
COLORREF  bck = RGB(0, 0, 0)
[static]
 

Creates a monochrome version of an icon.

Parameters:
[in] hIcon - Handle to source icon
[in] key - Foreground color
[in] bck - Background color
Warning:
You must release this icon when done by calling DestroyIcon()
Returns:
Handle to newly created mono-chrome icon
See also:

BOOL CGrDC::DottedBox LPRECT  pRect,
COLORREF  rgbPen,
COLORREF  rgbBck
[inline]
 

Draws a dotted box.

Parameters:
[in] pRect - Position of the dotted box
[in] rgbPen - Pen color
[in] rgbBck - Background color
Returns:
Non-zero if success
See also:

BOOL CGrDC::DottedBox HDC  hDC,
LPRECT  pRect,
COLORREF  rgbPen,
COLORREF  rgbBck
[static]
 

Draws a dotted box.

Parameters:
[in] hDC - DC handle for drawing
[in] pRect - Position of the dotted box
[in] rgbPen - Pen color
[in] rgbBck - Background color
Returns:
Non-zero if success
See also:

BOOL CGrDC::DrawButton BOOL  bPressed,
LPPOINT  pt,
DWORD  pts,
COLORREF  color,
HICON  hIcon
[inline]
 

Draws an irregular button shape.

Parameters:
[in] bPressed - Pressed state
[in] pt - Array of POINT structures
[in] pts - Number of points in pt
[in] color - Button color
[in] hIcon - Button icon
The first half of the points should be the top of the button, or the highlighted portion. The second half the points will be the bottom of the button, or the portion of the buttons edges in shadow.

Returns:
Non-zero if success
See also:

BOOL CGrDC::DrawButton HDC  hDC,
BOOL  bPressed,
LPPOINT  pt,
DWORD  pts,
COLORREF  color,
HICON  hIcon
[static]
 

Draws an irregular button shape.

Parameters:
[in] hDC - DC handle for drawing
[in] bPressed - Pressed state
[in] pt - Array of POINT structures
[in] pts - Number of points in pt
[in] color - Button color
[in] hIcon - Button icon
The first half of the points should be the top of the button, or the highlighted portion. The second half the points will be the bottom of the button, or the portion of the buttons edges in shadow.

Returns:
Non-zero if success
See also:

BOOL CGrDC::DrawGrid HDC  hDC,
LPRECT  pRect,
COLORREF  rgb,
long  cx,
long  cy,
long  ox = 0,
long  oy = 0,
int  pentype = PS_SOLID
[static]
 

Draws a grid into the specified rectangle.

Parameters:
[in] hDC - Handle to DC for drawing
[in] pRect - Rectangular area
[in] rgb - Color of the grid
[in] cx - Horizontal spacing between grid lines
[in] cy - Vertical spacing between grid lines
[in] ox - Horizontal offset of grid lines
[in] oy - Vertical offset of grid lines
[in] pentype - GDI pen type
Returns:
Non-zero if success
See also:

BOOL CGrDC::DrawIcon HDC  hDC,
LPRECT  pRect,
HICON  hIcon,
long  x = 0,
long  y = 0,
BOOL  bDisabled = FALSE
[static]
 

Draws the specified icon into a Device Context.

Parameters:
[in] hDC - Handle to DC for drawing
[in] pRect - Position and size to draw icon
[in] hIcon - Handle to icon
[in] x - If pRect is NULL, the horizontal position of icon
[in] y - If pRect is NULL, the vertical position of the icon
[in] bDisabled - Non-zero to draw disabled version of icon
Returns:
Non-zero if success
See also:

BOOL CGrDC::DrawPolygonOutline HDC  hDC,
LPRECT  pRect,
LPPOINT  ppi,
DWORD  pts,
COLORREF  rgb
[static]
 

Draws the outline of a polygon.

Parameters:
[in] hDC - Handle to DC for drawing
[in] pRect - Size of DC in hDC
[in] ppi - POINT array defining the polygon
[in] pts - number of points in ppi
[in] rgb - Color of outline
Returns:
Non-zero if success
See also:

BOOL CGrDC::DrawSelectionBox HDC  hDC,
LPRECT  pRect,
COLORREF  rgbBck,
COLORREF  rgbHatch,
DWORD  dwTranslucency = 5000
[static]
 

Draws a translucent rectangle.

Parameters:
[in] hDC - DC handle for drawing
[in] pRect - Rectangle defining selection area
[in] rgbBck - Color of the background
[in] rgbHatch - Color of the hatch
[in] dwTranslucency - Translucency 0 = Solid, 10000 = Invisible.
Returns:
Non-zero if success
See also:

BOOL CGrDC::DrawSelectionPolygon HDC  hDC,
LPPOINT  pPts,
DWORD  dwPts,
COLORREF  rgbBck,
COLORREF  rgbHatch,
DWORD  dwTranslucency = 5000
[static]
 

Draws a translucent polygon.

Parameters:
[in] hDC - DC handle for drawing
[in] pPts - Array of POINT structures defining the polygon
[in] dwPts - Number of structures in pPts
[in] rgbBck - Color of the background
[in] rgbHatch - Color of the hatch
[in] dwTranslucency - Translucency 0 = Solid, 10000 = Invisible.
Useful for highlighting an irregularly shaped area

Returns:
Non-zero if success
See also:

DWORD CGrDC::dwtohstr DWORD  num,
LPSTR  buf,
DWORD  index,
DWORD  pad = 2,
DWORD  max = 2
[static]
 

Converts a DWORD value into an ASCII hex string.

Parameters:
[in] num - DWORD value of number to convert
[in] buf - Buffer that receives ASCII string
[in] index - Offset into buffer to start copy
[in] pad - Minimum number of characters to copy
[in] max - Maximum number of characters to copy
Returns:
See also:

BOOL CGrDC::Ellipse HDC  hDC,
long  sz,
COLORREF  rgb,
LPPOINT  pptCenter,
long  lRadius
[static]
 

Draws a circle using a center point and radius.

Parameters:
[in] hDC - Handle to DC for drawing
[in] sz - Size of the border
[in] rgb - Color of ellipse
[in] pptCenter - Center point
[in] lRadius - Radius
Returns:
Non-zero if success
See also:

BOOL CGrDC::ExFill HDC  hDc,
LPRECT  pInside,
LPRECT  pOutside,
COLORREF  rgb
[static]
 

Fills the excluded region of two rectangles.

Parameters:
[in] hDc - Handle to DC for drawing
[in] pInside - Area to exclude
[in] pOutside - Area to fill
[in] rgb - Color of fill
This function fills the area that is within pOutside but not within pInside. This is usually used when displaying an aspect corrected image within a defined rectangle. It's faster than filling the entire background.

For the below instances, this function fills the area marked with '*'.

         pOutside
        ----------------------
        |********************|
        |****-----------*****|
        |****| pInside |*****|
        |****|         |*****|
        |****|         |*****|
        |****|         |*****|
        |****-----------*****|
        |********************|
        ----------------------

Returns:
Non-zero if success
See also:

BOOL CGrDC::FillHatchedPolygon LPPOINT  pt,
DWORD  pts,
COLORREF  bck,
COLORREF  lines,
int  hatch
[inline]
 

Fills a polygon with a hatch.

Parameters:
[in] pt - Pointer to point array
[in] pts - Number of points in pt
[in] bck - Background color
[in] lines - Hatch line colors
[in] hatch - Hatch style
Returns:
Non-zero if success
See also:

BOOL CGrDC::FillHatchedPolygon HDC  hDC,
LPPOINT  pt,
DWORD  pts,
COLORREF  bck,
COLORREF  lines,
int  hatch
[static]
 

Fills a polygon with a hatch.

Parameters:
[in] hDC - DC handle for drawing
[in] pt - Pointer to point array
[in] pts - Number of points in pt
[in] bck - Background color
[in] lines - Hatch line colors
[in] hatch - Hatch style
Returns:
Non-zero if success
See also:

BOOL CGrDC::FillHatchedRect LPRECT  pRect,
COLORREF  bck,
COLORREF  lines,
int  hatch
[inline]
 

Fills in a rectangle with a hatch pattern.

Parameters:
[in] pRect - Rectangle area
[in] bck - Background color
[in] lines - Color of hatch lines
[in] hatch - Type of hatch
Returns:
Non-zero if success
See also:

BOOL CGrDC::FillHatchedRect HDC  hDC,
LPRECT  pRect,
COLORREF  bck,
COLORREF  lines,
int  hatch
[static]
 

Fills in a rectangle with a hatch pattern.

Parameters:
[in] hDC - Handle to DC for drawing
[in] pRect - Rectangle area
[in] bck - Background color
[in] lines - Color of hatch lines
[in] hatch - Type of hatch
Returns:
Non-zero if success
See also:

BOOL CGrDC::FillSolidEllipse LPRECT  pRect,
COLORREF  pen,
COLORREF  bck
[inline]
 

Fills an ellipse with a solid color.

Parameters:
[in] pRect - Position and size of ellipse area
[in] pen - Color of border
[in] bck - Fill color
Returns:
Non-zero if success
See also:

BOOL CGrDC::FillSolidEllipse HDC  hDC,
LPRECT  pRect,
COLORREF  pen,
COLORREF  bck
[static]
 

Fills an ellipse with a solid color.

Parameters:
[in] hDC - DC handle for drawing
[in] pRect - Position and size of ellipse area
[in] pen - Color of border
[in] bck - Fill color
Returns:
Non-zero if success
See also:

BOOL CGrDC::FillSolidPolygon LPPOINT  pt,
DWORD  pts,
COLORREF  rgb
[inline]
 

Fills a solid polygon.

Parameters:
[in] pt - Array of POINT structures
[in] pts - Number of structures in pt
[in] rgb - Fill color
Returns:
Non-zero if success
See also:

BOOL CGrDC::FillSolidPolygon HDC  hDC,
LPPOINT  pt,
DWORD  pts,
COLORREF  rgb
[static]
 

Fills a solid polygon.

Parameters:
[in] hDC - DC handle for drawing
[in] pt - Array of POINT structures
[in] pts - Number of structures in pt
[in] rgb - Fill color
Returns:
Non-zero if success
See also:

BOOL CGrDC::FillSolidRect LPRECT  pRect,
COLORREF  rgb
[inline]
 

Fills a rectangle with a solid color.

Parameters:
[in] pRect - Position and size of area to fill
[in] rgb - Color to fill area
Returns:
Non-zero if success
See also:

BOOL CGrDC::FillSolidRect HDC  hDC,
LPRECT  pRect,
COLORREF  rgb
[static]
 

Fills a rectangle with a solid color.

Parameters:
[in] hDC - DC handle for drawing
[in] pRect - Position and size of area to fill
[in] rgb - Color to fill area
Returns:
Non-zero if success
See also:

double CGrDC::GetAngle double  x1,
double  y1,
double  x2,
double  y2
[static]
 

Returns the angle between the specified points.

Parameters:
[in] x1 - Horizontal offset of first point
[in] y1 - Vertical offset of first point
[in] x2 - Horizontal offset of second point
[in] y2 - Vertical offset of second point
Returns:
Angle between the points
See also:

double CGrDC::GetAngle long  x1,
long  y1,
long  x2,
long  y2
[static]
 

Returns the angle between the specified points.

Parameters:
[in] x1 - Horizontal offset of first point
[in] y1 - Vertical offset of first point
[in] x2 - Horizontal offset of second point
[in] y2 - Vertical offset of second point
Returns:
Angle between the points
See also:

float CGrDC::GetAngleDif float  a1,
float  a2
[static]
 

Returns the minimum difference between two angles.

Parameters:
[in] a1 - First angle in degrees
[in] a2 - Second angle in degrees
Returns:
Minimum difference between the two angles
See also:

BOOL CGrDC::GetDC HWND  hWnd  ) 
 

Gets the DC for a window.

Parameters:
[in] hWnd - Window handle
Returns:
Non-zero if success
See also:

BOOL CGrDC::GetIconRect HICON  hIcon,
LPRECT  pRect
[static]
 

Gets the size of an icon.

Parameters:
[in] hIcon - Valid icon handle
[in] pRect - Receives the size of the icon
Returns:
Non-zero if success
See also:

BOOL CGrDC::GetPolygonRect LPRECT  pRect,
LPPOINT  pt,
DWORD  pts
[static]
 

Returns the smallest rectangle enclosing all specified polygon.

Parameters:
[in] pRect - Receives the enclosing rectangle
[in] pt - Array of POINT structures defining the polygon
[in] pts - Number of structures in pt
Returns:
Non-zero if success
See also:

BOOL CGrDC::GetRect LPRECT  pRect  ) 
 

Gets the size of the encapsulated DC.

Parameters:
[in] pRect - Receives the size of the DC
Returns:
Non-zero if success
See also:

BOOL CGrDC::GradientFill LPRECT  pRect,
COLORREF  lefttop,
COLORREF  righttop,
COLORREF  leftbottom,
COLORREF  rightbottom
[inline]
 

Draws a gradient that transitions in four directions.

Parameters:
[in] pRect - Position and size of the gradient
[in] lefttop - Color at the top-left of gradient
[in] righttop - Color at the top-right of the gradient
[in] leftbottom - Color at the bottom-left of the gradient
[in] rightbottom - Color at the bottom-right of the gradient
This function colors a rectangular area, smoothly transitioning horizontally from the left color to the right color and vertically from the top color to the bottom color.

Returns:
Non-zero if success
See also:

BOOL CGrDC::GradientFill HDC  hDC,
LPRECT  pRect,
COLORREF  lefttop,
COLORREF  righttop,
COLORREF  leftbottom,
COLORREF  rightbottom
[static]
 

Draws a gradient that transitions in four directions.

Parameters:
[in] hDC - DC handle for drawing
[in] pRect - Position and size of the gradient
[in] lefttop - Color at the top-left of gradient
[in] righttop - Color at the top-right of the gradient
[in] leftbottom - Color at the bottom-left of the gradient
[in] rightbottom - Color at the bottom-right of the gradient
This function colors a rectangular area, smoothly transitioning horizontally from the left color to the right color and vertically from the top color to the bottom color.

Returns:
Non-zero if success
See also:

static COLORREF CGrDC::GrayScale COLORREF  rgb  )  [inline, static]
 

Returns grayscale representation of color.

Parameters:
[in] rgb - Color to convert to grayscale
Fast Appx       - Gray scale = ( Green + Green + Red + Blue ) >> 2
SMPTE-C         - Gray scale = Y = ( .298912 * Red + .586611 * Green + .114478 * Blue )
Rec 601-1       - Gray scale = Y = ( 299 * Red + 587 * Green + 114 * Blue ) / 1000
Rec 709         - Gray scale = Y = ( 213 * Red + 715 * Green + 72 * Blue ) / 1000
ITU standard    - Gray scale = Y = ( 222 * Red + 707 * Green + 71 * Blue ) / 1000
Microsoft       - Gray scale = Green |or| Gray scale = ( Red + Green + Blue ) / 3

+-----------------------------+----------------+
|Scheme                       |Luminosity level|
+-----------------------------+----------------+
|Gray=Green                   |        1       |
|Gray=ITU (D65)               |        2       |
|Gray=Rec 709 (D65)           |        3       |
|Gray=Rec 601-1 (C illuminant)|        4       |
|Gray=(Red+Green+Blue)/3      |        5       |
+-----------------------------+----------------+

Currently using ITU standard

Returns:
Grayscale representation of color value in rgb
See also:

BOOL CGrDC::HorzGradientFill LPRECT  pRect,
COLORREF  left,
COLORREF  right
[inline]
 

Draws a horizontal gradient.

Parameters:
[in] pRect - Size and position of the box
[in] left - Color at the left of the gradient
[in] right - Color at the right of the gradient
This function colors a rectangular area, smoothly transitioning horizontally from the left color to the right color.

Returns:
Non-zero if success
See also:

BOOL CGrDC::HorzGradientFill HDC  hDC,
LPRECT  pRect,
COLORREF  left,
COLORREF  right
[static]
 

Draws a horizontal gradient.

Parameters:
[in] hDC - DC handle for drawing
[in] pRect - Size and position of the box
[in] left - Color at the left of the gradient
[in] right - Color at the right of the gradient
This function colors a rectangular area, smoothly transitioning horizontally from the left color to the right color.

Returns:
Non-zero if success
See also:

COLORREF CGrDC::HtmlToRgb LPCTSTR  pHtml  )  [static]
 

Parameters:
[in] pHtml - HTML value, such as #FF00FF
Returns:
RGB value such as RGB( 255, 0, 255 )
See also:
RgbToHtml()

HCURSOR CGrDC::IconToCursor HICON  hIcon,
long  lxHotSpot,
long  lyHotSpot
[static]
 

Converts an icon into a cursor.

Parameters:
[in] hIcon - Icon to convert
[in] lxHotSpot - Horizontal hot spot for cursor
[in] lyHotSpot - Vertical hot spot for cursor
Warning:
You must release this cursor when done by calling DestroyCursor()
Returns:
Handle to newly created cursor
See also:

BOOL CGrDC::InflatePolygon LPPOINT  pt,
DWORD  pts,
long  x,
long  y
[static]
 

Linearly inflates the size of a polygon.

Parameters:
[in] pt - Array of POINT structures defining the polygon
[in] pts - Number of structues in pt
[in] x - Amount to add to x value of polygon points
[in] y - Amount to add to y value of polygon points
This function calculates the center point of the specified polygon. Subtracts x from points to the left of the center point. Adds x to points to the right of the center point. Subtracts y from points to the top of the center point. Adds y to points to the bottom of the center point.

Returns:
Non-zero if success
See also:

BOOL CGrDC::InflatePolygon LPPOINT  pt,
DWORD  pts,
double  mag
[static]
 

Scales the size of the polygon by the specified ammount.

Parameters:
[in] pt - Array of POINT structures defining the polygon
[in] pts - Number of structures in pt
[in] mag - Scaling factor.
  • 1 = No scaling
  • .5 = half size
  • 2 = double size
  • etc...
Returns:
See also:

BOOL CGrDC::IsLightColor COLORREF  rgb  )  [static]
 

Returns non-zero if the specified color is a 'light' color.

Parameters:
[in] rgb - Color to analyze
Returns:
Non-zero if light color
See also:

BOOL CGrDC::Line HDC  hDC,
COLORREF  rgb,
long  w,
long  x1,
long  y1,
long  x2,
long  y2,
int  nStyle = PS_SOLID,
COLORREF  rgbBrush = MAXDWORD
[static]
 

Draws an arbitrary line.

Parameters:
[in] hDC - Handle to DC for drawing
[in] rgb - Color of line to draw
[in] w - Line width
[in] x1 - Horzontal offset of line start
[in] y1 - Vertical offset of line start
[in] x2 - Horzontal offset of line end
[in] y2 - Vertical offset of line end
[in] nStyle - Line style
[in] rgbBrush - Color of background
Returns:
Non-zero if success
See also:

BOOL CGrDC::LineTo long  x,
long  y
[inline]
 

Draws a line from the current GDI caret positino to the specified point.

Parameters:
[in] x - Horizontal endpoint of line
[in] y - Vertical endpoint of line
Returns:
Non-zero if success
See also:

static HICON CGrDC::LoadIcon HINSTANCE  hInstance,
UINT  uIcon,
long  cx = 0,
long  cy = 0
[inline, static]
 

Loads icon resource.

Parameters:
[in] hInstance - Module instance handle containing the icon
[in] uIcon - UINT resource id
[in] cx - Desired horizontal size of the icon
[in] cy - Desired vertical size of the icon
Warning:
You must release this icon when done by calling DestroyIcon()
Returns:
Handle to newly created icon
See also:

static HICON CGrDC::LoadIcon UINT  uIcon,
long  cx = 0,
long  cy = 0
[inline, static]
 

Loads icon resource.

Parameters:
[in] uIcon - UINT resource id
[in] cx - Desired horizontal size of the icon
[in] cy - Desired vertical size of the icon
Warning:
You must release this icon when done by calling DestroyIcon()
Returns:
Handle to newly created icon
See also:

BOOL CGrDC::MoveTo long  x,
long  y,
LPPOINT  pt = NULL
[inline]
 

Moves the GDI drawing caret to the specified position.

Parameters:
[in] x - Horizontal offset
[in] y - Vertical offset
[in] pt - Optional variable to receive previous position.
Returns:
Non-zero if success.
See also:

BOOL CGrDC::PtInPolygon LPPOINT  pt,
LPPOINT  ppt,
DWORD  pts
[static]
 

Checks to see if the specified point is within the polygon.

Parameters:
[in] pt - Point to check
[in] ppt - Array of POINT structures defining the polygon
[in] pts - Number of structures in ppt
Returns:
Non-zero if the point is in the polygon.
See also:

BOOL CGrDC::PutPixel long  x,
long  y,
COLORREF  rgb
[inline]
 

Plots a single pixel of the specified color.

Parameters:
[in] x - Horizontal offset of pixel
[in] y - Vertical offset of pixel
[in] rgb - Color of pixel
This is not a particularly fast pixel plotting function and should be used wisely.

Returns:
Non-zero if success
See also:

BOOL CGrDC::ReleaseDC HWND  hWnd  ) 
 

Releases the encapsulated DC.

Parameters:
[in] hWnd - Window that owns the DC
Returns:
See also:

LPCTSTR CGrDC::RgbToHtml COLORREF  rgb,
LPSTR  pHtml
[static]
 

Converts an RGB color value into the HTML representation.

Parameters:
[in] rgb - RGB value, such as RGB( 255, 0, 255 )
[in] pHtml - HTML value, such as #FF00FF
Returns:
See also:
HtmlToRgb()

HICON CGrDC::RotateIcon HICON  hIcon,
float  angle
[static]
 

Rotates the specified icon.

Parameters:
[in] hIcon - Source icon
[in] angle - Angle to rotate in degrees
Warning:
You must release this icon when done by calling DestroyIcon()
Returns:
HICON handle to newly created rotated icon
See also:

BOOL CGrDC::RoundedBox3d LPRECT  pRect,
DWORD  size,
COLORREF  lt,
COLORREF  rb,
BOOL  bInvert = FALSE
[inline]
 

Draws a 3D rectangle with rounded edges.

Parameters:
[in] pRect - Size and position of rectangle
[in] size - Thickness of the rectangle edges.
[in] lt - Hightlighted color of box
[in] rb - Shadowed color of box
[in] bInvert - Inverts the highlighted and shadowed colors.
Returns:
Non-zero if success
See also:

BOOL CGrDC::RoundedBox3d HDC  hDC,
LPRECT  pRect,
DWORD  size,
COLORREF  lt,
COLORREF  rb,
BOOL  bInvert = FALSE
[static]
 

Draws a 3D rectangle with rounded edges.

Parameters:
[in] hDC - DC handle for drawing
[in] pRect - Size and position of rectangle
[in] size - Thickness of the rectangle edges.
[in] lt - Hightlighted color of box
[in] rb - Shadowed color of box
[in] bInvert - Inverts the highlighted and shadowed colors.
Returns:
Non-zero if success
See also:

COLORREF CGrDC::ScaleColor COLORREF  col,
long  scale
[static]
 

Creates a shade of the specified color.

Parameters:
[in] col - Color
[in] scale - Shade weight. Range is -255, 255.
This function should have been called Shade(). It creates a lighter or darker shade of a color depending on the weight.

If scale is -100, returns a color 100 points darker than col If scale is 100, returns a color 100 points lighter than col If scale is 0, returns col

This function always returns the same color in a different shade.

Returns:
See also:

COLORREF CGrDC::ScaleColor COLORREF  c1,
COLORREF  c2,
long  scale
[static]
 

Scales between two colors.

Parameters:
[in] c1 - First color
[in] c2 - Second color
[in] scale - Blending weight of each color. Range is 0 to 1000
This function should probably have been called Blend(). It blends two colors together using scale as a weight.

If scale is 0, returns c1 If scale is 1000 returns c2 If scale is 500 returns a 50% blend of c1 and c2 etc...

Returns:
See also:

BOOL CGrDC::ScalePoints LPPOINT  psrcPts,
LPPOINT  pdstPts,
DWORD  dwPts,
LPRECT  pSrc,
LPRECT  pDst
[static]
 

Scales the specified points.

Parameters:
[in] psrcPts - Array of source POINT structures
[in] pdstPts - Array of destination POINT structures
[in] dwPts - Number of points
[in] pSrc - Source rect
[in] pDst - Destination rect
Usefull for scaling points into another bounding rectangle.

Returns:
Non-zero if success
See also:

BOOL CGrDC::SelectObject HPEN  hPen  ) 
 

Selects a pen into the encapsulated DC.

Parameters:
[in] hPen - Pen to select
Returns:
Non-zero if success
See also:

BOOL CGrDC::SelectObject HBRUSH  hBrush  ) 
 

Selects a brush in to the encapsulated DC.

Parameters:
[in] hBrush - Brush to select
Returns:
Non-zero if success
See also:

BOOL CGrDC::SelectObject HFONT  hFont  ) 
 

Selects a font in the the encapsulated DC.

Parameters:
[in] hFont - Font to select
Returns:
Non-zero if success
See also:

BOOL CGrDC::Shade LPBYTE  pBuf,
long  lWidth,
long  lHeight,
LPRECT  pRect,
COLORREF  rgbShade
[static]
 

Shades the specified area of the video.

Parameters:
[in] pBuf - Pointer to the video buffer
[in] lWidth - Width of the video buffer
[in] lHeight - Height of the video buffer
[in] pRect - Area to shade
[in] rgbShade - Color to shade the area. Color component values should be less than 127.
Makes a nice background for drawing text on top of video.

Returns:
Non-zero if success
See also:

BOOL CGrDC::VertGradientFill LPRECT  pRect,
COLORREF  top,
COLORREF  bottom
[inline]
 

Draws a vertical gradient.

Parameters:
[in] pRect - Size and position of the box
[in] top - Color at the top of the gradient
[in] bottom - Color at the bottom of the gradient
This function colors a rectangular area, smoothly transitioning vertically from the top color to the bottom color.

Returns:
Non-zero if success
See also:

BOOL CGrDC::VertGradientFill HDC  hDC,
LPRECT  pRect,
COLORREF  top,
COLORREF  bottom
[static]
 

Draws a vertical gradient.

Parameters:
[in] hDC - DC handle for drawing
[in] pRect - Size and position of the box
[in] top - Color at the top of the gradient
[in] bottom - Color at the bottom of the gradient
This function colors a rectangular area, smoothly transitioning from the top color to the bottom color.

Returns:
Non-zero if success
See also:


The documentation for this class was generated from the following files:
  • inc/GrDC.h
  • GrDC.cpp
Copyright Robert Umbehant
This documentation is covered by the LGPL