Print Page | Close Window

Saving Quick Access Toolbar

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=22328
Printed Date: 17 June 2025 at 2:00am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Saving Quick Access Toolbar
Posted By: Dan
Subject: Saving Quick Access Toolbar
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net