home *** CD-ROM | disk | FTP | other *** search
/ Master Visual C++ 1.5 / MASTERVC15.ISO / vcprog / original / ch16 / fileit / mydlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-23  |  1.6 KB  |  74 lines

  1. // mydlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "fileit.h"
  6. #include "mydlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #undef THIS_FILE
  10. static char BASED_CODE THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. /////////////////////////////////////////////////////////////////////////////
  14. // CMyDlg dialog
  15.  
  16.  
  17. CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CMyDlg::IDD, pParent)
  19. {
  20.     //{{AFX_DATA_INIT(CMyDlg)
  21.     m_EditBoxContents = "";
  22.     //}}AFX_DATA_INIT
  23. }
  24.  
  25. void CMyDlg::DoDataExchange(CDataExchange* pDX)
  26. {
  27.     CDialog::DoDataExchange(pDX);
  28.     //{{AFX_DATA_MAP(CMyDlg)
  29.     DDX_Text(pDX, IDC_EDIT1, m_EditBoxContents);
  30.     //}}AFX_DATA_MAP
  31. }
  32.  
  33. BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
  34.     //{{AFX_MSG_MAP(CMyDlg)
  35.     ON_BN_CLICKED(IDC_SAVE_IT, OnSaveIt)
  36.     //}}AFX_MSG_MAP
  37. END_MESSAGE_MAP()
  38.  
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CMyDlg message handlers
  42.  
  43. void CMyDlg::OnSaveIt()
  44. {
  45.     // TODO: Add your control notification handler code here
  46.  
  47.      //////////////////////
  48.      // MY CODE STARTS HERE
  49.      //////////////////////
  50.  
  51.     // Create an object TheFile of class CFile
  52.     CFile TheFile;
  53.  
  54.     // Prepare the file for creation OR writing
  55.     TheFile.Open ( "MyFile.TXT",
  56.                   CFile::modeCreate|CFile::modeWrite );
  57.  
  58.  
  59.     // Update the value of m_EditBoxContents
  60.     UpdateData (TRUE);
  61.  
  62.      // Write into the TheFile
  63.      TheFile.Write ( m_EditBoxContents,
  64.                          m_EditBoxContents.GetLength() );
  65.  
  66.      // Close the file
  67.      TheFile.Close();
  68.  
  69.      ////////////////////
  70.      // MY CODE ENDS HERE
  71.      ////////////////////
  72.     
  73. }
  74.