July 5th, 1999, 02:25 PM
Given VC++5.0, a document and a form view with several edit boxes (or other controls) on it. User fills in the form and press Save (or Save As…) to serialize data into a file. At the end of the day document gets serialized. The question is: when to move data from CFormView data members (or may be directly from Windows controls) into document? Save (and Save As…) command is mapped to OnFileSave (OnFileSaveAs) member of CDocument. It resolves into OnSaveDocument – the only documented (virtual) member function of CDocument in this regard. It looks to me that I cannot remap Save to a CView derivative. CView members are not able to call CDocument protected members (OnFileSave (OnFileSaveAs) is protected, not to mention is undocumented). And if I insist and map Save to CView::OnFileSave I think the command will be dispatched to CView and not routed to CDocument. On the other hand I think it is quite natural to save the data using the “Press Save” technique but I am not able to achieve this. Do I need to consider something different? Some logic based on Get, Lose, Kill Focus for example?