Solved

CEdit color

Posted on 2002-03-13
4
445 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
  • 2
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
VinExpert earned 30 total points
Comment Utility
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
Comment Utility
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
Comment Utility
OK it worked, without open a class CEdit..
Thanks a lot.
0
 
LVL 8

Expert Comment

by:VinExpert
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
configuration management 2 99
iSeries DB2 Query 2 83
canBalance challenge 34 65
Use of condition with 'serial' in ansible 2 36
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now