Click here to Skip to main content
12,695,624 members (25,567 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C++ MFC
Hello , so my problem is with docking of a bar . The problem is that the application isn't reading properly from the registry when one tab is docked over other tab. The error is CArchiveException. After some debugging i found that CRuntimeClass::FromName returns NULL and this is the reason for the exception . The class which isn't recognized is CBCGPTabbedControlBar from BCGSoft. It is part from the class CBGPDockingControlBar which i am using for my docking bars as a inherited class. I saw that in FromName (arccore.cpp) the classes in the list are populated from
AFX_MODULE_STATE* pModuleState = AfxGetModuleState();

The class CBCGPTabbedControlBaris serialized and it had CRunTimeClass structure.I tested it with
CObject *mObject = new CBCGPTabbedControlBar;
       mObject->IsKindOf(RUNTIME_CLASS( CBCGPTabbedControlBar));

When i read for AfxGetModuleState() i understand that there are 3 kinds of MFC states: Module State, Process State, and Thread State and AfxGetModuleState()returns only the structures with module state . I should say that this is happening in a thread so my question is: is it CBCGPTabbedControlBar with Thread state? and if yes how could set him with module state so it would be recognized from FromName function.(reminding its a BCGSoft defined Class).

I saw article about MS adding some BCGSoft classes. I thought i can change the class CBGPDockingControlBar into CMFCDockingControlBar but this doesn't exist
My other question is: is there similar CMFCXXX class for CBGPDockingControlBar?

Thx for your help
Posted 12-Jun-12 22:32pm
Argonia12K
Updated 12-Jun-12 22:44pm
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

this may not be 100% related to your proble, but MFC has a handle map for HWNDs to CWnd* pointers. These handle maps are thread specific. So if you are trying to lookup an MFC CWnd type pointer it will not be found.

As you mention you are doing this work in a thread, it sounds like you probably need to move this functionality to the UI thread which does contain the handle map.

As a general rule I would never access a CWnd* pointer from a worker thread. If you do need to update controls etc, you should post/send a message from your worker thread to the UI thread and have that update the windows.
  Permalink  
Comments
Argonia 13-Jun-12 9:44am
   
It is in the UI Thread (more specifically the one which loads the window and all the bars and ets.)
I wonder why when in FromName loads the AFX_MODULE_STATE s the pModuleState->m_classList is empty (i am not sure if the CBCGPTabbedControlBar should be here )
and pModuleState->m_libraryList doesn't contain the BCGSoft library(classes)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Well this is embarrassing. After one good night sleep and more reading in CodeProject articles i realized that the library of BCGSoft was never loaded with
HMODULE m_hResDll = LoadLibrary(_T("xxx.dll"));


So now it recognizes the class but the problem remains. Now it trows exception because CBCGPTabbedControlBar is not derived from CBGPDockingControlBar
//arcobj.cpp code
...

// check for correct derivation
	if (pClassRefRequested != NULL &&
		!pClassRef->IsDerivedFrom(pClassRefRequested))
	{
	   AfxThrowArchiveException(CArchiveException::badClass, m_strFileName);
	}
...


After serious testing i saw that the problem was elsewhere. The problem was that when its reading from LoadState its looking for a object of this type CBCGPTabbedControlBar and because it cant find it (the Frame isn't created by the usual way with CSingleDocTemplate )it gives the exception.
After creating new class derived from CBCGPTabbedControlBar and using the function CBCGPDockingControlBar::SetTabbedControlBarRTC i managed to fix the problem.
And i didn't need the LoadLibrary(_T(xxx.dll));
  Permalink  
v2
Comments
Volynsky Alex 10-Aug-12 4:16am
   
Good answer Argonia!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 10 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100