home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / modeless / adderdlg.cpp next >
Encoding:
C/C++ Source or Header  |  1998-03-27  |  2.0 KB  |  90 lines

  1. // AdderDlg.cpp : implementation file
  2. //
  3.  
  4. // This is a part of the Microsoft Foundation Classes C++ library.
  5. // Copyright (C) 1992-1998 Microsoft Corporation
  6. // All rights reserved.
  7. //
  8. // This source code is only intended as a supplement to the
  9. // Microsoft Foundation Classes Reference and related
  10. // electronic documentation provided with the library.
  11. // See these sources for detailed information regarding the
  12. // Microsoft Foundation Classes product.
  13.  
  14. #include "stdafx.h"
  15. #include "modeless.h"
  16. #include "AdderDlg.h"
  17. #include "modeldlg.h"
  18.  
  19.  
  20. #ifdef _DEBUG
  21. #undef THIS_FILE
  22. static char BASED_CODE THIS_FILE[] = __FILE__;
  23. #endif
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CAdderDialog dialog
  27.  
  28.  
  29. CAdderDialog::CAdderDialog(CWnd* pParent)
  30.     : CDialog(CAdderDialog::IDD, pParent)
  31. {
  32.     //{{AFX_DATA_INIT(CAdderDialog)
  33.         // NOTE: the ClassWizard will add member initialization here
  34.     //}}AFX_DATA_INIT
  35.     ASSERT(pParent != NULL);
  36.  
  37.     m_pParent = pParent;
  38.     m_nID = CAdderDialog::IDD;
  39. }
  40.  
  41. void CAdderDialog::DoDataExchange(CDataExchange* pDX)
  42. {
  43.     CDialog::DoDataExchange(pDX);
  44.     //{{AFX_DATA_MAP(CAdderDialog)
  45.         // NOTE: the ClassWizard will add DDX and DDV calls here
  46.     //}}AFX_DATA_MAP
  47. }
  48.  
  49.  
  50. BEGIN_MESSAGE_MAP(CAdderDialog, CDialog)
  51.     //{{AFX_MSG_MAP(CAdderDialog)
  52.     //}}AFX_MSG_MAP
  53. END_MESSAGE_MAP()
  54.  
  55.  
  56. /////////////////////////////////////////////////////////////////////////////
  57. // CAdderDialog message handlers
  58.  
  59. void CAdderDialog::OnOK()
  60. {
  61.     CEdit* pEdit = (CEdit*) GetDlgItem(IDC_NEWTEXT);
  62.     CListBox* pList = (CListBox*) (m_pParent->GetDlgItem(IDC_LIST));
  63.  
  64.     ASSERT(pList != NULL);
  65.     ASSERT(pEdit != NULL);
  66.  
  67.     if (pList != NULL && pEdit != NULL)
  68.     {
  69.         CString str;
  70.         pEdit->GetWindowText(str);
  71.         pList->AddString(str);
  72.     }
  73. }
  74.  
  75. BOOL CAdderDialog::Create()
  76. {
  77.     return CDialog::Create(m_nID, m_pParent);
  78. }
  79.  
  80. void CAdderDialog::OnCancel()
  81. {
  82.     ((CMainDlg*)m_pParent)->BoxDone();
  83.     DestroyWindow();
  84. }
  85.  
  86. void CAdderDialog::PostNcDestroy()
  87. {
  88.     delete this;
  89. }
  90.