Solved

CEdit color

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Add content to output file 4 63
Doc'in system (example?) BA 7 107
Bartender label printing - switch on and off graphics 3 36
Problem to App 4 79
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
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.

785 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