MFC RichEdit

来源:互联网 发布:淘宝店铺用什么软件好 编辑:程序博客网 时间:2024/06/06 06:55

MFC RichEdit

flyfish

资源窗体 增加Rich Edit 2.0 Control

初始化

BOOL CMFCApplicationApp::InitInstance(){//TODO: call AfxInitRichEdit2() to initialize richedit2 library.AfxInitRichEdit2();}

头文件内容

//控件绑定变量
CRichEditCtrl m_RichEdit_ctlContent;
//格式
CHARFORMAT2 cf;

实现文件内容

    m_RichEdit_ctlContent.SetWindowText(L"富文本测试1234567");    cf.cbSize = sizeof(CHARFORMAT2);    cf.dwMask = CFM_BACKCOLOR | CFM_COLOR | CFM_FACE | CFM_SIZE;      //    cf.crBackColor = RGB(0, 255, 0);       // 背景色      cf.crTextColor = RGB(255, 0, 0); //文字颜色    cf.yHeight = 440;    lstrcpynW(cf.szFaceName, _T("微软雅黑"),32);    m_RichEdit_ctlContent.SetSel(1, 5); // 选中区域文字                    m_RichEdit_ctlContent.SetSelectionCharFormat(cf);

dwMask
Specifies the character height, in twips (1/1440 of an inch, or 1/20 of a printer’s point). To use this member, set the CFM_SIZE flag in the dwMask member.
指定的字符高度,单位为缇(1 / 1440英寸,或1 / 20的打印机的点)。使用此成员,在dwmask成员中设置cfm_size标志

1 twip=1/1440 inch
1 twip=1/20 point

pint与word字体号的对照

96 px/in screens
以二号字体为例 查表是22Point = 二号

设置数值是22*20=440

原创粉丝点击