Cbitmap
| Cobject |
| └ Cgdiobject |
| └ Cbitmap |
Cbitmap class encapsulates bitmaps in the Windows Graphics Device Interface (GDI) and provides member functions to manipulate bitmaps. Before using the cbitmap object, you must first construct the cbitmap object and call one of the initialization member functions to set the handle of the bitmap object. Then you can call other member functions. For more information about how to use graphical objects such as cbitmap, see "graphic objects" in the "visual c ++ programmer's Guide ".
# Include <afxwin. h>
Members of the cbitmap class
Constructor
| Cbitmap |
Construct a cbitmap object |
Initialization Function
| Loadbitmap |
Loads a named bitmap resource from the executable file of the application to initialize the bitmap object. |
| Loadoembitmap |
Load a predefined Windows bitmap to initialize the bitmap object. |
| Loadmappedbitmap |
Load a bitmap and map its color to the system color. |
| Createbitmap |
Initializes a bitmap object with a memory bitmap that depends on the device in the specified width, height, and bitmap mode. |
| Createbitmapindirect |
Initialize a bitmap object using a bitmap with the given width, height, and mode (which can be left unspecified ). |
| Createcompatiblebitmap |
Initializes an object with a bitmap to make it compatible with the specified device. |
| Creatediscardablebitmap |
Initializes an object with a discarded bitmap compatible with the specified device |
Attribute
| Getbitmap |
Fill bitmap structure with bitmap Information |
| Operator hbitmap |
Returns the Windows handle on the cbitmap object. |
Operation
| Fromhandle |
Returns the pointer to the cbitmap object when giving a pointer to the Windows hbitmap structure. |
| Setbitmapbits |
Set the bitmap bit to the specified value. |
| Getbitmapbits |
Copy the bitmap value to the specified buffer. |
| Setbitmapdimension |
Set the bitmap width and height (in 0.1mm) |
| Getbitmapdimension |
Returns the width and height of the bitmap. You must have called setbitmapdimension to set the width and height of the bitmap. |
Cbrush
| Cobject |
| └ Cgdiobject |
| └ Cbrush |
Cbrush class encapsulates the image brush in the Windows Graphical device interface (GDI. Construct a cbrush object before passing it to the CDC member function that needs to be painted. The paint brush can be solid, shadow, or pattern. For more information about image painter, see the graphic object section in the "Visual C ++ programmer Guide.
# Include <afxwin. h>
Cbrush class member
Constructor
| Cbrush |
Construct a cbrush object |
Initialization Function
| Createsolidbrush |
Initialize the image brush with the specified solid line |
| Createhatchbrush |
Initialize the paint brush with the specified Shadow Line |
| Createbrushindirect |
Initialize the paint brush with the style, color, and mode specified in the structure logbrush |
| Createpatternbrush |
Initialize the image brush in the pattern specified by the bitmap |
| Createdibpatternbrush |
Initialize the image brush with a device-independent Bitmap (DIB) |
| Createsyscolorbrush |
Create a paint brush that uses the default color of the system |
Operation
| Fromhandle |
Returns a pointer to the cbrush object when a Windows hbrush object handle is given. |
Attribute
| Getlogbrush |
Obtain a logbrush Structure |
| Operator hbrush |
Returns the Windows handle on the cbrush object. |
Cbutton
| Cobject |
| └ C0000target |
| └ Cwnd |
| └ Cbutton |
Class cbutton provides operations on Windows button controls. The button control is a small rectangle subwindow, which can be selected by clicking (Press) or not selected. Buttons can be used independently or in groups. They can also have text headers. When you click it, the button usually needs to change the display appearance.
Typical button controls include check boxes, single-choice buttons, and push buttons ). A cbutton object can be one of them, which is determined by its button style and the initialization of the member function create.
In addition, the class cbuttonbitmap is inherited from the class cbutton, But it supports button image labels. A cbuttonbitmap object can set different bitmaps for its four States (not pressed, pressed, focused, and inaccessible.
You can create a button control in the dialog box template or directly in the code.
In either case, you must first call the constructor cbutton to construct a cbutton object, then call the member function create to create a Windows button control and apply it to the cbutton object.
In a class derived from cbutton, the construction can be completed in one step. A programmer can compile a constructor for this derived class and call the create function.
If you want to process windows notification messages, such as the messages sent by the bitmap button control to its parent object (typically inherited from cdialog, add the message ing entry to the parent object and the member functions that process each message.
The format of each message ing entry is as follows:
On_notification (ID, memberfxn)
The ID specifies the ID of the subwindow of the control that sends the notification, while the memberfxn specifies the member function name in the parent object that processes the notification.
The function prototype of the parent object is as follows:
Afx_msg void memberfxn ();
Possible message ing entries are as follows:
| Ing entry |
When to send messages to the parent object |
| On_bn_clicked |
When you click a button |
| On_bn_doubleclicked |
When you double-click a button |
If a cbutton object is created in the dialog box resource, the cbutton object is automatically revoked when the user closes the dialog box. If a cbutton object is created in the window, you may need to undo it yourself. If the new function is used to create the object in the heap of the memory, you must use the delete function to cancel the window button control when closing the window. If this object is created in the stack or embedded in the parent dialog box, the system automatically revokes it.
# Include <afxwin. h>
Cbutton class member
Constructor
| Cbutton |
Construct a cbutton object |
Initialization Function
| Create |
Create a Windows button control and apply it to the cbutton object |
Operation
| Getstate |
Retrieves the selected, highlighted, and focused status of the button control. |
| Setstate |
Set the highlighted status of the button control |
| Getcheck |
Retrieves the selected status of the button control. |
| Setcheck |
Set the selected status of the button control |
| Getbuttonstyle |
Retrieving the style of a button control |
| Setbuttonstyle |
Set the style of the button control |
| GetIcon |
Retrieve the icon handle set by calling seticon |
| Seticon |
Specifies an icon displayed on the button. |
| Getbitmap |
Retrieves the handle of the bitmap previously called setbitmap. |
| Setbitmap |
Set the bitmap displayed on the button |
| Getcursor |
Retrieve the handle of the cursor image previously called setcursor |
| Setcursor |
Set the cursor image displayed on the button |
Covering Functions
| Drawitem |
It can be overwritten to draw custom cbutton objects. |