|
|
|
|
Forum
Please
Log In
to post a new message or reply to an existing one. If you are not registered, please
register.
NOTE: Some forums may be read-only if you are not currently subscribed to
our technical support services.
Subject |
Author |
Date |
|
Darren Oliver
|
Sep 29, 2005 - 4:18 PM
|
All the sample code always saves the windows layout to the registry on exit - I would like to do it on command (e.g. button press). I know that the call to ProfileBarStateSave() does the save, but I cannot take it out of DestroyWindow() and put it in say - "OnSaveLayout()", which gets called from a button press. Specifically, the code snippet:
CWinApp * pApp = ::AfxGetApp();
ASSERT( pApp != NULL );
ASSERT( pApp->m_pszRegistryKey != NULL );
ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) );
ASSERT( pApp->m_pszProfileName != NULL );
ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );
VERIFY(
CExtControlBar::ProfileBarStateSave(
this,
pApp->m_pszRegistryKey,
pApp->m_pszProfileName,
pApp->m_pszProfileName,
&m_dataFrameWP
);
Thanks ahead of time.
|
|
Technical Support
|
Sep 30, 2005 - 6:14 AM
|
Your code snippet looks correct. It must save the bar state to the registry and can be used in your OnSaveLayout() method. Please clarify the following: "... but I cannot take it out of DestroyWindow() and put it ...". Please let us know what exactly you cannot do?
|
|
Darren Oliver
|
Sep 30, 2005 - 7:28 AM
|
I cannot move the CExtControlBar::ProfileBarStateSave() call out of DestroyWindow() and use it in the OnSaveLayout() method. I end up with an exception in ProfileBarStateSave() at line "ASSERT( ::IsWindow(hWnd) );".
-------------------code snippet ------------------
void CMainFrame::OnSaveLayout() { CWinApp * pApp = ::AfxGetApp(); ASSERT( pApp != NULL ); ASSERT( pApp->m_pszRegistryKey != NULL ); ASSERT( pApp->m_pszRegistryKey[0] != _T(’\0’) ); ASSERT( pApp->m_pszProfileName != NULL ); ASSERT( pApp->m_pszProfileName[0] != _T(’\0’) );
VERIFY( CExtControlBar::ProfileBarStateSave( this, pApp->m_pszRegistryKey, pApp->m_pszProfileName, pApp->m_pszProfileName, &m_dataFrameWP ) ); }
|
|
Technical Support
|
Sep 30, 2005 - 7:59 AM
|
Your code should try to save the state of resizable bars only when the main frame window and all its bars are valid, existing windows. This means CWnd::m_hWnd properties of main frame window and all the bar windows should specify valid window handles. You cannot invoke the OnSaveLayout() method from the CMainFrame::PostNcDestroy() method. You cannot invoke it when CMainFrame is already destroyed. Please check these issues.
|
|