Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CRichEditCtrl word highlighting

CRichEditCtrl word highlighting

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    VinayCool
    wrote on last edited by
    #1

    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.

    H 1 Reply Last reply
    0
    • V VinayCool

      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.

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      See Customizing the Common Find/Replace Dialog in RichEdit View[^]_**


      **_

      whitesky


      V 1 Reply Last reply
      0
      • H Hamid Taebi

        See Customizing the Common Find/Replace Dialog in RichEdit View[^]_**


        **_

        whitesky


        V Offline
        V Offline
        VinayCool
        wrote on last edited by
        #3

        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.

        N 1 Reply Last reply
        0
        • V VinayCool

          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.

          N Offline
          N Offline
          NiceNaidu fo
          wrote on last edited by
          #4

          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."

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups