I know how to set background and text colors(and font faces) in RichEdit controls. I can't figure out how to set only certain words to a specific color. Can anyone help, please?
Thanks,
Matt U.
I know how to set background and text colors(and font faces) in RichEdit controls. I can't figure out how to set only certain words to a specific color. Can anyone help, please?
Thanks,
Matt U.
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
Someone please at least give me some links. I can't find anything I need at MSDN, except for each message. I know I need to get the text range with EM_GETTEXTRANGE, but I tried and it didn't work. I am trying to highlight HTML syntax(ex. <, >, and </). I want it to do it as soon as a <, >, or </ is entered into the RichEdit Control.
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
Well, at the risk of appearing once more as blatant self-publicist, you could try the example on my wee humble website; but if you are serious about fast syntax highlighting a web search on the subject should reveal some useful info on using streams to ferry info to and from a richedit control.
What's the URL to you website?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
It was in his profile...
gcc -lalleg
http://www.ciusa.net/~jrgrant/
Sorry, it was late...
http://www.foosyerdoos.fsnet.co.uk
or you could just click the 'www' button beneath a post or click the 'profile button' and get it from the opened page.
Ken's site had a lot of good examples. They helped me in some of the things I needed, but one thing. I didn't see anything about coloring certain chars a certain color. For example, if I entered: H it would be the font color the user selected(I got that done), but if I type <, >, or </ I want it to be RGB(200, 0, 0). How would I do that?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
Select the required text and then format it:
Formats everything. If you change the CHARRANGE values to the text you wish to change, that should do it. You can use the EM_EXGETSEL to fill a CHARRANGE struct with the current selected text range.Code:CHARFORMAT cf; ZeroMemory(&cf,sizeof(cf)); cf.cbSize=sizeof(cf); lstrcpy(cf.szFaceName,TEXT("Arial")); cf.bCharSet=ANSI_CHARSET; cf.bPitchAndFamily=FF_ROMAN; //bold, italic, underlined and coloured red. Height also valid cf.dwMask=CFM_COLOR|CFM_SIZE|CFM_FACE|CFM_EFFECTS; cf.dwEffects=CFE_BOLD|CFE_ITALIC|CFE_UNDERLINE; cf.crTextColor=RGB(200,0,0); cf.yHeight=200; //select all the current text for formatting CHARRANGE cr={0,-1}; SendMessage(hwndRichEdit,EM_EXSETSEL,0,(LPARAM)&cr); //let the cntrl know about it SendMessage(hwndRichEdit,EM_SETCHARFORMAT,SCF_WORD|SCF_SELECTION,(LPARAM)&cf);
I tried using EM_EXGETSEL, but I didn't know how. But that should work. Example, please?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
cr should now have the current selection range.Code:CHARRANGE cr; SendMessage(hwndRichEdit,EM_EXGETSEL,0,(LPARAM)&cr);
CHARRANGE cr;
SendMessage(hRichEd, EM_EXGETSEL, 0, (LPARAM) &cr);
CHARFORMAT cf;
ZeroMemory(&cf, sizeof(cf));
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_FACE | CFM_COLOR;
SendMessage(hRichEd, EM_EXSETSEL, 0, (LPARAM) &cr);
SendMessage(hRichEd, EM_SETCHARFORMAT, (WPARAM) SCF_WORD | SCF_SELECTION, (LPARAM) &cf);
Is That Correct? I think it will work, but I want to color < and > as the user inputs them. Will this code do that?
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK
Try it and see.
But don't forget to set your colour selection:
cf.crTextColor=RGB(200,0,0);
before sending the EM_SETCHARFORMAT message.
I am getting this now. Now I have another question. How do I handle the EN_CHANGE message for a rich edit with an ID of 200? That should check input and color it as it comes in. I just need how to set it up.
Website(s): http://www16.brinkster.com/trifaze/
E-mail: [email protected]
---------------------------------
C++ Environment: MSVC++ 6.0; Dev-C++ 4.0/4.1
DirectX Version: 9.0b
DX SDK: DirectX 8.1 SDK