Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - Saving Quick Access Toolbar
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Saving Quick Access Toolbar

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


Joined: 11 June 2014
Status: Offline
Points: 16
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dan Quote  Post ReplyReply Direct Link To This Post Topic: Saving Quick Access Toolbar
    Posted: 17 June 2014 at 6:51am
Hi,

I'm trying to load/save user's custom changes to the Quick Access Toolbar using Toolkit Pro v16.3.1.

I originally thought that something like this would work in the OnClose function ...

CFile fSettings;
if (fSettings.Open("c:\\setttings.xtb", CFile::modeCreate | CFile::modeWrite))
{
CArchive ar(&fSettings, CArchive::store);
CXTPPropExchangeArchive px(ar);

CXTPRibbonQuickAccessControls *pQA = m_pRibbonBar->GetQuickAccessControls();
pQA->DoPropExchange(&px); // Causes ASSERT here
ar.Close();
fSettings.Close();
}

The CXTPRibbonQuickAccessControls class doesn't have its own DoPropExchange so this function is calling CXTPControls::DoPropExchange, and that seems to be expecting the m_dwData member of the CXTPPropExchange to be a pointer to a XTP_COMMANDBARS_PROPEXCHANGE_PARAM struct...

void CXTPControls::DoPropExchange(CXTPPropExchange* pPX)
{
ASSERT(pPX->m_dwData != 0);
XTP_COMMANDBARS_PROPEXCHANGE_PARAM* pParam = (XTP_COMMANDBARS_PROPEXCHANGE_PARAM*)pPX->m_dwData;
...
}

I'm not sure how I supposed to know that - so I suspect that I shouldn't be doing this.

However, I continued and fixed the assert by adding these lines before the DoPropExchange call...

XTP_COMMANDBARS_PROPEXCHANGE_PARAM param; 
param.bSaveOnlyCustomized = FALSE;
param.bSaveOriginalControls = FALSE;
param.bSerializeActions = FALSE;
param.bSerializeControls = TRUE;
param.bSerializeDesignerControls = FALSE;
param.bSerializeImages = FALSE;
param.bSerializeLayout = FALSE;
param.bSerializeOptions = FALSE;
px.m_dwData = (DWORD_PTR)&param;

That seemed to solve the problem - and indeed it appears that the quick access toolbar settings are saved to c:\\settings.xtb.

Loading had similar issues ... the m_dwData had to be initialized to a pointer to the XTP_COMMANDBARS_PROPEXCHANGE_PARAM struct, and I had to set  param.pCommandBars = GetCommandBars().

Saving & Loading then appears to be working - but is there a better way of accomplishing this?

The Ribbon Bar sample applications included with Codejock 16.3.1 both have saving/loading routines commented out and enabling them either results in a crash, or the changes made to the Quick Access Toolbar not being saved and restored anyway.

Any help would be appreciated.

Thanks,

Dan
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.449 seconds.