home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / labs / c06 / lab05 / baseline / finddiff.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.7 KB  |  119 lines

  1. // FindDiff.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "diff.h"
  6. #include "FindDiff.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CFindDifferenceDialog dialog
  16.  
  17.  
  18. CFindDifferenceDialog::CFindDifferenceDialog(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CFindDifferenceDialog::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CFindDifferenceDialog)
  22.         // NOTE: the ClassWizard will add member initialization here
  23.     //}}AFX_DATA_INIT
  24.  
  25.     m_bTerminating = FALSE;
  26.     m_bFindNext = FALSE;
  27. }
  28.  
  29.  
  30. void CFindDifferenceDialog::DoDataExchange(CDataExchange* pDX)
  31. {
  32.     CDialog::DoDataExchange(pDX);
  33.     //{{AFX_DATA_MAP(CFindDifferenceDialog)
  34.         // NOTE: the ClassWizard will add DDX and DDV calls here
  35.     //}}AFX_DATA_MAP
  36. }
  37.  
  38.  
  39. BEGIN_MESSAGE_MAP(CFindDifferenceDialog, CDialog)
  40.     //{{AFX_MSG_MAP(CFindDifferenceDialog)
  41.     ON_BN_CLICKED(IDOK, OnFindNext)
  42.     //}}AFX_MSG_MAP
  43. END_MESSAGE_MAP()
  44.  
  45.  
  46. BOOL CFindDifferenceDialog::IsTerminating() const
  47. {
  48.     return m_bTerminating;
  49. }
  50.  
  51. BOOL CFindDifferenceDialog::SearchDown() const       
  52. {
  53.     return(IsDlgButtonChecked(IDC_RADIO_DOWN));
  54. }
  55.  
  56. BOOL CFindDifferenceDialog::FindDifference() const   
  57. {
  58.     return(IsDlgButtonChecked(IDC_RADIO_NEXTDIFF));
  59. }
  60.  
  61. BOOL CFindDifferenceDialog::FindNext() const
  62. {
  63.     return m_bFindNext;
  64. }
  65.  
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68. // CFindDifferenceDialog message handlers
  69.  
  70. void CFindDifferenceDialog::OnFindNext() 
  71. {
  72.     m_bFindNext = TRUE;
  73.     GetParent()->SendMessage(
  74.         ::RegisterWindowMessage(FINDDIFF_MSGSTRING), 
  75.         0, (LPARAM)this);
  76.     m_bFindNext = FALSE;
  77. }
  78.  
  79. BOOL CFindDifferenceDialog::OnInitDialog() 
  80. {
  81.     CDialog::OnInitDialog();
  82.     
  83.     //    Our initialization
  84.     CheckDlgButton(IDC_RADIO_NEXTDIFF, TRUE);
  85.     CheckDlgButton(IDC_RADIO_DOWN, TRUE);
  86.     
  87.     return TRUE;  // return TRUE unless you set the focus to a control
  88.                   // EXCEPTION: OCX Property Pages should return FALSE
  89. }
  90.  
  91. BOOL CFindDifferenceDialog::Create() 
  92. {
  93.     //    m_lpszTemplateName and m_pParent are set
  94.     //    up by CDialog during construction
  95.     return CDialog::Create (m_lpszTemplateName, m_pParentWnd);
  96. }
  97.  
  98.  
  99.  
  100. void CFindDifferenceDialog::OnCancel() 
  101. {
  102.     DestroyWindow();
  103. }
  104.  
  105. void CFindDifferenceDialog::PostNcDestroy() 
  106. {
  107.     //    Make sure our owner knows we are about
  108.     //    to delete ourself. Directly access
  109.     //    m_pParentWnd because a call to GetParent()
  110.     //    ASSERTS that m_hWnd is still a window which
  111.     //    is no longer true
  112.     m_bTerminating = TRUE;
  113.     m_pParentWnd->SendMessage(
  114.         ::RegisterWindowMessage(FINDDIFF_MSGSTRING), 
  115.         0, (LPARAM)this);
  116.  
  117.     delete this;
  118. }
  119.