Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Controls
  New Posts New Posts RSS Feed - Skinned background in owner-drawn CStatic control
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Skinned background in owner-drawn CStatic control

 Post Reply Post Reply
Author
Message
UglySwede View Drop Down
Groupie
Groupie


Joined: 27 February 2013
Location: Sweden
Status: Offline
Points: 17
Post Options Post Options   Thanks (0) Thanks(0)   Quote UglySwede Quote  Post ReplyReply Direct Link To This Post Topic: Skinned background in owner-drawn CStatic control
    Posted: 30 December 2014 at 11:12am
We are using Codejock/MFC to skin our application. It works fine and our customers like the look! :-)

We have a problem with a new control, though. It's a bit special, so we have to owner-draw it. We create it as CStatic with the SS_OWNERDRAW flag set, and we override the DrawItem() method. The control is drawn as we want it.

But we can't get the background right... Apparently, an owner-drawn CStatic does NOT automatically redraw the background. When we Invalidate() the control, it gets redrawn. But the background is not repainted, so the new value is painted above the previous. We have tried to paint the background ourselves, by handling WM_ERASEBKGND.

But how do we get the right color/brush? The default brush (the brush you get with GCLP_HBRBACKGROUND) is a white brush. We want the background brush of the current Codejock skin.

I'm no expert on owner-drawn controls. I'd be more than grateful for some good advice! :-)

  (a)  Are we doing something wrong? Could we set some flag so that the background of the CStatic gets repainted just like an ordinary (non-owner-drawn) CStatic? (Ordinary CStatics are of course painted with the correct skinned Codejock background.)

  (b)  Maybe CStatic is the wrong choise. Should we use some other type of control for our owner-drawn control?

  (c)  Are there some way to get the background brush for the current Codejock skin? It's no problem at all for us to paint the background ourselves, but we need the correct brush.

Best regards

Anders from Sweden
Back to Top
Insad View Drop Down
Groupie
Groupie
Avatar

Joined: 28 October 2004
Location: The Netherlands
Status: Offline
Points: 55
Post Options Post Options   Thanks (0) Thanks(0)   Quote Insad Quote  Post ReplyReply Direct Link To This Post Posted: 18 May 2015 at 7:01am
I have the same issue for some time now and never found a solution.

We have decided to disable skins for the time being and only use it in demos, promotion stuff, etc. until CJ finds a solution or until I have some time left over (will not happen very soon!) so I can look at it myself..

So please CodeJock can you provide an answer or solution Smile

Products in use: XTP version 13.4.2/15.3.1/16.4.0/17.3.0
Platforms: Win2003(R2)/Win2008(R2)/Win7/Win2011/Win8(.1)/Win2012(R2)/Win10 (x86/x64)
Langs: VC++ (MFC) 6/2005/2008/2013/2015/2017
Back to Top
mcmastl View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 April 2015
Status: Offline
Points: 79
Post Options Post Options   Thanks (0) Thanks(0)   Quote mcmastl Quote  Post ReplyReply Direct Link To This Post Posted: 18 May 2015 at 12:52pm
Hello and thank you for bringing this to our attention.  We have informed the development team and will be looking into the issue.  Are you able to reproduce this issue with any of our samples?
Luke McMasters, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Insad View Drop Down
Groupie
Groupie
Avatar

Joined: 28 October 2004
Location: The Netherlands
Status: Offline
Points: 55
Post Options Post Options   Thanks (0) Thanks(0)   Quote Insad Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 9:51am
I'm trying to get a sample you can use but it doesn't seem to be that easy;

If I try the Skin samples (MDI/SDI/etc) I can dynamically add CStatics to it and they all work without issues.

In my case I'm using an MDI application with RibbonBar and Theming.
When I add skinning the problem arises on a view in which I add controls, in a dynamic way, from a XML file onto a CXTPTabCtrl. All these controls work without color issues, with the exception of CStatic and checkboxes.. (Just found that one out, which is odd since the other CButton based controls, like radio buttons, look nice)

The background of the CStatic and the checkbox always seem to be white. And when I disable skinning the background happens to be white on this CXTPTabCtrl.

Currently I don't have much time but I will try to look what happens if I disable skinning and set the CXTPTabCtrl color to blue or something..

Products in use: XTP version 13.4.2/15.3.1/16.4.0/17.3.0
Platforms: Win2003(R2)/Win2008(R2)/Win7/Win2011/Win8(.1)/Win2012(R2)/Win10 (x86/x64)
Langs: VC++ (MFC) 6/2005/2008/2013/2015/2017
Back to Top
Insad View Drop Down
Groupie
Groupie
Avatar

Joined: 28 October 2004
Location: The Netherlands
Status: Offline
Points: 55
Post Options Post Options   Thanks (1) Thanks(1)   Quote Insad Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 11:10am
Okay.. I've got it working as expected..

Some 'inexperienced' junior developer had build his own color customization in a CTXPTabCtrl  derived class which eventually screwed up all kinds of things..

After removing all that stuff theming and skinning seem to work without issues.
And the part for which the color customization was made also works since we can now handle that in the skins Tongue

Anyway, thanks for listening Wink

* Edit: somewhat more friendly to junior developers Wink
Products in use: XTP version 13.4.2/15.3.1/16.4.0/17.3.0
Platforms: Win2003(R2)/Win2008(R2)/Win7/Win2011/Win8(.1)/Win2012(R2)/Win10 (x86/x64)
Langs: VC++ (MFC) 6/2005/2008/2013/2015/2017
Back to Top
mcmastl View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 April 2015
Status: Offline
Points: 79
Post Options Post Options   Thanks (0) Thanks(0)   Quote mcmastl Quote  Post ReplyReply Direct Link To This Post Posted: 19 May 2015 at 12:00pm
Hi Insad,
Im glad to hear you have resolved the issue! 
Luke McMasters, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.219 seconds.