Changing the background color of a static text control 
Author Message
 Changing the background color of a static text control

    I have a dialog which has a bitmap on it.  I also have a couple static
text controls on top of the bitmap.  The background color of my bitmap is
white, how can I change the background color of the static control?  I've
tried making them transparent, but I lose the text as well.

Anthony

--
Product Availability Developer
Invensys Avantis - http://www.*-*-*.com/
Production Management Division



Tue, 09 Aug 2005 20:35:49 GMT  
 Changing the background color of a static text control

Quote:
>     I have a dialog which has a bitmap on it.  I also have a couple static
> text controls on top of the bitmap.  The background color of my bitmap is
> white, how can I change the background color of the static control?  I've
> tried making them transparent, but I lose the text as well.

WM_CTLCOLOR/CTLCOLOR_STATIC.


Tue, 09 Aug 2005 20:41:43 GMT  
 Changing the background color of a static text control
    Thanks for pointing me in the right direction.  I have it partially
working now.  I have my text showing in the color I want, and the
background, but the rest of the area for the control is being displayed in
black.  I can't find the method that changes that color.

Anthony

--
Product Availability Developer
Invensys Avantis - http://www.avantis.net
Production Management Division


Quote:


> >     I have a dialog which has a bitmap on it.  I also have a couple
static
> > text controls on top of the bitmap.  The background color of my bitmap
is
> > white, how can I change the background color of the static control?
I've
> > tried making them transparent, but I lose the text as well.

> WM_CTLCOLOR/CTLCOLOR_STATIC.



Tue, 09 Aug 2005 22:39:06 GMT  
 Changing the background color of a static text control

Quote:
>     Thanks for pointing me in the right direction.  I have it partially
> working now.  I have my text showing in the color I want, and the
> background, but the rest of the area for the control is being displayed in
> black.  I can't find the method that changes that color.

Are you returning an HBRUSH or the proper color? How and when are you doing
the CreateSolidBrush?
--
Jeff Partch [VC++ MVP]


Tue, 09 Aug 2005 22:56:40 GMT  
 Changing the background color of a static text control

Quote:
> Are you returning an HBRUSH or the proper color?

Sorry that should be HBRUSH 'of' the porper color. :(


Tue, 09 Aug 2005 23:11:09 GMT  
 Changing the background color of a static text control
    I'm not calling CreateSolidBrush. Where is the appropriate spot to call
it.  Here is a the code that I am using.

HBRUSH CBaseDialog::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor )
{
    // Call the base class implementation first! Otherwise, it may
    // undo what we're trying to accomplish here.
    HBRUSH hbr = CDialog::OnCtlColor( pDC, pWnd, nCtlColor );

    switch ( pWnd->GetDlgCtrlID() )
    {
        case IDC_TITLE:
            {
                // Set the text color to black
                pDC->SetTextColor( RGB(0, 0, 0) );
                pDC->SetBkColor( RGB(255, 255, 255) );
                hbr = (HBRUSH) m_brush->GetSafeHandle();
            }
            break;
     }

    return hbr;

Quote:
}

Anthony
--
Product Availability Developer
Invensys Avantis - http://www.avantis.net
Production Management Division


Quote:


> >     Thanks for pointing me in the right direction.  I have it partially
> > working now.  I have my text showing in the color I want, and the
> > background, but the rest of the area for the control is being displayed
in
> > black.  I can't find the method that changes that color.

> Are you returning an HBRUSH or the proper color? How and when are you
doing
> the CreateSolidBrush?
> --
> Jeff Partch [VC++ MVP]



Tue, 09 Aug 2005 23:44:09 GMT  
 Changing the background color of a static text control

Quote:
>     I'm not calling CreateSolidBrush. Where is the appropriate spot to
call
> it.  Here is a the code that I am using.

> HBRUSH CBaseDialog::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor )
> {
>     // Call the base class implementation first! Otherwise, it may
>     // undo what we're trying to accomplish here.
>     HBRUSH hbr = CDialog::OnCtlColor( pDC, pWnd, nCtlColor );

>     switch ( pWnd->GetDlgCtrlID() )
>     {
>         case IDC_TITLE:
>             {
>                 // Set the text color to black
>                 pDC->SetTextColor( RGB(0, 0, 0) );
>                 pDC->SetBkColor( RGB(255, 255, 255) );
>                 hbr = (HBRUSH) m_brush->GetSafeHandle();
>             }
>             break;
>      }

>     return hbr;
> }

Okay, how are you 'Creating' your 'm_brush' member variable?


Tue, 09 Aug 2005 23:49:37 GMT  
 Changing the background color of a static text control
    In my constructor I have:

m_brush = new CBrush(RGB(0, 0, 0));

    Which, now that I look at it is what's causing the problem.  I've just
changed it to show white and the dialog displays as I want.

Thanks for the help!

Anthony

--
Product Availability Developer
Invensys Avantis - http://www.avantis.net
Production Management Division


Quote:


> >     I'm not calling CreateSolidBrush. Where is the appropriate spot to
> call
> > it.  Here is a the code that I am using.

> > HBRUSH CBaseDialog::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor )
> > {
> >     // Call the base class implementation first! Otherwise, it may
> >     // undo what we're trying to accomplish here.
> >     HBRUSH hbr = CDialog::OnCtlColor( pDC, pWnd, nCtlColor );

> >     switch ( pWnd->GetDlgCtrlID() )
> >     {
> >         case IDC_TITLE:
> >             {
> >                 // Set the text color to black
> >                 pDC->SetTextColor( RGB(0, 0, 0) );
> >                 pDC->SetBkColor( RGB(255, 255, 255) );
> >                 hbr = (HBRUSH) m_brush->GetSafeHandle();
> >             }
> >             break;
> >      }

> >     return hbr;
> > }

> Okay, how are you 'Creating' your 'm_brush' member variable?



Wed, 10 Aug 2005 00:44:47 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Change Background Color of a Static Control ...

2. Change Background Color of Static Control

3. Capturing Message Woes (WAS: Change Background Color of Static Control)

4. How to change color of text static control

5. Changing Color of Static Text and other controls?

6. changing the font color of a static text control

7. Change colors in static text control

8. Changing the color of the text in a static control

9. how to change the text color of a CEdit or static control

10. Change text color and background color in CEditView

11. Change a part of Background color or a part of text color from CListCtrl

12. Win2K: static background color vs. CFormView background color

 

 
Powered by phpBB® Forum Software