CDC
The base class of the Environment class of all devices. It encapsulates all the drawing functions of GDI and can be directly accessed.
Context of the entire display or non-Display Device (such as a printer)
Cpaintdc
Cpaintdc is used to redraw the Drawing Output of the message (wm_paint) in the response window.
You can also operate non-customer zones.
Cclientdc
It represents the device environment of the window customer area. It is generally used when responding to non-window messages and drawing the customer area.
This class
Cwindowdc
Represents the device environment of the entire window, including the customer and non-customer areas; unless you need to draw a window border and
Button, otherwise it is generally not used
Cmetafiledc
A device environment that represents a Windows Metafile. A Windows Metafile contains a series of images.
You can use these commands to create images.
Various Painting operations can be recorded in a Metafile.
Color settings
If the video card supports this function, you can use the colorref data type to define more than 16 million color categories.
Cpalette class
Encapsulate the GDI palette. Contains the available color information of the system. It is an interface for applications and color output device environments (such as monitors.
Crgn type
Encapsulate the GDI region. An area is a polygon or elliptical area in the window. Crgn is used for area operations in a device environment (usually a window). It is usually used together with member functions related to cropping (clipping) in the CDC class.
Cpen * penold, pennew; <br/> cbrush * brushold, brushnew; </P> <p> // select inventory black paint brush <br/> penold = (cpen *) PDC-> selectstockobject (black_pen); </P> <p> // select an inventory light gray paint brush <br/> brushold = (cbrush *) PDC-> selectstockobject (ltgray_brush ); <br/> PDC-> rectangle (100,100,300,300); </P> <p> // associate the GDI inventory object <br/> pennew. createstockobject (white_pen); <br/> PDC-> SelectObject (& pennew); <br/> PDC-> moveTo (100,100 ); <br/> PDC-> lineto (300,300); <br/> PDC -> MoveTo (100,300); <br/> PDC-> lineto (300,100 ); </P> <p> // restore the default GDI object of the System <br/> PDC-> SelectObject (penold); <br/> PDC-> SelectObject (brushold ); </P> <p> pennew. deleteobject (); </P> <p> // create a solid paint brush <br/> cbrush * Brush = new cbrush; <br/> brush-> createsolidbrush (RGB (255, 0, 0); <br/> PDC-> SelectObject (Brush ); <br/> PDC-> rectangle (400,400,500,500); </P> <p> // creates a shadow painter <br/> cbrush brushol; <br/> brushol. createhatchbrush (hs_bdia Gonal, RGB (0, 0, 255); <br/> PDC-> SelectObject (& brushol); <br/> PDC-> rectangle (200,400,300,500 ); </P> <p> // creates a bitmap function <br/> cbrush brushbit; <br/> cbitmap bitmap; <br/> bitmap. loadbitmap (idb_bitmap1); <br/> brushbit. createpatternbrush (& Bitmap); <br/> PDC-> SelectObject (& brushbit); <br/> PDC-> rectangle (0, 0, 100,100 ); </P> <p> // set the text background <br/> PDC-> setbkcolor (RGB (0,255, 0 )); // background color <br/> PDC-> setbkmode (opaque); // background mode <br/> PD C-> settextalign (ta_left | ta_bottom); // sets the text alignment mode. <br/> PDC-> textout (0,100, "Haha ~~~ // Set the text background ~~~ "); </P> <p> // set the text font <br/> cfont font; <br/> verify (font. createpointfont (200, "", PDC); <br/> PDC-> SelectObject (& font); <br/> PDC-> textout (400,300, "Haha ~~~ // Set the text font ~~~ "); </P> <p> // use the cbitmap class to display bitmap <br/> cbitmap * pbitmap = new cbitmap; <br/> pbitmap-> loadbitmap (idb_bitmap2); // load bitmap into memory <br/> CDC memdc; <br/> memdc. createcompatibledc (PDC); // create a memory device environment <br/> // select a bitmap object to the device environment, and save the pointer of the original device environment <br/> cbitmap * pbitmapold = memdc. selectObject (pbitmap); <br/> bitmap stbitmap; <br/> pbitmap-> getbitmap (& stbitmap); // obtain bitmap Information <br/> // output bitmap function: copy the bitmap from the source device environment to the target device environment // display the bitmap <br/> PDC-> bitblt (, stbitmap. bmwidth, stbitmap. bmheight, & memdc, 0, 0, srccopy); <br/> PDC-> SelectObject (pbitmapold); // restore the device environment <br/>