• Advertisement
Sign in to follow this  

coloring text in Win32

This topic is 4217 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone ^^, just wondering i have edit text window and i have i.e this text: "Hello World!" i want to color World how can i do this i checked msdn but didnt find anything =thank you . cya,

Share this post


Link to post
Share on other sites
Advertisement
for Win32 and standard edit controls, respond to the parent's WM_CTLCOLOREDIT message. it should be something like the code below... if different edit controls need different colors, then you need to add a few if/else statements in there. however, this colors all words in a standard edit control the same way. to have different words different colors you'll have to switch to rich-text controls.


case(WM_CTLCOLOREDIT) : {
HWND ctrl = (HWND)lparam;
SetBkColor((HDC)wparam, RGB(0,0,0));
SetTextColor((HDC)wparam, RGB(255, 0, 0));
return (LRESULT)GetStockObject(BLACK_BRUSH);
}




Share this post


Link to post
Share on other sites
hmmmm so there is another kind of textbox ..
so if i want to color one word then i need to use rich-text ?
anyresources ^^
thank you again,
cya.

Share this post


Link to post
Share on other sites
Yes, you need to use a rich edit control. Check out the msdn website for full information on how to use it. http://msdn.microsoft.com/

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement