Solved

CEdit color

Posted on 2002-03-13
4
491 Views
Last Modified: 2013-11-20
Hi!
I have a CEdit member in my cdialog.
The style of this CEdit is : MULTILINE and READ_ONLY.

But when i use this i get a gray background of the CEdit control, although the background that i want is WHITE.

Do you have a solution for me??
Guy Eliyahu.
0
Comment
Question by:GEliyahu
[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
4 Comments
 
LVL 8

Accepted Solution

by:
VinExpert earned 30 total points
ID: 6860118
Hi,

Open the class wizard and add a new class say CMyEdit derived form CEdit. Then have a control variable of type CMyEdit associated with that edit box using class wizard -> member variables tab -> Add Variable. Map the =WM_CTLCOLOR message to CMyEdit class using class wizard and modify it as

HBRUSH CMyEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
     HBRUSH hbr;
     
     //Set the text attributes
     pDC->SetTextColor(RGB(0, 0, 0));
     pDC->SetBkColor(RGB(255, 255, 255));

     //Set the edit bk color
     hbr = ::CreateSolidBrush(RGB(255, 255, 255));
     return hbr;    
}

That should give u the required.

Try it out.
VinExpert
0
 

Author Comment

by:GEliyahu
ID: 6860146
Do I have to add a spechiel class for this member???
can't i  use CMyDialog::CtlColor
where CMyDialog inherit CDialog  (CMyDialog::CDialog).
0
 

Author Comment

by:GEliyahu
ID: 6860167
OK it worked, without open a class CEdit..
Thanks a lot.
0
 
LVL 8

Expert Comment

by:VinExpert
ID: 6860175
Okay...

Possibly with read only set, u wont get that message in dialog for that edit control. U need the reflection message mapping. For that u need to have a subclassed edit control and map that message. Anyway, just give it a try. Otherwise it is always better to subclass it as u may want to add some more specific functionalities for that edit control... in that case it will help and is easy.

VinExpert
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

630 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