Solved

CEDIT color setting

Posted on 1998-02-26
6
711 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
[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
  • 3
  • 3
6 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 50 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

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…

695 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