Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
3.1 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. FndRcDlg.cpp
  7. Replication Node Property page
  8. FILE HISTORY:
  9. 2/15/98 RamC Added Cancel button to the Find dialog
  10. */
  11. #include "stdafx.h"
  12. #include "winssnap.h"
  13. #include "FndRcdlg.h"
  14. #ifdef _DEBUG
  15. #define new DEBUG_NEW
  16. #undef THIS_FILE
  17. static char THIS_FILE[] = __FILE__;
  18. #endif
  19. #include "actreg.h"
  20. /////////////////////////////////////////////////////////////////////////////
  21. // CFindRecord property page
  22. //IMPLEMENT_DYNCREATE(CFindRecord, CBaseDialog)
  23. CFindRecord::CFindRecord(CActiveRegistrationsHandler *pActreg, CWnd* pParent) :CBaseDialog(CFindRecord::IDD, pParent)
  24. {
  25. //{{AFX_DATA_INIT(CFindRecord)
  26. m_strFindName = _T("");
  27. m_fMixedCase = FALSE;
  28. //}}AFX_DATA_INIT
  29. m_pActreg = pActreg;
  30. }
  31. CFindRecord::~CFindRecord()
  32. {
  33. }
  34. void CFindRecord::DoDataExchange(CDataExchange* pDX)
  35. {
  36. CBaseDialog::DoDataExchange(pDX);
  37. //{{AFX_DATA_MAP(CFindRecord)
  38. DDX_Control(pDX, IDOK, m_buttonOK);
  39. DDX_Control(pDX, IDCANCEL, m_buttonCancel);
  40. DDX_Control(pDX, IDC_COMBO_NAME, m_comboLokkForName);
  41. DDX_CBString(pDX, IDC_COMBO_NAME, m_strFindName);
  42. DDX_Check(pDX, IDC_CHECK_MIXED_CASE, m_fMixedCase);
  43. //}}AFX_DATA_MAP
  44. }
  45. BEGIN_MESSAGE_MAP(CFindRecord, CBaseDialog)
  46. //{{AFX_MSG_MAP(CFindRecord)
  47. ON_CBN_EDITCHANGE(IDC_COMBO_NAME, OnEditchangeComboName)
  48. ON_CBN_SELENDOK(IDC_COMBO_NAME, OnSelendokComboName)
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CFindRecord message handlers
  53. BOOL
  54. CFindRecord::OnInitDialog()
  55. {
  56. CBaseDialog::OnInitDialog();
  57. // disable the findnow button
  58. m_buttonOK.EnableWindow(FALSE);
  59. // fill the combobox from the array in the actreg handler
  60. int nCount = (int)m_pActreg->m_strFindNamesArray.GetSize();
  61. for(int i = 0; i < nCount; i++)
  62. {
  63. m_comboLokkForName.AddString(m_pActreg->m_strFindNamesArray[i]);
  64. }
  65. return TRUE;
  66. }
  67. void
  68. CFindRecord::OnOK()
  69. {
  70. UpdateData();
  71. m_strFindName.TrimLeft();
  72. m_strFindName.TrimRight();
  73. // add the string to the cache in the act reg node
  74. if(!IsDuplicate(m_strFindName))
  75. m_pActreg->m_strFindNamesArray.Add(m_strFindName);
  76. if (!m_fMixedCase)
  77. m_strFindName.MakeUpper();
  78. m_pActreg->m_strFindName = m_strFindName;
  79. CBaseDialog::OnOK();
  80. }
  81. void
  82. CFindRecord::OnCancel()
  83. {
  84. CBaseDialog::OnCancel();
  85. }
  86. BOOL
  87. CFindRecord::IsDuplicate(const CString & strName)
  88. {
  89. int nCount = (int)m_pActreg->m_strFindNamesArray.GetSize();
  90. for(int i = 0; i < nCount; i++)
  91. {
  92. // if found
  93. if(m_pActreg->m_strFindNamesArray[i].Compare(m_strFindName) == 0)
  94. {
  95. return TRUE;
  96. }
  97. }
  98. return FALSE;
  99. }
  100. void CFindRecord::OnEditchangeComboName()
  101. {
  102. UpdateData();
  103. EnableButtons(m_strFindName.IsEmpty() ? FALSE : TRUE);
  104. }
  105. void CFindRecord::OnSelendokComboName()
  106. {
  107. EnableButtons(TRUE);
  108. }
  109. void CFindRecord::EnableButtons(BOOL bEnable)
  110. {
  111. m_buttonOK.EnableWindow(bEnable);
  112. }