Return to Index
created by gbSnippets
'MSDN Source: http://msdn.microsoft.com/en-us/library/aa969176%28VS.85%29.aspx
'Graphical Device Interface - generate graphical output for display on printer, monitors, ...
' - draw lines, curves, paths
' - fill closed figures
' - draw text
' - draw bitmap images
'GDI categories as defined by MSDN
' Bitmaps Fonts and Text Pens
' Brushes Lines and Curves Printing
' Clipping Metafiles Rectangles
' Colors Multiple Monitors Regions
' Coordinate ... OpenGL Windows Color System
' Device Contexts Painting Windows Image Acquisition
' Filled Shapes Paths Windows Multimedia
'Applications send output to device context (DC) for a device.
'API create a DC, returning a handle that is used in subsequent API calls
'There are 4 types of Device Context: display, printer, memory, information
Display 'Supports drawing operations On a video Display.
Printer 'Supports drawing operations On a printer Or plotter.
Memory 'Supports drawing operations On a Bitmap.
Information 'Supports the retrieval of device Data.
'Common function pairs used to get/release hDC:
* GetDC() - ReleaseDC() 'window DC
* BeginPaint() - EndPaint() 'window DC
* CreateCompatibleDC() - DeleteDC() 'memory DC
'Device Context Objects
Bitmaps 'Creates, manipulates (scale, scroll, rotate, and paint); stores images as files
Brushes 'Paints the interior of polygons, ellipses, and paths.
Fonts 'Draws text on video displays and other output devices.
Logical Palette 'A color palette
Paths 'One or more figures/shapes that are filled and/or outlined.
Pens 'Used to draw lines and curves
Regions 'Rectangle, polygon, ellipse (or combination of these)
'Region can be filled, painted, inverted, framed, and used to perform hit testing
'Device Context 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 ...
Pen 'style, width, and color
Region 'Location and dimensions.
'specify how colors are mixed, where output appears, how the output is scaled, ...
Background 'Defines how background colors are mixed with existing Window Or screen colors For Bitmap AND Text operations.
Drawing 'Defines how foreground colors are mixed with existing Window Or screen colors For pen, brush, Bitmap, AND Text operations.
Mapping 'Defines how graphics output is mapped From logical (Or world) space onto the Window, screen, Or printer Paper.
Polygon-fill 'Defines how the brush pattern is used to fill the interior of complex regions.
Stretching 'Defines how Bitmap colors are mixed with existing Window Or screen colors when the Bitmap is compressed (Or scaled down).
'An hDC can only contain one of each type of object (Bitmap, Font, pen...) at a time.
'When you select a new object, it will return the last one.
'When created, an hDC has default objects selected into it
'It's a good idea to store these when they are returned to you
'Then when you are completed drawing with the hDC select them back into it.
'You cannot delete an object while it is selected into an hDC.
'To clean up properly, reselect the default object back into the hDC. Then
'use DeleteObject to deleted the newly freed object.
'Drawing operations typically occur within WM_Paint, which is sent to the
'window when it is first displayed, when min/maximized, uncovered from
'having another window on top of it - letting the window know that it needs
'to redraw its contents.
'What you draw IS NOT permanent. It's only there until something else
'draws over it. Then, when it is visible again you have to redraw it.
'When handling WM_Paint, use BeginPaint/EndPaint
'When NOT handling WM_Paint, use GetDC
'For drawing or with bitmaps, create hDC in memory with CreteCompatibleDC
'(compatible with the color depth and display properties of the hDC for the Window)
'BitBlt copies from Memory DC to the Window DC
created by gbSnippets