InputMemberno2.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // InputMemberno2.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "InputMemberno2.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // InputMemberno2 dialog
  13. InputMemberno2::InputMemberno2(CWnd* pParent /*=NULL*/)
  14. : CDialog(InputMemberno2::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(InputMemberno2)
  17. m_memberno = _T("");
  18. m_point = _T("");
  19. //}}AFX_DATA_INIT
  20. }
  21. void InputMemberno2::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(InputMemberno2)
  25. DDX_Control(pDX, IDC_EDIT2, m_editnum);
  26. DDX_Text(pDX, IDC_EDIT1, m_memberno);
  27. DDX_Text(pDX, IDC_EDIT2, m_point);
  28. //}}AFX_DATA_MAP
  29. }
  30. BEGIN_MESSAGE_MAP(InputMemberno2, CDialog)
  31. //{{AFX_MSG_MAP(InputMemberno2)
  32. ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1)
  33. //}}AFX_MSG_MAP
  34. END_MESSAGE_MAP()
  35. /////////////////////////////////////////////////////////////////////////////
  36. // InputMemberno2 message handlers
  37. void InputMemberno2::OnOK()
  38. {
  39. // TODO: Add extra validation here
  40. UpdateData();
  41. m_point.TrimLeft ();
  42. m_point.TrimRight ();
  43. if( atoi(m_point)==0)
  44. return;
  45. CDialog::OnOK ();
  46. }
  47. BOOL InputMemberno2::OnInitDialog()
  48. {
  49. CDialog::OnInitDialog();
  50. // TODO: Add extra initialization here
  51. return TRUE; // return TRUE unless you set the focus to a control
  52. // EXCEPTION: OCX Property Pages should return FALSE
  53. }
  54. BOOL InputMemberno2::PreTranslateMessage(MSG* pMsg)
  55. {
  56. // TODO: Add your specialized code here and/or call the base class
  57. return CDialog::PreTranslateMessage(pMsg);
  58. if(pMsg->message==WM_KEYDOWN)
  59. {
  60. switch (pMsg->wParam)
  61. {
  62. if(GetFocus()!=GetDlgItem(IDC_EDIT1))return CDialog::PreTranslateMessage(pMsg);
  63. case '0':
  64. case VK_NUMPAD0:
  65. m_input+="0";
  66. CheckInput();
  67. break;
  68. case '1':
  69. case VK_NUMPAD1:
  70. m_input+="1";
  71. CheckInput();
  72. break;
  73. case '2':
  74. case VK_NUMPAD2:
  75. m_input+="2";
  76. CheckInput();
  77. break;
  78. case '3':
  79. case VK_NUMPAD3:
  80. m_input+="3";
  81. CheckInput();
  82. break;
  83. case '4':
  84. case VK_NUMPAD4:
  85. m_input+="4";
  86. CheckInput();
  87. break;
  88. case '5':
  89. case VK_NUMPAD5:
  90. m_input+="5";
  91. CheckInput();
  92. break;
  93. case '6':
  94. case VK_NUMPAD6:
  95. m_input+="6";
  96. CheckInput();
  97. break;
  98. case '7':
  99. case VK_NUMPAD7:
  100. m_input+="7";
  101. CheckInput();
  102. break;
  103. case '8':
  104. case VK_NUMPAD8:
  105. m_input+="8";
  106. CheckInput();
  107. break;
  108. case '9':
  109. case VK_NUMPAD9:
  110. m_input+="9";
  111. CheckInput();
  112. break;
  113. }
  114. }
  115. return CDialog::PreTranslateMessage(pMsg);
  116. }
  117. void InputMemberno2::CheckInput()
  118. {
  119. if(m_input.GetLength ()>=6)
  120. {
  121. m_input=m_input.Right (6);
  122. m_memberno=m_input.Left (5);
  123. UpdateData(false);
  124. }
  125. }
  126. void InputMemberno2::OnChangeEdit1()
  127. {
  128. // TODO: If this is a RICHEDIT control, the control will not
  129. // send this notification unless you override the CDialog::OnInitDialog()
  130. // function and call CRichEditCtrl().SetEventMask()
  131. // with the ENM_CHANGE flag ORed into the mask.
  132. UpdateData();
  133. m_input=m_memberno;
  134. // TODO: Add your control notification handler code here
  135. }