Print Page | Close Window

Saving dock state of CXTPCommandBars to registry

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=5635
Printed Date: 26 September 2024 at 1:53pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Saving dock state of CXTPCommandBars to registry
Posted By: Sergio
Subject: Saving dock state of CXTPCommandBars to registry
Date Posted: 29 November 2006 at 8:27am
Hello,
 
Upon your previous help (about saving the docking panes layout to the registry), we tried to do the same using the CXTPCommandBars.
 
Here is our code :
 
BOOL CMainFrame::LoadOrSaveCommandBarsLayout(BOOL bLoad, CXTPCommandBars* pCommandBars, CString sLayoutName)
{
     if (pCommandBars)
     {
          ASSERT(!sLayoutName.IsEmpty());
 
          HKEY hKey = GetRegistryLayoutKey();
          ASSERT(hKey);
          if (hKey)
          {
               XTP_COMMANDBARS_PROPEXCHANGE_PARAM stParams;
               ::memset(&stParams, 0, sizeof(stParams));
               stParams.bSerializeControls = FALSE;
               stParams.bSaveOnlyCustomized = FALSE;
               stParams.bLoadSilent = FALSE;
               stParams.bSaveOriginalControls = FALSE;
               stParams.bSerializeImages = FALSE;
               stParams.bSerializeOptions = FALSE;
               stParams.bSerializeLayout = TRUE;
               stParams.bSerializeDesignerControls = FALSE;
               stParams.bSerializeActions = FALSE;
               stParams.pCommandBars = pCommandBars;
 
               CXTPPropExchangeRegistry px(bLoad, hKey, sLayoutName);
               pCommandBars->DoPropExchange(&px, &stParams);
               RegCloseKey(hKey);
 
               return TRUE;
          }
     }
 
     return FALSE;
}
The "hkey" is valid. But nothing is saved in the registry.
 
One more time, we hope that you will help us !
Regards,
 


-------------
Sergio



Replies:
Posted By: Oleg
Date Posted: 30 November 2006 at 1:48am
Hi,
 
Actually code looks good. Try to debug into DoPropExchange and check if
"if (pParam->bSerializeLayout)" block was exectuted.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Sergio
Date Posted: 01 December 2006 at 9:07am

Hi,

Ok, here are the results :

-------------------------------------


This method is executed :
void CXTPCommandBars::DoPropExchange(CXTPPropExchange* pPX, XTP_COMMANDBARS_PROPEXCHANGE_PARAM* pParam)

 

This bloc is executed :
if (pParam->bSerializeLayout)
{
     GetDockState(state);
     CXTPPropExchangeSection secLayout(pPX->GetSection(_T("Layout")));
     state.DoPropExchange(&secLayout);
     SerializeDockBarsState(&secLayout);
}

Contents infos :
state.m_arrBarInfo.m_nSize = 0

 

This bloc is executed :
void CXTPCommandBars::GetDockState(CXTPDockState& state)

Contents infos :

GetCount() = 3
pInfo... = valid pointers and valid toolbars pointers

 

This bloc is executed :
void CXTPDockState::DoPropExchange(CXTPPropExchange* pPX)

Contents infos :
pPX->IsStoring() = TRUE
nCount = 3
for(...) :
   strSection = "BarInfo0"

 

This bloc is executed :
void CXTPToolBar::CToolBarInfo::DoPropExchange(CXTPPropExchange* pPX, CXTPDockState* pDockState)

Contents infos :
pDockState = valid
PX_ ... all valid
(pDockState->GetVersion() > _XTP_SCHEMA_87) = TRUE
PX_Bool(pPX, _T("DialogBar"), m_bDialogBar, FALSE); : *** m_bDialogBar = FALSE for the 3 cases of previous for(...) ***

 


This bloc is executed :
void CXTPCommandBars::SerializeDockBarsState(CXTPPropExchange* pPX)

Contents infos :
for(...) :
   pDock = valid
   strSection = "DockBar0"
   pPX->IsStoring() = TRUE
      nSize = 5
          pDock->m_arrBars[0] = NULL for all cases
          dwID = 0
      end of 2nd for(...)
      nCount = 5

      for(...) :
          strDockBarSection = "Id0" and pBar = NULL for the first
                              "Id1"            CXTPMenuBar for the 2nd
                              "..."            NULL for the 3rd
                                               CXTPToolBar for the 4th
                                               NULL for the 5th

 

...

-------------------------------------

Does it helps ?



-------------
Sergio


Posted By: Oleg
Date Posted: 01 December 2006 at 9:22am
Hello,
 
Again seems right.
so problem can be only in registry settings. May be hKey you get only "readonly"/may be sLayoutName contains symbols that can't be used as registry key ("\"."/". etc)
 
try again step into one of PX_,,,, and to CXTPPropExchangeRegistry::ExchangeProp and check what result of RegSetValueEx was.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Sergio
Date Posted: 01 December 2006 at 11:54am

Hi,

We set :
 
::RegCreateKeyEx(HKEY_CURRENT_USER, sKeyName, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKeyLayout, NULL);
 
sLayoutName = "AppMainFrame"
 
In the registry we now see :
Layout
   DockBars
      DockBar0
      DockBar1
      DockBar2
      DockBar3
   DockState
 
Each key is empty, there is just a "(default)   REG_SZ    (value not set)" per key.
 
Monday, we will step into your second answer.
 


-------------
Sergio


Posted By: Sergio
Date Posted: 04 December 2006 at 3:51am

Hi,

I stepped into the first PX_DWord(&secDockState, _T("Version"), m_dwVersion, 0).

 

This portion of code :

   void CXTPDockState::DoPropExchange(CXTPPropExchange* pPX)
   {
      CXTPPropExchangeSection secDockState(pPX->GetSection(_T("DockState")));
      // read/write version info
      if (pPX->IsStoring())
      {
         PX_DWord(&secDockState, _T("Version"), m_dwVersion, 0); ==========> Then stepped into this method :

 

   BOOL CXTPPropExchangeRegistry::ExchangeProp(LPCTSTR pszPropName, VARTYPE vtProp,
      void* pvProp, const void* pvDefault /*= NULL*/)
   {
      ...
      m_bUseDefaultOnSave = 1
      ...

         case VT_BOOL:
         {
            DWORD dwValue = 0;
            CopyPropValue(vtProp, &dwValue, pvProp);
            lResult=0 = RegSetValueEx(m_hSectionKey=0xa64, pszPropName="Version", NULL, REG_DWORD, (LPBYTE)&dwValue=18, sizeof(DWORD));
         }
         break;

 

Perhaps the m_hSectionKey doesn't point to the correct registry key ?


-------------
Sergio


Posted By: Sergio
Date Posted: 04 December 2006 at 3:57am
There isn't any "ScreenSize" in the registry.

-------------
Sergio


Posted By: Sergio
Date Posted: 04 December 2006 at 11:31am
( "ScreenSize" is easier to find than "Version" in the registry. )

-------------
Sergio


Posted By: Oleg
Date Posted: 04 December 2006 at 1:08pm
Hi,
 
Sergio, try to find some minutes to modify our sample and try reproduce the problem with same code. If sample will fail also, attach changed code here and we will quickly find reason.
 
It is impossible  to say why without ability to debug/check what you do in code.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Sergio
Date Posted: 08 December 2006 at 8:02am
Hi Oleg,
 
Could you please give me the name of the sample to modify ?
 
Thanks,


-------------
Sergio


Posted By: Oleg
Date Posted: 08 December 2006 at 10:31am
Hi,
Any from CommandBars folder. Just try to reroduce same problem. or can create new using Appwizard....


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS



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