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