Click here to Skip to main content
15,920,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I created a serializable SDI application with Document/View support & I want to Open a certain file Silently (Without having to call the prompting CFileDialog Class) in just one click from the main menu & then do the rest of code in the virtual void Serialize(CArchive& ar); function. & of course clear the current document on closing it or on the next reopening.
I am wondering what sequence of code should I use to ensure this & what class of the (CWinApp, CDocument, CFrameWnd or the CView) classes should I implement that code.

Help me please to solve this issue. :sigh:
Posted
Updated 6-Dec-10 12:43pm
v2

I guess CWinApp::OpenDocumentFile should do the job
 
Share this answer
 
Comments
Mr. Tomay 7-Dec-10 18:39pm    
Where to implement this CWinApp::OpenDocumentFile ?
SoftwareDeveloperGoa 7-Dec-10 18:51pm    
Implemented by MFC, just use it
Here is a possible start :) :
class CYourDoc : public CDocument
{
  DECLARE_DYNCREATE(CYourDoc)

private:
  COLORREF m_clrBackColor; // some content :)

protected:
  CYourDoc();

public:
  virtual ~CYourDoc();
  
  virtual void Serialize(CArchive& ar);
};

IMPLEMENT_DYNCREATE(CYourDoc, CDocument)

void CYourDoc::Serialize(CArchive& ar)
{
  if (ar.IsStoring()) {
    ar << m_clrBackColor;
  } else {
    ar >> m_clrBackColor;
  } 
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900