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

  1. // DlgBrkPnts.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "resource.h"
  6. #include "DlgBrkPnts.h"
  7. #include <afxdlgs.h>
  8. #include "dlgAdvanced.h"
  9. #include "brkpntmgr.h"
  10. #include "brkpnts.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CDlgBrkPnts dialog
  20.  
  21.  
  22. CDlgBrkPnts::CDlgBrkPnts(CWnd* pParent /*=NULL*/)
  23.     : CDialog(CDlgBrkPnts::IDD, pParent)
  24. {
  25.     //{{AFX_DATA_INIT(CDlgBrkPnts)
  26.     m_fSaveOnlyEnabled = FALSE;
  27.     m_strFile = _T("");
  28.     //}}AFX_DATA_INIT
  29.     m_pBrkPnts = NULL;
  30. }
  31.  
  32.  
  33. void CDlgBrkPnts::DoDataExchange(CDataExchange* pDX)
  34. {
  35.     CDialog::DoDataExchange(pDX);
  36.     //{{AFX_DATA_MAP(CDlgBrkPnts)
  37.     DDX_Control(pDX, IDC_EDITCOMMENTS, m_ctlEditComment);
  38.     DDX_Control(pDX, IDC_COUNT, m_ctlCount);
  39.     DDX_Check(pDX, IDC_CHECKSAVEONLYENABLED, m_fSaveOnlyEnabled);
  40.     DDX_Text(pDX, IDC_EDITFILE, m_strFile);
  41.     //}}AFX_DATA_MAP
  42. }
  43.  
  44.  
  45. BEGIN_MESSAGE_MAP(CDlgBrkPnts, CDialog)
  46.     //{{AFX_MSG_MAP(CDlgBrkPnts)
  47.     ON_BN_CLICKED(IDC_BUTTONBROWSE, OnButtonbrowse)
  48.     ON_BN_CLICKED(IDC_BUTTONLOAD, OnButtonload)
  49.     ON_BN_CLICKED(IDC_BUTTONCLEAR, OnButtonclear)
  50.     ON_BN_CLICKED(IDB_OUTPUT, OnOutput)
  51.     ON_BN_CLICKED(IDSAVE, OnSave)
  52.     //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54.  
  55. /////////////////////////////////////////////////////////////////////////////
  56. // CDlgBrkPnts message handlers
  57.  
  58. void CDlgBrkPnts::OnButtonbrowse() 
  59. {
  60.     CFileDialog dlgGetFile(FALSE, NULL, NULL, OFN_EXPLORER,
  61.         _T("brk files(*.brk)|*.brk|All Files (*.*)|*.*||"),
  62.         this);
  63.     
  64.     if (dlgGetFile.DoModal() == IDOK)
  65.     {
  66.         UpdateData();
  67.         m_strFile = dlgGetFile.GetPathName();
  68.         UpdateData(FALSE);
  69.     }
  70. }
  71.  
  72. void CDlgBrkPnts::OnButtonload() 
  73. {
  74.     CString strComment;
  75.  
  76.     if (m_pBrkPnts)
  77.     {
  78.         UpdateData();
  79.         m_pBrkPnts->Load(m_strFile, strComment);
  80.         m_ctlEditComment.SetWindowText(strComment);
  81.         UpdateInfo();
  82.     }
  83. }
  84.  
  85. BOOL CDlgBrkPnts::OnInitDialog() 
  86. {
  87.     AFX_MANAGE_STATE(AfxGetStaticModuleState());
  88.     CDialog::OnInitDialog();
  89.     
  90.     UpdateInfo();
  91.     
  92.     return TRUE;  // return TRUE unless you set the focus to a control
  93.                   // EXCEPTION: OCX Property Pages should return FALSE
  94. }
  95.  
  96. void CDlgBrkPnts::OnButtonclear() 
  97. {
  98.     if (m_pBrkPnts)
  99.     {
  100.         m_pBrkPnts->ClearAll();
  101.         UpdateInfo();
  102.     }
  103. }
  104.  
  105. void CDlgBrkPnts::OnOutput() 
  106. {
  107.     CString strComment;
  108.  
  109.     if (m_pBrkPnts)
  110.     {
  111.         UpdateData();
  112.         m_ctlEditComment.GetWindowText(strComment);
  113.         m_pBrkPnts->Save(TRUE, NULL, m_fSaveOnlyEnabled, strComment);
  114.     }
  115. }
  116.  
  117. void CDlgBrkPnts::UpdateInfo()
  118. {
  119.     CString strInfo;
  120.     long lEnabled, lTotal;
  121.  
  122.     if (m_pBrkPnts)
  123.     {
  124.         m_pBrkPnts->GetCounts(lTotal, lEnabled);
  125.         strInfo.Format(IDS_INFO, lEnabled, lTotal);
  126.         m_ctlCount.SetWindowText(strInfo);
  127.     }
  128. }
  129.  
  130. void CDlgBrkPnts::OnSave() 
  131. {
  132.     CString strComment;
  133.  
  134.     if (m_pBrkPnts)
  135.     {
  136.         UpdateData();
  137.         m_ctlEditComment.GetWindowText(strComment);
  138.         m_pBrkPnts->Save(FALSE, m_strFile, m_fSaveOnlyEnabled, strComment);
  139.     }
  140. }
  141.