Click here to Skip to main content
15,891,184 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
QuestionSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ Pin
VeganFanatic24-Jul-11 8:44
VeganFanatic24-Jul-11 8:44 
QuestionRe: SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ Pin
Richard MacCutchan24-Jul-11 21:09
mveRichard MacCutchan24-Jul-11 21:09 
AnswerRe: SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ Pin
VeganFanatic25-Jul-11 2:25
VeganFanatic25-Jul-11 2:25 
GeneralRe: SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ Pin
Richard MacCutchan25-Jul-11 3:33
mveRichard MacCutchan25-Jul-11 3:33 
AnswerRe: SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\ Pin
MicroVirus6-Sep-11 2:18
MicroVirus6-Sep-11 2:18 
QuestionHelp regarding method WNetCancelConnection2 Pin
tasumisra18-Jul-11 23:42
tasumisra18-Jul-11 23:42 
AnswerRe: Help regarding method WNetCancelConnection2 Pin
Richard MacCutchan19-Jul-11 0:35
mveRichard MacCutchan19-Jul-11 0:35 
QuestionProblems with Docking Toolbars Pin
Syamlal S Nair18-Jul-11 17:59
Syamlal S Nair18-Jul-11 17:59 
Hi,

I have been trying to adopt certain new MFC classes(version-10.0) into my application (written based on MFC 7.0 originally).
A brief of the context is as below.

I have an application with the main window class, CMainFrame derived from CMDIFrameWnd, and the toolbars created from CToolBar.

These ToolBars are fitted into objects of a class called CMyDialogBar. CMyDialogBar is derived from CDialogBar (which is a child of CControlBar, as you know).

In order to serialize the dock information, in one of the Dlls of my application, CDockState object is used in the code. A pointer to the application's main window is retrieved using AfxGetMainWnd() and dynamic casted to CFrameWnd, and methods like GetDockState() etc. are called against it. Also, CControlBarInfo pointer is used to get each control bar information from CDockState object, and remove a couple of them from the list based on some specific logic before
saving it for persisting.

Now starts the real problem.

I need to incorporate CMFCToolBar instead of CToolBar, and the application's main window is changed to derive from CMDIFrameWndEx instead of CMDIFrameWnd.CMyDialogBar class is now altered to derive from 'CDockablePane' (instead of CDialogBar) as I found in some forums.

I get debug assertion failures, wherever CControlBarInfo is used, and wherever GetDockState() or SetDockState() is called since those methods refer to CControlbar objects/pointers internally.

Sample code from dll, is as shown here:

void CDialogBarService::RestoreState()
{
	CFrameWnd* pWnd = DYNAMIC_DOWNCAST( CFrameWnd, OldStyleAfxGetMainWnd());
	pWnd->PostMessage( WM_STATUS_UPDATE, 0, 0);
	
	ASSERT( pWnd != NULL);

	// Restore from user object
	//
	CDockState state;

	CMyContext context;
	CMwSession session;
	CProxyUser*	pUser = session.GetUserProxy();
	if ( pUser != NULL && pUser->GetInstrProfileContext( NAME_LAYOUT_DIALOG_BAR_SERVICE, context) )
	{
		if ( context.Exists( NAME_TOOLBAR_STATE) )
		{
			CByteArray data;
			if ( context[NAME_TOOLBAR_STATE].Get( data) )
			{
				// create a RawByteFile with a pointer to the byte array
				// reqd as the archive object requires a file not an array
				//
				CRawByteFile file( data.GetSize(), data.GetData());

				// create an archive object, set to LOAD
				//
				CArchive ar( &file, CArchive::load);

				// extract the toolbar state from the archive
				//
				state.Serialize( ar);
			}
		}

		// Do some pre-processing to ensure that we get no errors
		//
		// If our toolbars are hidden they are not restored and so we can get
		// error conditions in SetDockState.  This code just purges
		// the saved state of any toolbars that don't exist at this time
		//
		for ( int i = state.m_arrBarInfo.GetUpperBound(); i >= 0 ; i-- )
		{
			CControlBarInfo* pInfo = reinterpret_cast< CControlBarInfo*>( state.m_arrBarInfo[i]);
			ASSERT( pInfo != NULL);
			pInfo->m_pBar = pWnd->GetControlBar( pInfo->m_nBarID);
			if ( pInfo->m_pBar == NULL )
			{
				CControlBarInfo* pState = reinterpret_cast< CControlBarInfo*>( state.m_arrBarInfo[i]);
				state.m_arrBarInfo.RemoveAt( i);
				delete pState;
			}
		}

		// Finally set toolbar state		
		pWnd->SetDockState( state);
		
	}
}


In the above sample code, i even tried to replace CFrameWnd pointer to CMDIFrameWndEx pointer, but the method call SetDockState() was giving compilation error, since it is made protected in the new MFC class hierarchy. Since i am standing in a dll, i cannot have my CMainFrame class instantiated here, to call a public method or overridden member function, which in turn can invoke the protected member.


Questions-

1. Which class i can use for replacing CControlBarInfo in the context of DockablePanes?

2. Why those methods like SetDockState(), GetDockingManager() etc. made protected for CMDIFrameWndEx class in new hierarchy?

3. Is there any other mechanism/classes using which i could achieve the above persistence?

Thanks in advance.

Regards
Syamlal
SYAMLAL

QuestionCompiling with VS2010 Pin
Kyudos14-Jul-11 13:39
Kyudos14-Jul-11 13:39 
AnswerRe: Compiling with VS2010 Pin
Albert Holguin15-Jul-11 3:54
professionalAlbert Holguin15-Jul-11 3:54 
GeneralRe: Compiling with VS2010 [modified] Pin
Kyudos17-Jul-11 17:50
Kyudos17-Jul-11 17:50 
GeneralRe: Compiling with VS2010 Pin
Albert Holguin18-Jul-11 4:33
professionalAlbert Holguin18-Jul-11 4:33 
GeneralRe: Compiling with VS2010 Pin
Kyudos18-Jul-11 11:13
Kyudos18-Jul-11 11:13 
GeneralRe: Compiling with VS2010 Pin
Albert Holguin18-Jul-11 11:19
professionalAlbert Holguin18-Jul-11 11:19 
GeneralRe: Compiling with VS2010 Pin
Kyudos19-Jul-11 10:40
Kyudos19-Jul-11 10:40 
GeneralRe: Compiling with VS2010 Pin
Albert Holguin19-Jul-11 11:32
professionalAlbert Holguin19-Jul-11 11:32 
QuestionATL CString Pin
hrishi32110-Jul-11 18:49
hrishi32110-Jul-11 18:49 
AnswerRe: ATL CString Pin
Cool_Dev10-Jul-11 21:02
Cool_Dev10-Jul-11 21:02 
GeneralRe: ATL CString Pin
hrishi32110-Jul-11 21:18
hrishi32110-Jul-11 21:18 
GeneralRe: ATL CString Pin
Cool_Dev11-Jul-11 4:36
Cool_Dev11-Jul-11 4:36 
GeneralRe: ATL CString Pin
hrishi32111-Jul-11 17:43
hrishi32111-Jul-11 17:43 
GeneralRe: ATL CString Pin
Richard MacCutchan11-Jul-11 22:26
mveRichard MacCutchan11-Jul-11 22:26 
GeneralRe: ATL CString Pin
BWake8-Aug-11 5:47
BWake8-Aug-11 5:47 
AnswerRe: ATL CString Pin
Richard MacCutchan11-Jul-11 5:03
mveRichard MacCutchan11-Jul-11 5:03 
GeneralRe: ATL CString Pin
hrishi32111-Jul-11 17:45
hrishi32111-Jul-11 17:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.