Link to home
Start Free TrialLog in
Avatar of jkribaHTS
jkribaHTS

asked on

Transparent CStatic in CView

Hi,
  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

Regards
JK
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start 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 https://msdn.microsoft.com/de-de/library/0wwk06hc.aspx

Sara
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.

Sara