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. RichEdit Control Error

RichEdit Control Error

Scheduled Pinned Locked Moved C / C++ / MFC
questiondotnethelp
3 Posts 2 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.
  • S Offline
    S Offline
    Suresh H
    wrote on last edited by
    #1

    Hello all, I have a Rich edit control in my win 32 App. I am passing one word to rich edit control and I want to change the color of that word in all the places where it occurs in the Rich control. I am trying with this code void ColorWords(char* word,HWND hwnd) { CHARFORMAT2 cf; memset(&cf, 0, sizeof(CHARFORMAT2)); cf.cbSize = sizeof(CHARFORMAT2); cf.dwMask = CFM_BOLD; cf.dwEffects = CFE_BOLD; COLORREF clr =RGB(255, 10, 15) ; cf.dwMask =CFM_COLOR; cf.crTextColor = clr; FINDTEXTEX findText; int foundCount = 0; int foundPos = 0; int wordLen = lstrlen(word); findText.chrg.cpMin = 0; findText.chrg.cpMax = -1; findText.lpstrText = word; //Handle to the Rich edit box HWND hwndRichEdit = GetDlgItem(hwnd, IDC_FILECONT); foundPos=SendMessage(hwndRichEdit,EM_FINDTEXT,FR_WHOLEWORD,(LPARAM)&findText); while (foundPos != -1) { SendMessage(hwndRichEdit,EM_EXSETSEL,0,(LPARAM)foundPos + wordLen); SendMessage(hwndRichEdit,EM_GETCHARFORMAT,SCF_SELECTION,(LPARAM)cf); findText.chrg.cpMin = foundPos + wordLen; foundPos =SendMessage(hwndRichEdit,EM_FINDTEXT,FR_WHOLEWORD,(LPARAM)&findText); } } I am getting the below error can u please tell me what is error ?? Error :- error C2440: 'type cast' : cannot convert from 'struct CHARFORMAT2A' to 'long' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Error executing cl.exe.

    H 1 Reply Last reply
    0
    • S Suresh H

      Hello all, I have a Rich edit control in my win 32 App. I am passing one word to rich edit control and I want to change the color of that word in all the places where it occurs in the Rich control. I am trying with this code void ColorWords(char* word,HWND hwnd) { CHARFORMAT2 cf; memset(&cf, 0, sizeof(CHARFORMAT2)); cf.cbSize = sizeof(CHARFORMAT2); cf.dwMask = CFM_BOLD; cf.dwEffects = CFE_BOLD; COLORREF clr =RGB(255, 10, 15) ; cf.dwMask =CFM_COLOR; cf.crTextColor = clr; FINDTEXTEX findText; int foundCount = 0; int foundPos = 0; int wordLen = lstrlen(word); findText.chrg.cpMin = 0; findText.chrg.cpMax = -1; findText.lpstrText = word; //Handle to the Rich edit box HWND hwndRichEdit = GetDlgItem(hwnd, IDC_FILECONT); foundPos=SendMessage(hwndRichEdit,EM_FINDTEXT,FR_WHOLEWORD,(LPARAM)&findText); while (foundPos != -1) { SendMessage(hwndRichEdit,EM_EXSETSEL,0,(LPARAM)foundPos + wordLen); SendMessage(hwndRichEdit,EM_GETCHARFORMAT,SCF_SELECTION,(LPARAM)cf); findText.chrg.cpMin = foundPos + wordLen; foundPos =SendMessage(hwndRichEdit,EM_FINDTEXT,FR_WHOLEWORD,(LPARAM)&findText); } } I am getting the below error can u please tell me what is error ?? Error :- error C2440: 'type cast' : cannot convert from 'struct CHARFORMAT2A' to 'long' No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called Error executing cl.exe.

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

      I think you get your answer but moreover see A Rich Edit Control That Displays Bitmaps and Other OLE Objects[^] its good article about RichEdit ;)


      WhiteSky


      S 1 Reply Last reply
      0
      • H Hamid Taebi

        I think you get your answer but moreover see A Rich Edit Control That Displays Bitmaps and Other OLE Objects[^] its good article about RichEdit ;)


        WhiteSky


        S Offline
        S Offline
        Suresh H
        wrote on last edited by
        #3

        Thanks white sky for the link …. But its MFC rich edit box application …. I think there is a lot of changes in the MFC and Win 32 way of handling structure and send messages. If u have any link for win 32 Api Application examples for rich edit box please send it, it will be very use full for me.

        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