[MFC] Cum salvez starea barelor de control?

Despre MFC, ATL si alte biblioteci C++ de la Microsoft (forum moderat)
Post Reply
User avatar
Ovidiu Cucu
Fondator
Fondator
Posts: 3776
Joined: 11 Jul 2007, 16:10
Judet: Iaşi
Location: Iasi
Contact:

[MFC] Cum salvez starea barelor de control?

Post by Ovidiu Cucu » 04 Aug 2011, 12:46

Intrebare
Cum salvez starea barelor de control (toolbar, statusbar, dialogbar, etc) intr-o aplicatie SDI/MDI, in asa fel incat sa o pot reface la repornire.

Raspuns
Functia CFrameWnd::SaveBarState salveaza urmatoarele informatii despre control bars:
  • vizibilitate;
  • docking state (docata in frame sau flotanta);
  • orientare si pozitie.

Pentru a reface starea salvata, se apeleaza CFrameWnd::LoadBarState

Exemplu

Code: Select all

BOOL CMyApplication::InitInstance()
{
   // Change the registry key under which our settings are stored.
   SetRegistryKey(_T("Codexpert.ro"));
   // ...
}

Code: Select all

// MainFrm.h

class CMainFrame : public CMDIFrameWnd
{
   static LPCTSTR const m_pszRegBarState;
// ...
};

Code: Select all

// MainFrm.cpp
// ...
LPCTSTR const CMainFrame::m_pszRegBarState = _T("mainframe_bar_state");

Code: Select all

// WM_CLOSE message handler
void CMainFrame::OnClose() 
{
   SaveBarState(m_pszRegBarState);
   // ...
   CMDIFrameWnd::OnClose();
}

Code: Select all

// WM_CREATE message handler
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   // ...
   LoadBarState(m_pszRegBarState);
   return 0;
}
Vezi si << Back to MFC index



Post Reply