Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Edit vs. Rich Edit Controls

Posted on 1998-10-26
5
Medium Priority
?
290 Views
Last Modified: 2010-04-02
I'm wondering if the EDIT control can change text colors.  I've tried before with SetTextColor() using MFC, and never could get it to work.  Now I've recoded the entire thing WITHOUT MFC, and am wondering if I am just waisting my time...If it IS possible, could you let me know the correct syntax?  (of the entire process, if possible.)

Also, besides some OLE stuff, are there any major advantages to using RichEdit instead of Edit?
0
Comment
Question by:ichor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:yonat
ID: 1176245
Besides the "OLE stuff", with rich edit control you can use different text styles (fonts, coloers, size, etc.) and you are not limited to 64K content.

And no,you can't change the color of an edit control.

0
 

Author Comment

by:ichor
ID: 1176246
Using the EDIT control, I can already change the font and size.  But there's no way to change the color of the text using just Edit (instead of RichEdit)?  

I was under the impression that using Windows COLORREF values that I could change RGB values of text, like I said before, using SetTextColor()

Although I never got it to work correct (it never worked at all, actually), I had once tried to use code like:

m_Color = GREEN;  //GREEN defined in .h file.
HDC hdc;
SetTextColor(hdc, m_Color);

Obviously, this did not work.  I'm still sure that I've seen color changing using SetTextColor() with just the Edit control though.  Maybe I'm thinking of something else?
0
 
LVL 5

Expert Comment

by:yonat
ID: 1176247
You can only have ONE font and size for the ENTIRE text in the edit control. In the rich edit control, each character can have a different style. I don't know of a way to change its color.
0
 
LVL 4

Accepted Solution

by:
pagladasu earned 210 total points
ID: 1176248
Of course, you can change the text color in an edit control using MFC. Assume that there is an edit control to which is mapped a control type of variable called m_edit.
Map the WM_CTLCOLOR message of your dialog box.
Add the following code in OnCtlColor() function.
HBRUSH CDilprnDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
      HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
             //my additions
      if(pWnd==&m_edit)
            pDC->SetTextColor(RGB(255,0,0));
             //my addition ends
      return hbr;
}

Try it and send  a feedback.
Thanks,
Pagladasu.

Regarding Rich edit controls, I think most of the comments apply.

0
 

Author Comment

by:ichor
ID: 1176249
Hmm...I'd like to give both of you points, but I don't think that's possible.  Thanks for your help, though!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question