home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / addins / booknote / dlgnote.cpp < prev    next >
C/C++ Source or Header  |  1998-04-02  |  2KB  |  97 lines

  1. // DlgNote.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "resource.h"
  6. #include "DlgNote.h"
  7. #include <afxdlgs.h>
  8. #include "booknote.h"
  9. #include "markit.h"
  10.  
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. /////////////////////////////////////////////////////////////////////////////
  18. // CDlgNote dialog
  19.  
  20.  
  21. CDlgNote::CDlgNote(CWnd* pParent /*=NULL*/)
  22.     : CDialog(CDlgNote::IDD, pParent)
  23. {
  24.     //{{AFX_DATA_INIT(CDlgNote)
  25.     m_strNote = _T("");
  26.     m_strLogFile = _T("");
  27.     m_fEcho = FALSE;
  28.     //}}AFX_DATA_INIT
  29.  
  30.     m_pMarkIt = NULL;
  31.  
  32. }
  33.  
  34.  
  35. void CDlgNote::DoDataExchange(CDataExchange* pDX)
  36. {
  37.     CDialog::DoDataExchange(pDX);
  38.     //{{AFX_DATA_MAP(CDlgNote)
  39.     DDX_Text(pDX, IDC_EDITNOTE, m_strNote);
  40.     DDV_MaxChars(pDX, m_strNote, 1024);
  41.     DDX_Text(pDX, IDC_EDITFILE, m_strLogFile);
  42.     DDX_Check(pDX, IDC_CHECKECHO, m_fEcho);
  43.     //}}AFX_DATA_MAP
  44. }
  45.  
  46.  
  47. BEGIN_MESSAGE_MAP(CDlgNote, CDialog)
  48.     //{{AFX_MSG_MAP(CDlgNote)
  49.     ON_BN_CLICKED(IDC_BUTTONBROWSE, OnButtonbrowse)
  50.     ON_BN_CLICKED(IDC_BUTTON_DUMP, OnButtonDump)
  51.     //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CDlgNote message handlers
  56.  
  57. BOOL CDlgNote::OnInitDialog() 
  58. {
  59.     CDialog::OnInitDialog();
  60.     
  61.     UpdateData(FALSE);
  62.     
  63.     return TRUE;  // return TRUE unless you set the focus to a control
  64.                   // EXCEPTION: OCX Property Pages should return FALSE
  65. }
  66.  
  67. void CDlgNote::OnButtonbrowse() 
  68. {
  69.     CFileDialog dlgGetFile(FALSE, NULL, NULL, OFN_EXPLORER,
  70.         _T("txt files(*.txt)|*.txt|All Files (*.*)|*.*||"),
  71.         this);
  72.     
  73.     if (dlgGetFile.DoModal() == IDOK)
  74.     {
  75.         UpdateData();
  76.         m_strLogFile = dlgGetFile.GetPathName();
  77.         UpdateData(FALSE);
  78.     }
  79. }
  80.  
  81. void CDlgNote::OnOK() 
  82. {
  83.     if (m_strLogFile.ReverseFind(_T('.')) < 0)
  84.     {
  85.         m_strLogFile += _T(".txt");
  86.     }
  87.     CDialog::OnOK();
  88. }
  89.  
  90. void CDlgNote::OnButtonDump() 
  91. {
  92.     if (m_pMarkIt)
  93.     {
  94.         m_pMarkIt->Dump(m_strLogFile);
  95.     }
  96. }
  97.