Various objects related to GUI 2001-10-03 · · · Vchelp There are various GUI objects (not confused with C objects) in Windows, when you are drawing, you need to take advantage of these objects. The various objects have various properties, and the following describes the various GUI objects and their properties. Font Objects CFont uses different styles and size fonts when the text is output. The selectable style includes: whether it is a slope, whether it is a bold, the font name, whether it is underscore, etc. Colors and background colors are not in the font properties. Regarding how to create and use fonts in 2.2, you will explain in detail in the output text in the window. The brush CBRUSH object determines the color or template used in the fill area. For a fixed color brush, its attribute is color, whether the type of grid and grid is used, vertical, cross-like, etc. You can also create a custom template with a bitmap of 8 * 8, and the system will use the bitmap to step by step by step by using this brush. Regarding how to create and use a brush to use a brush in 2.3, the pen will explain in detail. The brush CPEN object is useful when drawing points and lines. Its properties include color, width, line style, such as dashed lines, solid lines, dotlines, etc. About how to create and use a brush to use a brush in 2.3, the pen will explain in detail. Bitmap CBITMAP objects can contain an image that can be saved in the resource. About how to use bitmaps in 2.4 Drawing device-related bitmaps, icons, and device-free bitmaps in the window. There is also a special GUI object is a polygon, which can limit the map area or change the window exterior using a polygon. About how to create and use polygons explain in detail in a 2.6 polygon and scrapbooking area. Use the GUI object in Windows to comply with certain rules. First, you need to create a legitimate object, and different object creation methods are different. The GUI object is then required to select the DC while saving the original GUI object in the DC. If an illegal object is selected will cause an exception. After use, the original object should be restored. This is especially important. If a temporary object is saved in the DC, it may cause an exception after the temporary object is destroyed. One must pay attention to, each object must be destroyed before recreation, the code below demonstrates this safe usage: OnDraw (CDC * PDC) {CPEN PEN1, PEN2; Pen1.createpen (PS_SOLID, 2, RGB ( 128, 128, 128)); // Create object pen2.createpen (PS_SOLID, 2, RGB (128, 128, 0)); // Create object cpen * ppenold = (cpen *) PDC-> selectobject (& Pen1); // Select Object into DC DrawWithpen1 ... (cpen *) PDC-> SelectObject (& Pen2); // Select Object into DC DRAWWITHPENPEN2 ... Pen1.deleteObject (); // First destroy Pen1.createpen before you create (PS_SOLID, 2, RGB (0 , 0, 0)); // Create an object again (CPEN *) PDC-> SelectObject (& Pen1); // Select Object into DC DrawWithpen1 ... PDC-> SelectObject (POLDPEN); // Restore} In addition to the system With some stock GUI objects, you can use CDC :: SelectStockObject (SelectStockObject (INT NINDEX) to select these objects, including some fixed color brushes, brushes, and some basic fonts.