Solved

CEdit color

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unix / Linux grid computing 5 163
List out all word 7 317
sum28 challenge 31 115
canBalance challenge 34 98
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

828 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