home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / mfc / general / npp / finddlg.cpp < prev    next >
C/C++ Source or Header  |  1998-03-26  |  2KB  |  92 lines

  1. // finddlg.cpp : implementation file
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12. //
  13.  
  14. #include "stdafx.h"
  15. #include <stddef.h>
  16. #include "np.h"
  17. #include "combobar.h"
  18. #include "mainfrm.h"
  19. #include "npdoc.h"
  20. #include "npview.h"
  21. #include "finddlg.h"
  22.  
  23. #ifdef _DEBUG
  24. #undef THIS_FILE
  25. static char BASED_CODE THIS_FILE[] = __FILE__;
  26. #endif
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CFindDlg dialog
  30.  
  31.  
  32. CFindDlg::CFindDlg(CWnd* pParent /*=NULL*/)
  33.     : CDialog(CFindDlg::IDD, pParent)
  34. {
  35.     //{{AFX_DATA_INIT(CFindDlg)
  36.     m_bMatchCase = FALSE;
  37.     m_szText = _T("");
  38.     m_nDirection = 1; // down by default
  39.     //}}AFX_DATA_INIT
  40. }
  41.  
  42.  
  43. void CFindDlg::DoDataExchange(CDataExchange* pDX)
  44. {
  45.     CDialog::DoDataExchange(pDX);
  46.     //{{AFX_DATA_MAP(CFindDlg)
  47.     DDX_Check(pDX, IDC_CHECK1, m_bMatchCase);
  48.     DDX_CBString(pDX, IDC_COMBO1, m_szText);
  49.     DDX_Radio(pDX, IDC_RADIO1, m_nDirection);
  50.     //}}AFX_DATA_MAP
  51. }
  52.  
  53.  
  54. BEGIN_MESSAGE_MAP(CFindDlg, CDialog)
  55.     //{{AFX_MSG_MAP(CFindDlg)
  56.     ON_BN_CLICKED(ID_EDIT_FIND_NEXT, OnEditFindNext)
  57.     //}}AFX_MSG_MAP
  58. END_MESSAGE_MAP()
  59.  
  60.  
  61. /////////////////////////////////////////////////////////////////////////////
  62. // CFindDlg message handlers
  63.  
  64. void CFindDlg::OnEditFindNext()
  65. {
  66.     // the user selected to search. see if there is a search pattern in the edit control
  67.     // using the default data exchange.
  68.     // if no search string is present, keep the dialog box up.
  69.     UpdateData(TRUE);
  70.  
  71.     if (!m_szText.GetLength())
  72.     {
  73.         MessageBeep(MB_ICONEXCLAMATION);
  74.         GotoDlgCtrl(GetDlgItem(IDC_COMBO1));
  75.         return ;
  76.     }
  77.  
  78.     EndDialog(TRUE);
  79.     GetApplicationView()->m_searchHistory.AddString(m_szText);
  80. }
  81.  
  82. BOOL CFindDlg::OnInitDialog()
  83. {
  84.     CDialog::OnInitDialog();
  85.  
  86.     CWnd* pWnd = GetDlgItem(IDC_COMBO1);
  87.     GetApplicationView()->m_searchHistory.FillCombobox();
  88.  
  89.     return TRUE;  // return TRUE unless you set the focus to a control
  90.                   // EXCEPTION: OCX Property Pages should return FALSE
  91. }
  92.