下面的代码可以很好地找到第一次出现的单词:
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);
}
如何找到下一个事件?
设置chrg。cpMin成员为chrgText。cpMax,参见http://msdn.microsoft.com/en-us/library/bb787909.aspx