Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can the background of a CStatic be Set Transparent?

170 views
Skip to first unread message

James Roy

unread,
Sep 12, 2000, 7:09:20 PM9/12/00
to
The subject asks it. Anyone have any experience or samples setting the
background of a CStatic transparent so as not to clash with DIB used as the
background in a form view?
Thanks


Carter Smith

unread,
Sep 12, 2000, 8:49:58 PM9/12/00
to

This is just be a matter of adding an OnCtlColor handler to your form view
class, as described in knowledge base article "Q132080 HOWTO: Change the
Color of an MFC Child Control Class". You can determine which control on the
form view is causing the OnCtlColor call by checking the nCtlColor and pWnd
parameters (for example, check pWnd->GetDlgCtrlID()). When OnCtlColor is
called for your static control, set the background mode to transparent and
return a stock hollow brush, something like this:

pDC->SetBkMode(TRANSPARENT);
return (HBRUSH) GetStockObject(HOLLOW_BRUSH);

--Carter


"James Roy" <Jame...@worldnet.att.net> wrote in message
news:AIyv5.5965$M37.4...@bgtnsc07-news.ops.worldnet.att.net...

jame...@my-deja.com

unread,
Sep 14, 2000, 3:00:00 AM9/14/00
to
Excellent suggestion, works great.
One thing though, How can I accomplish the same
thing for Other Controls like CSliderCtrl. They
appear to misbehave badly in a similar fashion.


In article
<eVnOWyR...@cppssbbsa02.microsoft.com>,


"Carter Smith" <cart...@msn.com> wrote:
>
> This is just be a matter of adding an
OnCtlColor handler to your form view
> class, as described in knowledge base
article "Q132080 HOWTO: Change the
> Color of an MFC Child Control Class". You can
determine which control on the
> form view is causing the OnCtlColor call by
checking the nCtlColor and pWnd
> parameters (for example, check pWnd-
>GetDlgCtrlID()). When OnCtlColor is
> called for your static control, set the
background mode to transparent and
> return a stock hollow brush, something like
this:
>
> pDC->SetBkMode(TRANSPARENT);
> return (HBRUSH) GetStockObject
(HOLLOW_BRUSH);
>
> --Carter
>
> "James Roy" <Jame...@worldnet.att.net> wrote
in message

> news:AIyv5.5965$M37.410010@bgtnsc07-


news.ops.worldnet.att.net...
> > The subject asks it. Anyone have any
experience or samples setting the
> > background of a CStatic transparent so as not
to clash with DIB used as
> the
> > background in a form view?
> > Thanks
> >
> >
>
>

Sent via Deja.com http://www.deja.com/
Before you buy.

Carter Smith

unread,
Sep 14, 2000, 3:00:00 AM9/14/00
to

This will depend on the kind of control. I haven't tried this, but for the
CSliderCtrl, you might try handling NM_CUSTOMDRAW notifications.

<jame...@my-deja.com> wrote in message news:8prkkb$vd4$1...@nnrp1.deja.com...


> Excellent suggestion, works great.
> One thing though, How can I accomplish the same
> thing for Other Controls like CSliderCtrl. They
> appear to misbehave badly in a similar fashion.
>
>
> In article
> <eVnOWyR...@cppssbbsa02.microsoft.com>,
> "Carter Smith" <cart...@msn.com> wrote:
> >

> > This is just be a matter of adding an
> OnCtlColor handler to your form view
> > class, as described in knowledge base
> article "Q132080 HOWTO: Change the
> > Color of an MFC Child Control Class". You can
> determine which control on the
> > form view is causing the OnCtlColor call by
> checking the nCtlColor and pWnd
> > parameters (for example, check pWnd-
> >GetDlgCtrlID()). When OnCtlColor is
> > called for your static control, set the
> background mode to transparent and
> > return a stock hollow brush, something like
> this:
> >
> > pDC->SetBkMode(TRANSPARENT);
> > return (HBRUSH) GetStockObject
> (HOLLOW_BRUSH);
> >
> > --Carter
> >
> > "James Roy" <Jame...@worldnet.att.net> wrote
> in message

> > news:AIyv5.5965$M37.410010@bgtnsc07-


> news.ops.worldnet.att.net...
> > > The subject asks it. Anyone have any
> experience or samples setting the
> > > background of a CStatic transparent so as not
> to clash with DIB used as
> > the
> > > background in a form view?
> > > Thanks
> > >
> > >
> >
> >
>
>
>

0 new messages