以下代码可以很好地找到第一个单词:
int len = m_find.LineLength(m_find.LineIndex(0));
CString path;
LPTSTR p = path.GetBuffer(len);
m_find.GetLine(0, p, len);
path.ReleaseBuffer();
// Set the selection to be the first occurrence of the
// string lpszmyString, if it is found.
FINDTEXTEX ft;
ft.chrg.cpMin = nEndChar;
ft.chrg.cpMax = -1;
ft.lpstrText = p;
long n = ctrl.FindText(FR_MATCHCASE|FR_WHOLEWORD|FR_DOWN, &ft);
if (n != -1)
{
ctrl.SetSel(ft.chrgText);
}
如何找到下一次出现?
答案 0 :(得分:-1)
将chrg.cpMin成员设置为chrgText.cpMax,请参阅http://msdn.microsoft.com/en-us/library/bb787909.aspx