EmployeeMsg.cpp 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // EmployeeMsg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ylgl.h"
  5. #include "EmployeeMsg.h"
  6. #include "MyMdi.H"
  7. #include "SendMsgDlg.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. /////////////////////////////////////////////////////////////////////////////
  14. // EmployeeMsg
  15. IMPLEMENT_DYNCREATE(EmployeeMsg, MyFormView)
  16. EmployeeMsg::EmployeeMsg()
  17. : MyFormView(EmployeeMsg::IDD)
  18. {
  19. //{{AFX_DATA_INIT(EmployeeMsg)
  20. //}}AFX_DATA_INIT
  21. }
  22. EmployeeMsg::~EmployeeMsg()
  23. {
  24. }
  25. void EmployeeMsg::DoDataExchange(CDataExchange* pDX)
  26. {
  27. MyFormView::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(EmployeeMsg)
  29. DDX_Control(pDX, IDC_LIST2, m_List1);
  30. DDX_Control(pDX, IDC_STATIC1, m_static1);
  31. //}}AFX_DATA_MAP
  32. }
  33. BEGIN_MESSAGE_MAP(EmployeeMsg, MyFormView)
  34. //{{AFX_MSG_MAP(EmployeeMsg)
  35. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  36. ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
  37. ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
  38. //}}AFX_MSG_MAP
  39. END_MESSAGE_MAP()
  40. /////////////////////////////////////////////////////////////////////////////
  41. // EmployeeMsg diagnostics
  42. #ifdef _DEBUG
  43. void EmployeeMsg::AssertValid() const
  44. {
  45. MyFormView::AssertValid();
  46. }
  47. void EmployeeMsg::Dump(CDumpContext& dc) const
  48. {
  49. MyFormView::Dump(dc);
  50. }
  51. #endif //_DEBUG
  52. /////////////////////////////////////////////////////////////////////////////
  53. // EmployeeMsg message handlers
  54. void EmployeeMsg::OnInitialUpdate()
  55. {
  56. MyFormView::OnInitialUpdate();
  57. // TODO: Add your specialized code here and/or call the base class
  58. CMyMdi Mdi;
  59. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  60. // Here we create the outbar control using the splitter as its parent
  61. // and setting its id to the first pane.
  62. CRect rc2;
  63. GetWindowRect(rc2);
  64. ::MoveWindow(m_hWnd, g_rc.left, g_rc.top, g_rc.Width(), g_rc.Height(), TRUE);
  65. EnumChildWindows(m_hWnd, (WNDENUMPROC)EnumChildProc, 0);
  66. m_static1.SetFont(&g_titlefont);
  67. m_List1.SetHeadings("编号, 100;姓名, 100;部门, 100;性别, 100;电话, 200;地址, 200");
  68. m_List1.LoadColumnInfo(137);
  69. g_sendhead.bsql = 0;
  70. g_sendhead.code[0] = 3;
  71. g_sendhead.tabcount = 1;
  72. g_pMainWnd->ProcessChatMessageRequest2(3); if (g_bSendOK == 0)return;
  73. DataToArray(&g_List1array);
  74. FillGrid();
  75. }
  76. void EmployeeMsg::FillGrid()
  77. {
  78. m_List1.DeleteAllItems2();
  79. int ii = 0;
  80. m_List1.m_arLabels.SetSize(g_userarray.GetSize(), 1);
  81. int count = 0;
  82. for (ii = 0; ii < m_List1.m_arLabels.GetSize(); ii++)
  83. {
  84. m_List1.m_arLabels.ElementAt(count++).Copy(g_userarray.ElementAt(ii));
  85. }
  86. m_List1.m_arLabels.SetSize(count, 1);
  87. ii = count;
  88. m_List1.m_LabelCount = ii;
  89. m_List1.SetItemCountEx(ii);
  90. }
  91. void EmployeeMsg::OnBUTclose()
  92. {
  93. // TODO: Add your control notification handler code here
  94. GetParent()->SendMessage(WM_CLOSE);
  95. }
  96. BOOL EmployeeMsg::PreTranslateMessage(MSG* pMsg)
  97. {
  98. // TODO: Add your specialized code here and/or call the base class
  99. try
  100. {
  101. if (pMsg->message == WM_KEYDOWN)
  102. {
  103. switch (pMsg->wParam)
  104. {
  105. case 0x43: // copy
  106. if ((GetKeyState(VK_CONTROL) & 0x80))
  107. {
  108. GetFocus()->SendMessage(WM_COPY);
  109. return TRUE;
  110. }
  111. break;
  112. case 0x56: //Ctrl + V:
  113. if ((GetKeyState(VK_CONTROL) & 0x80))
  114. {
  115. GetFocus()->SendMessage(WM_PASTE);
  116. return TRUE;
  117. }
  118. break;
  119. case 0x58: // cut
  120. if ((GetKeyState(VK_CONTROL) & 0x80))
  121. {
  122. GetFocus()->SendMessage(WM_CUT);
  123. return TRUE;
  124. }
  125. break;
  126. case 0x5A: //undo
  127. case 0x59: //redo
  128. if ((GetKeyState(VK_CONTROL) & 0x80))
  129. {
  130. GetFocus()->SendMessage(WM_UNDO);
  131. return TRUE;
  132. }
  133. break;
  134. }
  135. }
  136. return MyFormView::PreTranslateMessage(pMsg);
  137. }
  138. catch (...)
  139. {
  140. }
  141. return TRUE;
  142. }
  143. void EmployeeMsg::OnButton2() // 发送消息
  144. {
  145. // TODO: Add your control notification handler code here
  146. POSITION pos;
  147. pos = m_List1.GetFirstSelectedItemPosition();
  148. if (pos == NULL)
  149. {
  150. AfxMessageBox("请先选中您要发送短信的员工!", MB_ICONINFORMATION);
  151. return;
  152. }
  153. int iItem;
  154. CStringArray array;
  155. while (pos)
  156. {
  157. iItem = m_List1.GetNextSelectedItem(pos);
  158. if (!m_List1.GetItemText(iItem, 4).IsEmpty())
  159. array.Add(m_List1.GetItemText(iItem, 4));
  160. }
  161. SendMsgDlg dlg;
  162. dlg.m_mode = 1;
  163. dlg.m_pArray = &array;
  164. dlg.DoModal();
  165. }
  166. void EmployeeMsg::OnButton3()
  167. {
  168. // TODO: Add your control notification handler code here
  169. for (int i = 0; i < m_List1.GetItemCount(); i++)
  170. m_List1.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED);
  171. }