Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Use SetTheme in DLL
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Use SetTheme in DLL

 Post Reply Post Reply
Author
Message
Robby View Drop Down
Newbie
Newbie


Joined: 17 August 2005
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Robby Quote  Post ReplyReply Direct Link To This Post Topic: Use SetTheme in DLL
    Posted: 17 August 2005 at 9:32am

 my program will show a regular dialog, it's a normal cdialog,and it has a cbotton control, press this button will show another cdialog,this dialog is defined in my dll.

 in this dialog,I add a cxtbotton to it, and  then m_button.SetTheme(new CXTButtonThemeOfficeXP(TRUE)).

 it's ok when i show this dialog,the theme looks nice,but when i quit the program , an error occured,i'm sorry i can't remember the detail infomation about this error. this error occured both in dynamic link with mfc dll and static link with mfc. i test in a normal dialog program(normal means i build an .exe program not .dll),it works well.

i  just wanta know is there anything i should do when i use settheme function in my dll?

any advice would be appreciated!

P.S: i  use XT pro and VC6



Edited by Robby
Back to Top
Robby View Drop Down
Newbie
Newbie


Joined: 17 August 2005
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Robby Quote  Post ReplyReply Direct Link To This Post Posted: 17 August 2005 at 9:06pm

the error says

debug assertion failed

in xtthememanager.cpp

i debug the code found that

the error happened in

CXTThemeManager::~CXTThemeManager()
{
 POSITION pos = m_mapDefaultFactories.GetStartPosition();
 void* pThemeFactoryClass;
 CXTThemeManagerStyleFactory* pFactory = 0;
 while(pos)
 {
  m_mapDefaultFactories.GetNextAssoc(pos, pThemeFactoryClass, (void *&)pFactory);
  delete pFactory;
 }

 ASSERT(m_factoryList.m_pHead == 0); //here
 m_factoryList.RemoveAll();
}

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 18 August 2005 at 4:15am

Thank you for details, we will try to reproduce it to find solution for you.

Any hints what is your dll is? (MFC extension, MFC dll, simple Win32 dll)

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 18 August 2005 at 6:15am

2005-08-18_061524_demo.zip

Check sample. DOn't see any assert errors :(

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Robby View Drop Down
Newbie
Newbie


Joined: 17 August 2005
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Robby Quote  Post ReplyReply Direct Link To This Post Posted: 18 August 2005 at 9:23am

thank you for your reply.

it's a mfc dll. just some dialog things,i have checked sample for several times.

may be i should check again.

Back to Top
franji1 View Drop Down
Groupie
Groupie
Avatar

Joined: 28 June 2005
Status: Offline
Points: 70
Post Options Post Options   Thanks (0) Thanks(0)   Quote franji1 Quote  Post ReplyReply Direct Link To This Post Posted: 22 August 2005 at 3:54pm

I had a similar problem with version 8.6, which has to do NOT with when the DLL that "new"ed the specific custom theme, but with WHERE the constructor/destructor code of the custom theme is located.  In my case, the custom theme code is IN A DLL - this is BAD, as I will describe below.

The "global theme manager" is a static? global? object that gets "free"ed when the .EXE shuts down (I can't remember the specific call, but basically the C++ startup/shutdown code calls the destructors of all "global/static" objects at shutdown).  Regardless, the .DLL that has the code for the custom theme is now UNLOADED when the global theme manager is destroyed.  What's the big deal?  The deal is that the destructor of a theme is VIRTUAL, hence when the code in the global theme manger that deletes this custom theme is CALLED, the DLL that this virtual function pointed to is now GONE!

The "correct" fix is to implement ALL custom themes in the main .EXE, but I wanted mine in a DLL for reasons that are only valid to me, cuz sometimes I like it that way  

My fix for shutting down with custom themes implemented in a DLL, though crude, works.  "Standard" themes do not have this problem because their code is still "in memory" (even though we use the XTP as a DLL?!?).  Anyway, all I do is call CXTPPaintManager::SetTheme(xtpThemeOfficeXP) first thing in the OnDestroy of my main CFrameWnd dervied window. This causes the current theme to be swapped out with one of the "predefined" themes at the last possible moment. The previous theme's destructor is called while its code is still loaded, hence no crash at shutdown!

Back to Top
Robby View Drop Down
Newbie
Newbie


Joined: 17 August 2005
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote Robby Quote  Post ReplyReply Direct Link To This Post Posted: 25 August 2005 at 7:41am

that make sense!

but my problem haven't appear for several days ,i do nothing .

it's amazing....

anyway thank you for your explicit reply

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.047 seconds.