Solved

CEDIT color setting

Posted on 1998-02-26
6
655 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 50 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 32

Expert Comment

by:jhance
Comment Utility
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
Comment Utility
What is missing?  The explicit colors?  That is what the member variables are for...

-=- James.
0
 
LVL 4

Expert Comment

by:jtwine100697
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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…
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now