^_^ TY
2019-03-28 15:54[求助]MFC的CRichEditView视图,将Tab键产生的空格修改为两个空格出错了
在捕获tab按键消息时修改执行,获取光标位置,在该位置按Tab时输出两个空格,当前位置后移两位出错
if ((VK_TAB == pMsg->wParam) && (WM_KEYDOWN == pMsg->message) && (pMsg->hwnd == GetSafeHwnd()))
{
CString strContent;//视图内容
long lBegin = 0;
long lEnd = 0;
GetRichEditCtrl().GetSel(lBegin, lEnd); //当前光标位置
GetRichEditCtrl().GetWindowText(strContent);
if (lBegin != lEnd)
{
strContent = strContent.Left(lBegin) + strContent.Mid(lEnd);
}
strContent.Insert(lBegin, " ");
GetRichEditCtrl().SetWindowText(strContent);
GetRichEditCtrl().SetSel(lBegin + 2, lBegin + 2);
return TRUE;
}
执行结果:
在6前面回车,然后再按Tab就变成下图情况了
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- MFC有没有什么视图能同时编辑图片和文字
- mfc
- 控件
- 2个回答
- MFC单文档 CRichEditView如何设置光标的位置
- mfc
- cricheditview
- c++
- 3个回答
- 求助!MFC 单文档多视图 CEditView加载的背景图片被挡住的问题
- mfc
- c++
- ceditview
- 1个回答
- 求助!MFC单文档多视图的各视图的问题
- 多视图
- mfc
- treeview
- c++
- 2个回答