How to change background color Of CEdit? 
Author Message
 How to change background color Of CEdit?

Hi,i want to change the CEdit background Color,
How to do it ?

thanks!



Fri, 20 Feb 2004 19:02:15 GMT  
 How to change background color Of CEdit?
Handle WM_CTLCOLOR in parent window class (most likely CDialog based class)

Evgeny


Quote:
> Hi,i want to change the CEdit background Color,
> How to do it ?

> thanks!



Fri, 20 Feb 2004 19:30:59 GMT  
 How to change background color Of CEdit?
Think you,your help.I write it as so:

HBRUSH CMMsgEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
 // TODO: Change any attributes of the DC here

 // TODO: Return a non-NULL brush if the parent's handler should not be
called
  CBrush brush(RGB(0,0,0));
    if (nCtlColor== CTLCOLOR_EDIT  )
 {
  // set the background color to Black.
  pDC->SetBkColor(RGB(0, 0, 0));
  // Set the text color to White
  pDC->SetTextColor(RGB(255,255,255));
 }
 return brush;

Quote:
}



Quote:
> Handle WM_CTLCOLOR in parent window class (most likely CDialog based
class)

> Evgeny



> > Hi,i want to change the CEdit background Color,
> > How to do it ?

> > thanks!



Fri, 20 Feb 2004 21:04:57 GMT  
 How to change background color Of CEdit?
Hi!

Quote:

> Think you,your help.I write it as so:

> HBRUSH CMMsgEdit::CtlColor(CDC* pDC, UINT nCtlColor)
> {
>  // TODO: Change any attributes of the DC here

>  // TODO: Return a non-NULL brush if the parent's handler should not be
> called
>   CBrush brush(RGB(0,0,0));
>     if (nCtlColor== CTLCOLOR_EDIT  )
>  {
>   // set the background color to Black.
>   pDC->SetBkColor(RGB(0, 0, 0));
>   // Set the text color to White
>   pDC->SetTextColor(RGB(255,255,255));
>  }
>  return brush;
> }

Don't leave the CBrush a local variable. Either make it static or a member of the CMMsgEdit class.
The CBrush destructor will call DeleteObject when your function returns, so as it stands your
returned HBRUSH is invalid by the time the caller receives it. Also, do you mean to be returning a
black brush for everything?

HTH,

Jeff...
--
Please post all follow-ups to the newsgroup only.



Fri, 20 Feb 2004 21:40:04 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to change background color of CEdit?

2. Changing Background Color of CEdit - Problem With Double Clicking On Texts

3. Changing the default background color of disabled control (CEdit)

4. How to change background color of a dynamically created CEdit control

5. Change background color of disabled CEdit controls

6. Changing the Background Color of Individual CEdit controls in a CDialogBar

7. Changing CEdit background COLOR on FOCUS????

8. Change background color of CEdit in CEditView

9. change the CEdit Background color - but tricky!

10. Changing color of background of a CEdit control

11. How to change CEdit window background color without derivation from it a new class

12. Changing the Background Color of a Dialog to match the background of a Bitmap

 

 
Powered by phpBB® Forum Software