Re: My controls are too transparent

r_z_aret_at_pen_fact.com
Date: 02/27/04


Date: Fri, 27 Feb 2004 18:21:07 -0500

If you really want a transparent background, I can't help. If,
however, you would be content with a solid color that matches the
color of the parent window, I have some leads.

I spent quite a bit of time (actual and elapsed) trying to do that,
and mostly succeeded (except for some Windows CE emulators). I suggest
starting with my 14 Nov 03 contribution to a thread called "Dialog
Background" in comp.os.ms-windows.programmer.win32

On Wed, 25 Feb 2004 11:11:28 +0100, "Kirk" <NO SPAM> wrote:

>Hello,
>
>I've a form view with some static controls. I want to change background
>color view and make static controls transparent. For that, i handle
>ON_WM_CTLCOLOR and ON_WM_ERASEBKGND messages :
>
>// change background color
>BOOL CMyClass::OnEraseBkgnd(CDC* pDC)
>{
> CRect rect;
> pDC->GetClipBox(&rect);
> CBrush brush(RGB(100,100,100);
> CBrush* pOldBrush = pDC->SelectObject(&brush);
> pDC->PatBlt( rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
> pDC->SelectObject(pOldBrush);
> return TRUE;
>}
>// set transparent static controls
>HBRUSH CMyClass::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
>{
> HBRUSH hbr;
>
> switch (nCtlColor) {
> case CTLCOLOR_STATIC:
> pDC->SetBkMode(TRANSPARENT);
> hbr = (HBRUSH) GetStockObject(NULL_BRUSH);
> break;
> default:
> hbr=CFormView::OnCtlColor(pDC,pWnd,nCtlColor);
> }
> return hbr;
>}
>
>My problem is that i can see inside static controls the windows desktop and
>not the background color of the view !
>
>What's wrong with this code ?
>
>Thanks in advance.
>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com



Relevant Pages