Solved

CEDIT color setting

Posted on 1998-02-26
6
700 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
Technology Partners: 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
repeatEnd java challenge 42 85
sameEnds challenge 3 187
modThree challenge 4 113
Remove Password Protection from pdf (with password) using an command line executable 5 84
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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 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.

730 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