[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

CEDIT color setting

Posted on 1998-02-26
6
Medium Priority
?
729 Views
Last Modified: 2013-11-20
How do I set the color of a  CEdit control to light yellow (the control is read only)?
0
Comment
Question by:krhegde
  • 3
  • 3
6 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 150 total points
ID: 1316566
Override the OnCtlColor memober function of your CDialog derived class and return a yellow HBRUSH for that control ID of the CEdit you want changed.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316567
Jhance...  You answered right as I was composing my answer...   Beat me too it by *that* much! :P

-=- James.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316568
Yes, it happens.  Some "experts" post an "Answer Coming" right away and then post the real answer at their lesiure.  In my opinion, that's tacky.
0
Industry Leaders: 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!

 
LVL 32

Expert Comment

by:jhance
ID: 1316569
Actually, your function is missing some stuff:

HBRUSH CPaddsCvtDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
 
    //
    //  If My Control Is Asking For Its Colors, Set Them.
    //
    if( pWnd->GetDlgCtrlID() == IDC_PADDSASCII )
    {
        pDC->SetTextColor(RGB(0,0,0));                  // Set Text Color
        pDC->SetBkColor(RGB(255, 255, 0));      // Set Text BG Color
        return(::CreateSolidBrush(RGB(255, 255, 0)));                  // Return BG Brush
    }
   
    //
    //  If Not My Control, Just Do The Default.
    //
    HBRUSH hBrush = CDialog::OnCtlColor( pDC, pWnd, nCtlColor );
    return( hBrush );
}
0
 
LVL 32

Expert Comment

by:jhance
ID: 1316570
What is missing?  The explicit colors?  That is what the member variables are for...

-=- James.
0
 
LVL 4

Expert Comment

by:jtwine100697
ID: 1316571
Thanks jhance for your solution .
This works fine only if the  R G B values are 0,255,128 ( pure colors only).I also needed to specify pDC->SetBkMode(TRANSPARENT);
 It does not draw transparent for non-pure colors.
Is there any way to do that ?

0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
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.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

830 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