Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - subclassing CXTPStatusBarThemeOffice203
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

subclassing CXTPStatusBarThemeOffice203

 Post Reply Post Reply
Author
Message
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 886
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Topic: subclassing CXTPStatusBarThemeOffice203
    Posted: 17 October 2018 at 3:48pm
I want to draw a gripper in the status bar. The CXTPStatusBarThemeOffice2013 DrawStatusBarGripper method does nothing. But, I see the method is virtual. So I subclassed from CXTPStatusBarThemeOffice2013 and implemented code to draw the gripper. CJ calls the method and I have a gripper.

But, my destructor is never called. CJ directly calls new on the CJ CXTPStatusBarThemeOffice2013 class in the paint manager code. And it calls delete too. The destructor in CXTPStatusBarThemeOffice2013 is not virtual so making mine virtual doesn't get the job done - my destructor is never called. I finally resorted to not declaring any instance data in the class and keeping static data around (I draw a transparent bitmap in DrawStatusBarGripper that I create one time).

So why have virtual methods if there is not an easy way to get CJ to use my subclass properly? I had to override SetTheme in our command bars subclass, call the CJ method and then delete m_pPaintManger->m_pStatusBarPaintManager (as it is always CXTPStatusBarThemeOffice2013 instance when the theme is xtpThemeOffice2013) Then I allocate my class and set the m_pStatusBarPaintManager pointer to an instance of my derived class.

The CXTPStatusBarThemeOffice2013 class doesn't do the implement dynamic nor even make the destructor virtual. But, I am assuming that just because I didn't see a more direct route to get my class instance in place doesn't mean there isn't one.

Am I missing something? Or will it take, at the very least, CJ making the destructor for XTPStatusBarThemeOffice2013 virtual? I hesitate to modify the CJ class as that is something I have to track and do with each update.
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.