Date: 02-16-2022
Return to Index
created by gbSnippets
'Graphic Objects =========================================================
Structure that defines a set of graphic objects:
-pen -brush -bitmap -font -palette -region -path
Object attributes:
Bitmap Size, in bytes; dimensions, in pixels; color-format; compression scheme; and so on.
Brush Style, color, pattern, and origin.
Palette Colors and size (or number of colors).
Font Typeface name, width, height, weight, character set, and so on.
Path Shape.
Pen Style, width, and color.
Region Location and dimensions.
When app creates DC, default objects are stored (no bitmap, no path)
GetCurrentObject - get handle to an object in a DC
GetObject - get info about object
hObject = GetCurrentObject(hDC,%Obj_Brush) 'logical bitmap/brush/palette/pen/dib
GetObject(hObject, Len(buf), Varptr(buf)) 'buf contains info about the object
SelectObject - selects object into a DC
Get/Set attributes of objects:
GetDCBrushColor
SetDCBrushColor
GetDCPenColor
SetDCPenColor
'Graphic Modes =========================================================
Modes: Background - BG mixing for bitmap/text
Drawing - FG mixing for pen/brush/bitmap/text
Mapping - mapping from logical/world space to the device
Polygon-Fill - how brush fills interior
Stretching - how colors are mixed when scaled
Mode API Background - GetBkMode / SetBkMode
Drawing - GetROP2 / SetROP2
Mapping - GetMapMode / SetMapMode
Polygon-Fill - GetPolyFillMode / SetPolyFillMode
Stretching - GetStretchBltMode / SetStretchBltMode
'DC Types =========================================================
Display - draw on video display
Printer - draw on printer
Memory (Compatible) - draw on bitmap
Information - retrieval of device data
'Display DC ----------------
BeginPaint() EndPaint()
GetDC() ReleaseDC()
'Printer DC ------------------
CreateDC DeleteDC
'Memory DC -----------------
Create a DC, create a bitmap for the DC, select the bitmap into the DC
CreateCompatibleDC - create DC with a default 1x1 bitmap
CreateBitmap + planes/bpp
CreateBitmapIndirect + planes/bpp
CreateCompatibleBitmap uses specified device to obtain planes/bpp
SelectObject - must select bitmap before drawing
'Information DC
Create a DC, then use GetCurrentObject/GetObject to retrieve default attributes
CreateIC - create info DC for a device
GetCurrentObject - get handle to device in DC
GetObject - get attributes
'Operations on Graphic Objects =========================================================
GetCurrentObject - handle to current object
GetObject - info about current object
EnumObjects - enumerate resident pens/brushes (printers only)
EnumFontFamiles - enumerate resident fonts (printers only)
'creating new objects
Bitmap CreateBitmap, CreateBitmapIndirect, CreateCompatibleBitmap
CreateDiscardableBitmap, CreateDIBitmap
Brush CreateBrushIndirect, CreateDIBPatternBrush, CreateDIBPatternBrushPt
CreateHatchBrush, CreatePatternBrush, CreateSolidBrush
Color Palette CreatePalette
Font CreateFont, CreateFontIndirect
Pen CreatePen, CreatePenIndirect, ExtCreatePen
Region CreateEllipticRgn, CreateEllipticRgnIndirect, CreatePolygonRgn
CreatePolyPolygonRgn, CreateRectRgn, CreateRectRgnIndirect
CreateRoundRectRgn
DeleteObject - to delete any object created from above
'Cancel Operation =========================================================
CancelDC
'Retrieving Device Data =========================================================
GetDeviceCapts - diplays/printers
DeviceCapabilities - printers only
'Save/Restore Device Context =========================================================
SaveDC
RestoreDC
'Stock OBjects
GetStockObject - gets handle to stock pens, brushes, fonts, or palettes
It is not necessary to delete stock objects by calling DeleteObject
When DC_Brush or DC_Pen are selected, their colors may be retrieved/changed:
GetDCBrushColor / SetDCBrushColor
GetDCPenColor / SetDCPenColor
Brushes: Black_Brush
DKGray_Brush
DC_Brush (solid white, can be changed with SetDCBrushColor)
Gray_Brush
Hollow_Brush (same as Null_Brush)
Null_Brush
LTGray_Brush
White_Brush
Pens: Black_Pen
DC_Pen (solid white, can be changed with SetDCPenColor
Null_Pen
White_Pen
Font: ANSI_Fixed_Font
ANSI_Var_Font
Device_Default_Font
Default_GUI_Font
OEM_Fixed_Font
System_Font (Tahoma)
System_Fixed_Font
Palette: Default_Palette
'gbs_00947
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm