[VC programming skills] controls? 4.1 Bitmap Button

Source: Internet
Author: User
4.1 Bitmap Button

Adding a bitmap to a button or changing the font of the button can make the button shine. How can I add a bitmap to the button and change the font of the text on the button? See the following example!

1> Create a dialog box program and create the following dialog box;

Figure 1


Resource ID description:

ID of the left button: idc_button1

ID of the right button: idcancel


2> set the button attribute. Set options, as shown in the arrow;

Figure 2


3> Add a bitmap to a project, such as an arrow;

Figure 3


4> Add control variables to the buttons on the left (use the Class Wizard );

CBitmapButton m_bitmapButton;

※If the cbitmapbutton type does not exist in the Class Wizard, you can change it to cbitmapbutton by default.

5> in the program initialization function of the dialog box, set a bitmap for the buttons on the left and a font for the buttons on the right;

// Todo: add additional initialization code m_bitmapbutton.loadbitmaps (idb_bitmap1, idb_bitmap2) here; // Load button bitmap resource logfont lf; memset (& lf, 0, sizeof (logfont )); // initialize lf. lfheight = 20; // font height (unit: Px) lf. lfwidth = 13; // font width lf. lfitalic = true; // italic lf. lfescapement =-50; // use italic _ tcsncpy_s (LF. lffacename, lf_facesize, _ T ("Arial"), 7); // request a face name "Arial" verify (m_fontbutton.createfontindirect (& lf )); // create a new font getdlgitem (idcancel)-> setfont (& m_fontbutton); // return true for the font application and cancel button; // unless the focus is set to the control, otherwise, true is returned. </span>

6> final

Figure 4


P.s download project source code

[VC programming skills] controls? 4.1 Bitmap Button

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.