CRichEditCtrl word highlighting
-
Hi All, Sorry I am back…. With help of Steve Echols I have finished displaying text file in the Rich Edit box, Now I want to search a particular word in the edit box and I want to high light them Can u please help me with this…. word to be highlighted is stored in the variable w // set the window text m_FCONT.SetWindowText(text); delete [] text; fclose(fp); -- ----- CHARFORMAT cf; memset(&cf, 0, sizeof(CHARFORMAT)); cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_BOLD; cf.dwEffects = CFE_BOLD; UpdateData(TRUE); CString w; w = m_WORD; int len = strlen(word); char word_position[50]; char word_length[50]; // **** pseudo-code **** for (int p = 0; p < len ; p++) { m_FCONT.SetSel(word_position[p], word_length[p]); m_FCONT.SetSelectionCharFormat(cf); } Regards, Vinay Charan.
-
Hi All, Sorry I am back…. With help of Steve Echols I have finished displaying text file in the Rich Edit box, Now I want to search a particular word in the edit box and I want to high light them Can u please help me with this…. word to be highlighted is stored in the variable w // set the window text m_FCONT.SetWindowText(text); delete [] text; fclose(fp); -- ----- CHARFORMAT cf; memset(&cf, 0, sizeof(CHARFORMAT)); cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_BOLD; cf.dwEffects = CFE_BOLD; UpdateData(TRUE); CString w; w = m_WORD; int len = strlen(word); char word_position[50]; char word_length[50]; // **** pseudo-code **** for (int p = 0; p < len ; p++) { m_FCONT.SetSel(word_position[p], word_length[p]); m_FCONT.SetSelectionCharFormat(cf); } Regards, Vinay Charan.
-
-
Hi WhiteSky, i want to highlight the word during text tranfer from file to rich edit box,i have no options of using another dialog for finding the text.. can u please tell me how to find the word and highlight it.. Regards, Vinay Charan.
Hi Vinay Try Using FindText, Here is a sample code,
// The pointer to my rich edit control. CRichEditCtrl* pmyRichEditCtrl; // The string to search for. LPCTSTR lpszmyString; // Set the selection to be the first occurrence of the // string lpszmyString, if it is found. FINDTEXTEX ft; ft.chrg.cpMin = 0; ft.chrg.cpMax = -1; ft.lpstrText = (LPSTR) lpszmyString; long n = pmyRichEditCtrl->FindText(FR_MATCHCASE|FR_WHOLEWORD, &ft); if (n != -1) pmyRichEditCtrl->SetSel(ft.chrgText);
Appu.. "If you judge people, you have no time to love them."