Transparent CStatic in CView

  I am trying to Create a Static Text Control dynamically in the View [Derived from CView] of an MFC SDI application,
And i want to provide Transparency for the Text Background since the View has some texture in the background,
I have tried various options by Overriding the OnDraw of the CStatic control class and setting SetBKMode(Transparent)..
Nothing works with the View, Any help will be really helpful..Thanks

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ypu can use 'SetLayeredWindowAttributes()' ( to control that, see also 

The idea would be to

HWND hWnd = m_myStaticCtrl.m_hWnd;

Open in new window

If you'd use 255 instead of 128, the control would be opaque.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
the CStatic doesn't have a OnDraw member functiion. i assume you derived from CView and have an override of CView::OnDraw. unfortunately this function is unrelated to the controls which you have placed on it. it paints the view's client area but nothing else.

if you want to change the colors of a child control, you need to override the OnCtlColor member function of our view class.

see sample code at

the question should be deleted.

the solution jkr posted cannot work since the status words stored by SetWindowLong were not evaluated again for static mfc controls. hence the call was without any effect. the attributes only could be set when creating the controls what is not easily to achieve since mfc static controls cannot made owner-drawn windows. the way out is to create a customized window derived from CWnd but surely that is another game.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.