home *** CD-ROM | disk | FTP | other *** search
- // archview.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "arch.h"
- #include "archview.h"
-
- #ifdef _DEBUG
- #undef THIS_FILE
- static char BASED_CODE THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CArchView
-
- IMPLEMENT_DYNCREATE(CArchView, CFormView)
-
- CArchView::CArchView()
- : CFormView(CArchView::IDD)
- {
- //{{AFX_DATA_INIT(CArchView)
- m_Var1 = "";
- m_Var2 = "";
- //}}AFX_DATA_INIT
- }
-
- CArchView::~CArchView()
- {
- }
-
- void CArchView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CArchView)
- DDX_Text(pDX, IDC_VAR1, m_Var1);
- DDX_Text(pDX, IDC_VAR2, m_Var2);
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(CArchView, CFormView)
- //{{AFX_MSG_MAP(CArchView)
- ON_BN_CLICKED(IDC_SAVE_BUTTON, OnSaveButton)
- ON_BN_CLICKED(IDC_LOAD_BUTTON, OnLoadButton)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-
- /////////////////////////////////////////////////////////////////////////////
- // CArchView message handlers
-
-
- void CArchView::OnSaveButton()
- {
- // TODO: Add your control notification handler code here
-
- //////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Update m_Var1 and m_Var2 with the screen contents.
- UpdateData(TRUE);
-
- // Create the file TRY.TRY.
- CFile f;
- f.Open("TRY.TRY", CFile::modeCreate | CFile::modeWrite );
-
- // Create an archive object.
- CArchive ar( &f, CArchive::store );
-
- // Serialize m_Var1 and m_Var2 into the archive.
- ar << m_Var1 << m_Var2;
-
- // Close the archive
- ar.Close();
-
- // Close the file.
- f.Close();
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-
- void CArchView::OnLoadButton()
- {
- // TODO: Add your control notification handler code here
-
- ///////////////////////
- // MY CODE STARTS HERE
- //////////////////////
-
- // Open the file TRY.TRY.
- CFile f;
- if ( f.Open("TRY.TRY", CFile::modeRead)== FALSE )
- return;
-
- // Create an archive object.
- CArchive ar( &f, CArchive::load );
-
- // Serialize data from the archive into m_Var1 and m_Var2.
- ar >> m_Var1 >> m_Var2;
-
- // Close the archive
- ar.Close();
-
- // Close the file.
- f.Close();
-
- // Update screen with the new values of m_Var1 and m_Var2.
- UpdateData(FALSE);
-
- ////////////////////
- // MY CODE ENDS HERE
- ////////////////////
-
- }
-