user3161924
user3161924

Reputation: 2317

MFC Saving Custom Header Column Widths

So I'm just learning MFC to see if I want to start using it over normal Win32 programming. I have a SDI MFC application setup. I have a view with members that create a CTreeCtrl and CHeaderCtrl. I have a CDwordArray setup as m_ColWidths that is currently in my View class, but using MFC, should this be in the document class instead since I'll want to save and restore it to keep the users widths when program exits? I guess even though it's only part of the view it's still data and use GetDocument() to reference them?

TIA!!

Upvotes: 0

Views: 140

Answers (1)

IInspectable
IInspectable

Reputation: 51506

Application state should not be stored in the document. The purpose of the CDocument(-derived) class is:

A document represents the unit of data that the user typically opens with the File Open command and saves with the File Save command.

CDocument supports standard operations such as creating a document, loading it, and saving it. The framework manipulates documents using the interface defined by CDocument.

The designated entity to store application state (e.g. size and visibility of UI elements) is the CWinAppEx(-derived) implementation:

CWinAppEx handles the application state, saves the state to the registry, loads the state from the registry, [...].

Upvotes: 1

Related Questions