Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to create incremental search (similar to the visual studio editor) option for CRicheditview in my application.

Any one can help me? How could I do that?
Posted
Updated 21-Apr-11 20:01pm
v2

My solution - You should set the caret back to the first character position for the next search.
C#
BOOL CSimpleFinderView::Findx(CString str)
{
  SendMessage(EM_SETSEL,0,0);
  return FindText(str,FALSE,FALSE,FALSE);
}


Regards.
 
Share this answer
 
Tell us how far you've gotten, and post specific questions here.
 
Share this answer
 
BOOL CSimpleFinderView::Findx(CString str)
{
       return FindText(str,FALSE,FALSE,FALSE);
}



I have wrote above function in view class derived from CRicheditview. I will call this function from mainfrm class.

Consider following example text present view.


"function is not working, so remove the the function"

To find the word "function", I traps characters at mainfrm pretranslate message and calling above function for every key pressing.

Keypressed | Result
--------------------
f | function is not working, so remove the the function
fu | function is not working, so remove the the function

Findtext() selecting the second occurrence of the word function. But it suppose to be first one.
I feel this CRichEditView::FindText() will not help

Can u suggest any other solution?
 
Share this answer
 
Comments
mbue 23-Apr-11 17:05pm    
You should set the caret back to the first character position for the next search.
SendMessage(EM_SETSEL,0,0);
Regards.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900