Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - QuickAccessToolbar Save and  Load [Solved]
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

QuickAccessToolbar Save and Load [Solved]

 Post Reply Post Reply
Author
Message
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Topic: QuickAccessToolbar Save and Load [Solved]
    Posted: 20 July 2022 at 5:10am
I can't find any examples on how to save and load the controls in the QuickAccessToolbar.

I managed to save and load the using the code below.

Right after adding a new control to the QuickAccessToolbar using the CXTPRibbonCustomizeQuickAccessPage everyting works.

The problem is that after saving and loading the QuickAccesControls they appear correct in the QuickAccessToolbar, but the controls are not working?

void CMainWindow::LoadQuickAccessControls()
{
CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, GetCommandBars()->GetMenuBar());
if (pRibbonBar == NULL) return;
CXTPRibbonQuickAccessControls *pQA = pRibbonBar->GetQuickAccessControls();
if (pQA == NULL) return;
XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
param.pCommandBars = GetCommandBars();
param.bSaveOriginalControls = FALSE;
param.bSerializeControls = TRUE;
param.bSerializeActions = TRUE;
param.bSerializeLayout = FALSE;
param.bSerializeOptions = FALSE;

HKEY hKey = NULL;
if (::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\My Company\\My App"), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
return;
CXTPPropExchangeRegistry px(TRUE, hKey, _T("QuickAccessLayout"));
px.m_dwData = DWORD_PTR(&param);
pQA->DoPropExchange(&px);
::RegCloseKey(hKey);
}
void CMainWindow::SaveQuickAccessControls()
{
CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, GetCommandBars()->GetMenuBar());
if (pRibbonBar == NULL) return;
CXTPRibbonQuickAccessControls *pQA = pRibbonBar->GetQuickAccessControls();
if (pQA == NULL) return;
XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
param.bSaveOriginalControls = FALSE;
param.bSerializeControls = TRUE;
param.bSerializeActions = TRUE;
param.bSerializeLayout = FALSE;
param.bSerializeOptions = FALSE;

HKEY hKey = NULL;
if (::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\My Company\\My App"), 0, KEY_WRITE, &hKey) != ERROR_SUCCESS)
return;
CXTPPropExchangeRegistry px(FALSE, hKey, _T("QuickAccessLayout"));
px.m_dwData = DWORD_PTR(&param);
pQA->DoPropExchange(&px);
::RegCloseKey(hKey);
}

This fails:
XTPCommandBar.cpp line 653:
if (!pControl->OnSetPopup(TRUE))

Since m_pCommandBar is NULL in XTPControlPopup.cpp line 295:
if (!m_pCommandBar)

Please help.
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Posted: 29 July 2022 at 2:56am
Maybe a good idea to add these methods to the Codejock Ribbon MDI Sample for others to use??

void CMainFrame::LoadQuickAccessControls()
{
  CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, 
          GetCommandBars()->GetMenuBar());
  if (pRibbonBar == NULL) return;
  CXTPRibbonQuickAccessControls *pQA = pRibbonBar->GetQuickAccessControls();
  if (pQA == NULL) return;

  XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
  param.pCommandBars = GetCommandBars();
  param.bSaveOnlyCustomized = FALSE;
  param.bLoadSilent = TRUE;
  param.bSaveOriginalControls = TRUE;
  param.bSerializeActions = TRUE;
  param.bSerializeControls = TRUE;
  param.bSerializeDesignerControls = TRUE;
  param.bSerializeImages = FALSE;
  param.bSerializeLayout = TRUE;
  param.bSerializeOptions = TRUE;

  HKEY hKey = NULL;
  if (::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Codejock Software Sample Applications
          \\Codejock Ribbon MDI Sample"), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
  {
    pRibbonBar->GetQuickAccessControls()->Reset();
    return;
  }
  ::RegCloseKey(hKey);

  if (::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Codejock Software Sample Applications
          \\Codejock Ribbon MDI Sample"), 0, KEY_READ, &hKey) != ERROR_SUCCESS)
    return;

  pRibbonBar->GetQuickAccessControls()->RemoveAll();

  CXTPPropExchangeRegistry px(TRUE, hKey, _T("QuickAccessLayout"));
  px.m_dwData = DWORD_PTR(&param);
  pQA->DoPropExchange(&px);
  ::RegCloseKey(hKey);
}
void CMainFrame::SaveQuickAccessControls()
{
  CXTPRibbonBar* pRibbonBar = DYNAMIC_DOWNCAST(CXTPRibbonBar, 
          GetCommandBars()->GetMenuBar());
  if (pRibbonBar == NULL) return;
  CXTPRibbonQuickAccessControls *pQA = pRibbonBar->GetQuickAccessControls();
  if (pQA == NULL) return;

  XTP_COMMANDBARS_PROPEXCHANGE_PARAM param;
  param.pCommandBars = NULL;// GetCommandBars();
  param.bSaveOnlyCustomized = FALSE;
  param.bLoadSilent = TRUE;
  param.bSaveOriginalControls = FALSE;
  param.bSerializeActions = TRUE;
  param.bSerializeControls = TRUE;
  param.bSerializeDesignerControls = TRUE;
  param.bSerializeImages = FALSE;
  param.bSerializeLayout = TRUE;
  param.bSerializeOptions = TRUE;

  HKEY hKey = NULL;
  if (::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Codejock Software Sample Applications
          \\Codejock Ribbon MDI Sample"), 0, KEY_WRITE, &hKey) != ERROR_SUCCESS)
    return;
  CXTPPropExchangeRegistry px(FALSE, hKey, _T("QuickAccessLayout"));
  px.m_dwData = DWORD_PTR(&param);
  pQA->DoPropExchange(&px);
  ::RegCloseKey(hKey);
}  
Product: Xtreme ToolkitPro (24.0.0)
Platform: Windows 10 (x64)
Language: Visual Studio 2017 (C++)
Back to Top
Fredrik View Drop Down
Senior Member
Senior Member


Joined: 22 June 2005
Status: Offline
Points: 235
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fredrik Quote  Post ReplyReply Direct Link To This Post Posted: 30 July 2022 at 7:39am
A question, why would you need to load/save Quick Access controls using separate functions? 

I just create the ribbon bar including the QAT, and then call LoadCommandBars(L"MySection", TRUE); and all previous customizations are then loaded.


Windows 10, Visual Studio 20157, Toolkit Pro 18.3.0
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.203 seconds.