To create a bitmap-button control in a window’s client area, follow these steps:
Create one to four bitmap images for the button.
Construct the CBitmapButton object.
Call the Create function to create the Windows button control and attach it to the CBitmapButton object.
Call the LoadBitmaps member function to load the bitmap resources after the bitmap button is constructed.
To include a bitmap-button control in a dialog box, follow these steps:
Create one to four bitmap images for the button.
Create a dialog template with an owner-draw button positioned where you want the bitmap button. The size of the button in the template does not matter.
Set the button’s caption to a value such as “MYIMAGE” and define a symbol for the button such as IDC_MYIMAGE.
In your application’s resource script, give each of the images created for the button an ID constructed by appending one of the letters “U,” “D,” “F,” or “X” (for up, down, focused, and disabled) to the string used for the button caption in step 3. For the button caption “MYIMAGE,” for example, the IDs would be “MYIMAGEU,” “MYIMAGED,” “MYIMAGEF,” and “MYIMAGEX.” You must specify the ID of your bitmaps within double quotes. Otherwise the resource editor will assign an integer to the resource and MFC will fail when loading the image.
In your application’s dialog class (derived from CDialog), add a CBitmapButton member object.
In the CDialog object’s OnInitDialog routine, call the CBitmapButton object’s AutoLoad function, using as parameters the button’s control ID and the CDialog object’s this pointer.
If you want to handle Windows notification messages, such as BN_CLICKED, sent by a bitmap-button control to its parent (usually a class derived from CDialog), add to the CDialog-derived object a message-map entry and message-handler member function for each message. The notifications sent by a CBitmapButton object are the same as those sent by a CButton object.
The class CToolBar takes a different approach to bitmap buttons.
For more information on CBitmapButton, seeControl Topics in Visual C++ Programmer's Guide.
说的真的很明白的。