• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 732
  • Last Modified:

CEDIT color setting

How do I set the color of a  CEdit control to light yellow (the control is read only)?
0
krhegde
Asked:
krhegde
  • 3
  • 3
1 Solution
 
jhanceCommented:
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
 
jtwine100697Commented:
Jhance...  You answered right as I was composing my answer...   Beat me too it by *that* much! :P

-=- James.
0
 
jtwine100697Commented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

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

-=- James.
0
 
jtwine100697Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now