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.

110 lines
2.7 KiB

  1. // wclsedit.cpp : registered WNDCLASS Edit control example
  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. #include "stdafx.h"
  13. #include "ctrltest.h"
  14. #include "paredit.h"
  15. /////////////////////////////////////////////////////////////////////////////
  16. // Dialog class
  17. class CWclsEditDlg : public CDialog
  18. {
  19. public:
  20. //{{AFX_DATA(CWclsEditDlg)
  21. enum { IDD = IDD_WNDCLASS_EDIT };
  22. //}}AFX_DATA
  23. CWclsEditDlg()
  24. : CDialog(CWclsEditDlg::IDD)
  25. { }
  26. // access to controls is through inline helpers
  27. CEdit& Edit1()
  28. { return *(CEdit*)GetDlgItem(IDC_EDIT1); }
  29. CEdit& Edit2()
  30. { return *(CEdit*)GetDlgItem(IDC_EDIT2); }
  31. CEdit& Edit3()
  32. { return *(CEdit*)GetDlgItem(IDC_EDIT3); }
  33. CEdit& Edit4()
  34. { return *(CEdit*)GetDlgItem(IDC_EDIT4); }
  35. BOOL OnInitDialog();
  36. //{{AFX_MSG(CWclsEditDlg)
  37. virtual void OnOK();
  38. afx_msg void OnIllegalChar();
  39. //}}AFX_MSG
  40. DECLARE_MESSAGE_MAP();
  41. };
  42. BOOL CWclsEditDlg::OnInitDialog()
  43. {
  44. // nothing special to do
  45. return TRUE;
  46. }
  47. void CWclsEditDlg::OnOK()
  48. {
  49. #ifdef _DEBUG
  50. // dump results, normally you would do something with these
  51. CString s;
  52. Edit1().GetWindowText(s);
  53. TRACE1("edit1 = '%s'\n", s);
  54. Edit2().GetWindowText(s);
  55. TRACE1("edit2 = '%s'\n", s);
  56. Edit3().GetWindowText(s);
  57. TRACE1("edit3 = '%s'\n", s);
  58. Edit4().GetWindowText(s);
  59. TRACE1("edit4 = '%s'\n", s);
  60. #endif
  61. EndDialog(IDOK);
  62. }
  63. /////////////////////////////////////////////////////////////////////////////
  64. // Handle custom control notification here
  65. BEGIN_MESSAGE_MAP(CWclsEditDlg, CDialog)
  66. //{{AFX_MSG_MAP(CWclsEditDlg)
  67. ON_CONTROL(PEN_ILLEGALCHAR, IDC_EDIT1, OnIllegalChar)
  68. ON_CONTROL(PEN_ILLEGALCHAR, IDC_EDIT2, OnIllegalChar)
  69. ON_CONTROL(PEN_ILLEGALCHAR, IDC_EDIT3, OnIllegalChar)
  70. ON_CONTROL(PEN_ILLEGALCHAR, IDC_EDIT4, OnIllegalChar)
  71. //}}AFX_MSG_MAP
  72. END_MESSAGE_MAP()
  73. void CWclsEditDlg::OnIllegalChar()
  74. {
  75. TRACE0("Don't do that!\n");
  76. // add extra reporting here...
  77. }
  78. /////////////////////////////////////////////////////////////////////////////
  79. // Run the test
  80. void CTestWindow::OnTestWndClassEdit()
  81. {
  82. TRACE0("running dialog containing WNDCLASS special edit items\n");
  83. if (!CParsedEdit::RegisterControlClass())
  84. {
  85. CString strMsg;
  86. strMsg.LoadString(IDS_WNDCLASS_NOT_REGISTERED);
  87. MessageBox(strMsg);
  88. return;
  89. }
  90. CWclsEditDlg dlg;
  91. dlg.DoModal();
  92. }
  93. /////////////////////////////////////////////////////////////////////////////