Set the font height C ++ VC MFC

Source: Internet
Author: User

[1] example 1

BelowCodeIs placed in the oninitdialog of the dialog box class. Note that m_font is a class member function. Otherwise, the setfont may be faulty due to the failure of local variables.

 

Cfont * pfont = m_e2.getfont (); // cedit m_e2; <br/> assert (null! = Pfont); <br/> logfont lf; <br/> int nret = pfont-> getlogfont (& lf); <br/> assert (0! = Nret); <br/> lf. lfheight =-60; // set the height <br/> m_font.createfontindirect (& lf); // cfont m_font; is a class member function <br/> m_e2.setfont (& m_font );

[2] Example 2

In this example, only the font height is changed, and the font width remains unchanged.

Void cmy3455dlgdlg: onbutton1 () <br/>{</P> <p> cclientdc DC (this); <br/> logfont; <br/> cfont objfont; </P> <p> DC. getcurrentfont ()-> getlogfont (& logfont); <br/> logfont. lfheight * = 2; // double the font size <br/> // logfont. lfwidth = 0; // Note: If this sentence is added, the font width is changed based on the font height to maintain the font ratio. <Br/> logfont. lfquality = draft_quality; </P> <p> objfont. createfontindirect (& logfont); <br/> DC. selectObject (objfont); </P> <p> DC. textout (0, 0, text ("China"), 4); <br/>}

 

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.