Quantcast
Channel: Visual C forum
Viewing all articles
Browse latest Browse all 15302

Issue with CrichEditCtrl ::FindText() in unicode app

$
0
0

Hi All,

I am facing some issue related to text search with CrichEditCtrl  in unicode app ..

CRichEditCtrl *pvoEditCtrl;
//Load text here
{
  ///////
}

CString strFindWhat = _T("Hello");

FINDTEXTEX FindText; 
DWORD      dwSearchFlags;
       
//case 1: Normal search
dwSearchFlags = 0;

FindText.chrg.cpMin = 0;
FindText.chrg.cpMax = -1;
FindText.lpstrText  = (LPCTSTR) pvstrFindWhat;  // FindText.lpstrText  = (LPSTR) (LPCTSTR) strFindWhat; for non unicode application ANSI

for( long lnCharPos = -1 ; ((lnCharPos = pvoEditCtrl->FindText(dwSearchFlags, &lvFindText)) != - 1); lnCount++)
{
   //do something
}

//Case 2: whole word match
dwSearchFlags = FR_WHOLEWORD;

FindText.chrg.cpMin = 0;
FindText.chrg.cpMax = -1;
FindText.lpstrText  = (LPCTSTR) pvstrFindWhat;
for( long lnCharPos = -1 ; ((lvnCharPos = pvoEditCtrl->FindText(dwSearchFlags, &lvFindText)) != - 1); lnCount++)
{
 //do something
}


Issues I found are following:
Case 1: It gives  all line or char position for all word  which contain  the first char of search string as like "H" of "Hello" in unicode application.
        It gives all line or char position for only word  which contain  the  search string as like "Hello" in non unicode application (ANSI).
Csae 2: No result, string not found, FindText() returns -1  for unicode application .
        Correct result for non unicode application (ANSI).

What is the issue with this API FindText() ?

Please help me to correct the issue.


Viewing all articles
Browse latest Browse all 15302

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>