Need to know cursor character position in a CRichEdit control

39 views Asked by At

I have an old MFC app with multiple CRichEdit controls. Currently, the app has no "Find" capability, and I want to add it. Like Notepad, I would like the search to begin from the current cursor position. Unfortunately, as insane is it seems, I can't find any way to determine where the cursor is. I have spent hours searching forums. Even going back to the Win32 Edit control, I can find no message to query the cursor position. This seems ridiculous. Am I missing something here?

1

There are 1 answers

0
Grant Downey On

OK, I found the answer to this. The CRichEdit::GetSel() function will return the character range if there is a current selection. If there is no current selection, the start and end character offsets will be equal to the cursor position. This is not made clear in any documentation I have seen, nor have I found it in any forum.