解决方案 »
- 各位c++ coders,你们会鄙视藐视轻视甚至无视c#程序员吗?
- 请教外挂输入法原理、思路或源码
- WinCE6.0 下CommandLineToArgv返回参数错误
- 怎样在重绘的EDIT里创建“输入光标”
- PeekMessage(&Symsg,NULL,0,0,PM_REMOVE) 等于 GetMessage么?
- DLL问题
- D3D显示内存数据崩溃
- 完成端口在用WSASend发送数据的时候,到底是已经发送完了还是只进入完成端口线程操作?
- 一个结构体变量赋值的问题
- 我下载了一本电子书,试用winrar打开后,格式是acrobat reader 目录能打开,但是
- (100分)求QQ聊天摄像头录像及屏幕录像专家代码(在线等)
- CFileFind计算4GB以上文件长度
ZeroMemory(&cf, sizeof(CHARFORMAT));
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE |
CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;
cf.dwEffects = 0;
cf.yHeight = 180;
cf.crTextColor = RGB(255, 255, 255);
strcpy(cf.szFaceName ,_T("宋体"));
m_edit.SetSel(0, 5);
m_edit.SetSelectionCharFormat(cf);
{
// bool b1=AfxInitRichEdit(); //调试时,b1为TRUE
CDialog::OnInitDialog();
m_richEdit.SetWindowText(_T("dfsafda5fjdsaojfoajguaenogdjuao9eongodaj"));
CHARFORMAT cf;
ZeroMemory(&cf, sizeof(CHARFORMAT));
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR ;
cf.dwEffects=~CFE_AUTOCOLOR;
cf.dwEffects = 0;
cf.crTextColor = RGB(255,0,0); //文字颜色
m_richEdit.SetSel(1,8); //设置处理区域
bool b=m_richEdit.SetSelectionCharFormat(cf); //调试时,b始终为False,SetWordCharFormat,SetDefaultCharFormat之类的函数都不能成功执行 -----------
BOOL CDlgApp::InitInstance()
{
AfxEnableControlContainer();
AfxInitRichEdit();我这可以
// 一直在用她!int CXXDlg::AppendToLog(CString str, COLORREF color)
{
int nOldLines = 0, nNewLines = 0, nScroll = 0;
long nInsertionPoint = 0;
CHARFORMAT cf; // Save number of lines before insertion of new text
nOldLines = m_LogEdit.GetLineCount(); // Initialize character format structure
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask = CFM_COLOR;
cf.dwEffects = 0; // To disable CFE_AUTOCOLOR
cf.crTextColor = color; // Set insertion point to end of text
nInsertionPoint = m_LogEdit.GetWindowTextLength();
m_LogEdit.SetSel(nInsertionPoint, -1); // Set the character format
m_LogEdit.SetSelectionCharFormat(cf); // Replace selection. Because we have nothing selected, this will simply insert
// the string at the current caret position.
m_LogEdit.ReplaceSel(str); // Get new line count
nNewLines = m_LogEdit.GetLineCount(); // Scroll by the number of lines just inserted
nScroll = nNewLines - nOldLines;
m_LogEdit.LineScroll(nScroll); return 0;
}
在我机上,SetSelectionCharFormat(cf)还是执行不了
它就是SetSelectionCharFormat(cf)没有成功,返回值每次都是0,都不知是不是系统问题。我用的是Vista全部项目代码已在http://hedanwang.cn/bbs/dispbbs.asp?boardid=17&Id=9135
用户名和密码都是test2