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

Change background color of a CPropertyPage?

836 views
Skip to first unread message

skil...@gmail.com

unread,
Oct 17, 2007, 6:34:19 PM10/17/07
to
What's the right way to use a custom background color (white in this
case) with a CPropertyPage? I override OnEraseBkgnd and that works if
there aren't any controls on the page. But if I put a CStatic item on
the page, it seems to draw its own background (gray) even though I set
the CStatic to be transparent in the dialog editor in VS.

When my property sheet is in non-wizard mode so it draws tabs, the tab
control sets the background color somehow and the CStatic draws
correctly there with a white background, but I'm using wizard mode.

Check Abdoul

unread,
Oct 17, 2007, 10:41:47 PM10/17/07
to
See if the following google archive helps you

http://tinyurl.com/9hslu

--
Cheers
Check Abdoul
------------------

<skil...@gmail.com> wrote in message
news:1192660459.7...@z24g2000prh.googlegroups.com...

skil...@gmail.com

unread,
Oct 18, 2007, 2:23:34 AM10/18/07
to

So I figured out that if I override OnCtlColor in my property page
then I can return a different background color and that seems to work
with CStatic and other items.

But what if I wanted a background that's not just a simple color? I'd
like to be able to draw a background (maybe an watermark-style image)
as my property page background and not have CStatic and other controls
draw their own background. I would have though the transparent option
in the CStatic class would do this when set from the dialog editor,
but it doesn't seem to.

David Ching

unread,
Oct 18, 2007, 10:11:34 AM10/18/07
to
<skil...@gmail.com> wrote in message
news:1192664135.2...@i38g2000prf.googlegroups.com...

> On Oct 17, 3:34 pm, "skillz...@gmail.com" <skillz...@gmail.com> wrote:
>> What's the right way to use a custom background color (white in this
>> case) with a CPropertyPage? I override OnEraseBkgnd and that works if
>> there aren't any controls on the page. But if I put a CStatic item on
>> the page, it seems to draw its own background (gray) even though I set
>> the CStatic to be transparent in the dialog editor in VS.
>>
> So I figured out that if I override OnCtlColor in my property page
> then I can return a different background color and that seems to work
> with CStatic and other items.
>
> But what if I wanted a background that's not just a simple color? I'd
> like to be able to draw a background (maybe an watermark-style image)
> as my property page background and not have CStatic and other controls
> draw their own background. I would have though the transparent option
> in the CStatic class would do this when set from the dialog editor,
> but it doesn't seem to.
>

In OnCtlColor() you can also set the (CDC *) parameter, e.g.

pDC->SetBkMode(TRANSPARENT);


This paints the static control transparently so the background shines
through. One disadvantage is that this causes problems if the CPropertyPage
is repainted more than once or if the text of the CStatic needs to change...
since the static control is now transparent, there is no way to erase the
previous text before painting the new text, so you will get a jumbled mess
of both old text and the new text painted on top of it. But most CStatic
controls are not painted multiple times like this, so it works.

-- David

Victor

unread,
Oct 18, 2007, 2:48:47 PM10/18/07
to
Have a look at Joe's essay "Changing Dialog Box/CFormView Background Color":
http://www.flounder.com/dialog_box_color.htm

Victor

<skil...@gmail.com> wrote in message
news:1192660459.7...@z24g2000prh.googlegroups.com...

0 new messages