Question : Problem with RichEdit20a and FindText?

I'm using vc7.1 to develop an SDI app based on CFormView that contains a CRichEditCtrl that is defined in the .rc as "RichEdit20a". In the MyApp::InitInstance, I am calling
AfxInitRichEdit2();

Then I have this code in MyView::OnInitialUpdate:

myRichEdit20aCtrl.Clear();
myRichEdit20aCtrl.SetWindowText("Will the word 'hello' be found?");
FINDTEXTEX ftx;
ftx.chrg.cpMin = 0;
ftx.chrg.cpMax = -1;
char* searchStr = "hello";
ftx.lpstrText = searchStr;
long offset = myRichEdit20aCtrl.FindText(0, &ftx);

With this combination, the CRichEditCtrl::FindText always returns -1 (not found).

If I change to "RICHEDIT" in the .rc and call AfxInitRichEdit(), then the FindText() works ok.

I'm baffled.

Does it appear like I am doing something wrong or leaving out a step? Is there perhaps "dll heck" going on with the .dll associated with RichEdit? Could Unicode be involved? Is there a problem with RichEdit20a and FindText? Is there a work-around? I want to use some of the RichEdit20a functionality, but I can't get the FindText to work properly.

Answer : Problem with RichEdit20a and FindText?

It's a M$ strange thingy. You need to set, especially for RichEdit 2.0, the FR_DOWN flag:

long offset = myRichEdit20aCtrl.FindText(FR_DOWN, &ftx);
Random Solutions  
 
programming4us programming4us