cricheditctrl

Change char inserted using Alt+Unicode in CRichEdit

心已入冬 提交于 2020-02-06 03:30:31
问题 I want to change a unicode char inserted using Alt+Unicode code from the keyboard. I used PretranslateMessage for changing the chars inserted directly from the keyboard and it worked. But with the Alt+Unicode code method it does not. Here is the code: Microsoft Word has this functionality when enabling show/hide paragraph marks. BOOL CEmphasizeEdit::PreTranslateMessage(MSG* msg) { if (msg->hwnd == m_hWnd) { if (msg->message == WM_CHAR) { if (TheApp.Options.m_bShowWSpaceChars) { if (msg-

Spurious '\r' added by CRichEditCtrl::GetLine() when called on single-character lines?

筅森魡賤 提交于 2019-12-24 02:22:47
问题 I tried using CRichEditCtrl::GetLine() to retrieve the text of a given line of a rich-edit control in an MFC application built with VS2015 in Unicode mode, and running on Windows 10. I wrote this helper function: CString GetLine(CRichEditCtrl& richEdit, const int lineNum) { int lineLength = richEdit.LineLength(richEdit.LineIndex(lineNum)); if (lineLength == 0) { // Empty line return CString(); } const int kMinBufferLength = sizeof(int) / sizeof(wchar_t); const int bufferLength = max

How to display Red Squiggly Lines in CRichEditCtrl in MFC

微笑、不失礼 提交于 2019-12-21 20:44:56
问题 I am working on implementing spellchecker in an MFC application. What I want to do is display red lines under incorrectly spelled words. I found one example where it is done but it works only for a simple edit box because it can simply use the edit controls default font for doing calculations to draw the squiggly lines. But it does not work for a rich edit control as in rich edit control it is possible that different words can have different fonts. In this case the example I found draws lines

CRichEditCtrl::GetSelText() is not working right

こ雲淡風輕ζ 提交于 2019-12-20 04:14:13
问题 MFC File: winctrl4.cpp (C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\src\mfc) CString CRichEditCtrl::GetSelText() const { ASSERT(::IsWindow(m_hWnd)); CHARRANGE cr; cr.cpMin = cr.cpMax = 0; ::SendMessage(m_hWnd, EM_EXGETSEL, 0, (LPARAM)&cr); CStringA strText; LPSTR lpsz=strText.GetBufferSetLength((cr.cpMax - cr.cpMin + 1)*2); lpsz[0] = NULL; ::SendMessage(m_hWnd, EM_GETSELTEXT, 0, (LPARAM)lpsz); strText.ReleaseBuffer(); return CString(strText); } I am having a weird problem, when I

How to render CRichEditCtrl on CDC with transparent backgorund ? (MFC)

北慕城南 提交于 2019-12-11 05:01:53
问题 I need help with rendering CRichEditCtrl content with transparent background on graphical context which is displayed on screen and printed as well. Now I have following code, which is working good except transparency issues: CRichEditCtrl ctrl; // my CRichEditCtrl CDC *dc; // - my graphical context dc->SetBkMode(TRANSPARENT); dc->DPtoHIMETRIC(&targetSize); CRect cHiMetricRect( 0, 0, origSize.cx*factor,origSize.cy*factor); CRect cTwipsRect( 0, 0, (TWIPS_INCH * targetSize.cx + HIMETRIC_INCH / 2

CRichEditCtrl appending colored text?

你离开我真会死。 提交于 2019-12-10 10:31:51
问题 I have a CRichEditCtrl in an MFC project, which I use as a report log. Depending on the given situation, I need to append different colored text to the control (ie. a blue line for standard notifications, a red line for errors, etc). I've come pretty close to getting this to work, but it still behaves strangely: void CMyDlg::InsertText(CString text, COLORREF color, bool bold, bool italic) { CHARFORMAT cf = {0}; CString txt; int txtLen = m_txtLog.GetTextLength(); m_txtLog.GetTextRange(0,

CRichEditCtrl appending colored text?

空扰寡人 提交于 2019-12-06 13:42:27
I have a CRichEditCtrl in an MFC project, which I use as a report log. Depending on the given situation, I need to append different colored text to the control (ie. a blue line for standard notifications, a red line for errors, etc). I've come pretty close to getting this to work, but it still behaves strangely: void CMyDlg::InsertText(CString text, COLORREF color, bool bold, bool italic) { CHARFORMAT cf = {0}; CString txt; int txtLen = m_txtLog.GetTextLength(); m_txtLog.GetTextRange(0, txtLen, txt); cf.cbSize = sizeof(cf); cf.dwMask = (bold ? CFM_BOLD : 0) | (italic ? CFM_ITALIC : 0) | CFM

How to display Red Squiggly Lines in CRichEditCtrl in MFC

醉酒当歌 提交于 2019-12-04 12:36:16
I am working on implementing spellchecker in an MFC application. What I want to do is display red lines under incorrectly spelled words. I found one example where it is done but it works only for a simple edit box because it can simply use the edit controls default font for doing calculations to draw the squiggly lines. But it does not work for a rich edit control as in rich edit control it is possible that different words can have different fonts. In this case the example I found draws lines at incorrect places. Please let me know if someone has already done this for CRichEditCtrl? (it must