MFC RichEdit

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

西笑生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值