One-minute learning to use the RichEdit control

Source: Internet
Author: User

1. Add the Code related to RichEdit initialization to initinstance ().

Afxinitrichedit ();
M_hrichedit = loadlibrary ("richedw.dll ");

(The hmodule m_hrichedit is defined in the corresponding header file)

2. Set the text display style in RichEdit

Charformat CF;
Zeromemory (& CF, sizeof (charformat ));
Cf. cbsize = sizeof (charformat );
Cf. dwmask = cfm_bold | cfm_color | cfm_face |
Cfm_italic | cfm_size | cfm_underline;
Cf. dweffects = cfe_underline;
Cf. yheight = 12*12; // text height
Cf. crtextcolor = RGB (200,100,255); // text color
Strcpy (Cf. szfacename, _ T (""); // set the font
M_ctrlmyrichedit.setdefacharcharformat (CF );

(Cricheditctrl m_ctrlmyrichedit; defined in the header file of the corresponding dialog box,

And this variable is associated with a RichEdit control in the dialog box)

3. display text

Cstring strtext = "Hello, world! /R/nby Colin ";
M_ctrlmyrichedit.setwindowtext (strtext );

(/R/n indicates line feed. Of course, the premise of line feed is that the multiline option of the RichEdit control has been selected)

4. release resources related to RichEdit in exitinstance ()
Freelibrary (m_hrichedit );

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.