Tip-set the font for cedit

Source: Internet
Author: User
Tip-set the font for cedit

Keywords: Cedit font logfont cfont

 

Set the font for ceditCode:

Within. H of the class

Cmyedit * m_pedit;
Cfont font;

In the CPP file of the class:

Logfont lf;
Memset (& lf, 0, sizeof (logfont ));
Lf. lfheight = height; // request a 12-pixel-height font
// Lf. lfwidth = 0;
Lf. lfweight = fw_bold;
Strcpy (LF. lffacename, "Arial"); // request a face name "Arial"
Verify (font. createfontindirect (& lf); // create the font
M_pedit = new cmyedit;
M_pedit-> Create (ws_child | ws_visible | ws_tabstop, crect (1, 1, width + 1, height + 1), this, 100 );
M_pedit-> setfont (& font );

Note that:

The cedit: setfont () function is required to set the font of the cedit control. However, the input parameter cannot be a local variable and must be valid throughout the entire survival period of the cedit control, therefore, you need to set the cfont variable to an in-class parameter or global. In short, cfont must exist when cedit exists.

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.