Solved

CEdit color

Posted on 2002-03-13
4
486 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

729 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