文章目录
ui 设置
使用AfxInitRichEdit2(); 初始化否则不显示
//初始化
BOOL CnotePadDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// 设置此对话框的图标。 当应用程序主窗口不是对话框时,框架将自动
// 执行此操作
SetIcon(m_hIcon, TRUE); // 设置大图标
SetIcon(m_hIcon, FALSE); // 设置小图标
CHARFORMAT cf = { 0 };
//追加到上面去
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_BOLD | CFM_CHARSET | CFM_COLOR | CFM_FACE | CFM_SIZE | CFM_UNDERLINE;
cf.dwEffects = CFE_BOLD;//加粗
cf.yHeight = 200;//高
cf.yOffset = 30;
cf.crTextColor = RGB(255, 0, 230);
cf.bCharSet = ANSI_CHARSET;//字符集
cf.bPitchAndFamily = DEFAULT_PALETTE;
wcscpy(cf.szFaceName, L"宋体");
m_richedit.SetDefaultCharFormat(cf);
return TRUE; // 除非将焦点设置到控件,否则返回 TRUE
}
//发送消息
void CnotePadDlg::OnBnClickedBtnSend()
{
UpdateData(TRUE);
//追加到上面去
CHARFORMAT cf = { 0 };
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_BOLD | CFM_CHARSET | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;
cf.dwEffects = CFE_BOLD | CFE_ITALIC;
cf.yHeight = 400;
cf.yOffset = 30;
cf.crTextColor = RGB(255, 255, 255);
cf.bCharSet = DEFAULT_CHARSET;
cf.bPitchAndFamily = DEFAULT_PITCH;
wcscpy(cf.szFaceName, L"楷体");
m_richedit.SetSelectionCharFormat(cf);
//追加
int nLength = m_richedit.GetWindowTextLength();
m_richedit.SetSel(nLength, -1);
m_richedit.ReplaceSel(m_edit);
}