SPForm.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. // SPForm.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "LYFZIPManage.h"
  5. #include "SPForm.h"
  6. #include "MyMdi.H"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // SPForm
  14. IMPLEMENT_DYNCREATE(SPForm, CFormView)
  15. SPForm::SPForm()
  16. : CFormView(SPForm::IDD)
  17. {
  18. //{{AFX_DATA_INIT(SPForm)
  19. m_filter = _T("");
  20. //}}AFX_DATA_INIT
  21. }
  22. SPForm::~SPForm()
  23. {
  24. }
  25. void SPForm::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CFormView::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(SPForm)
  29. DDX_Control(pDX, IDC_COMBO1, m_combo1);
  30. DDX_Control(pDX, IDC_LIST2, m_List1);
  31. DDX_Control(pDX, IDC_STATIC1, m_static1);
  32. DDX_CBString(pDX, IDC_COMBO1, m_filter);
  33. //}}AFX_DATA_MAP
  34. }
  35. BEGIN_MESSAGE_MAP(SPForm, CFormView)
  36. //{{AFX_MSG_MAP(SPForm)
  37. ON_BN_CLICKED(IDC_BUTclose, OnBUTclose)
  38. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  39. ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
  40. ON_WM_TIMER()
  41. //}}AFX_MSG_MAP
  42. END_MESSAGE_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. // SPForm diagnostics
  45. #ifdef _DEBUG
  46. void SPForm::AssertValid() const
  47. {
  48. CFormView::AssertValid();
  49. }
  50. void SPForm::Dump(CDumpContext& dc) const
  51. {
  52. CFormView::Dump(dc);
  53. }
  54. #endif //_DEBUG
  55. /////////////////////////////////////////////////////////////////////////////
  56. // SPForm message handlers
  57. void SPForm::OnInitialUpdate()
  58. {
  59. CFormView::OnInitialUpdate();
  60. // TODO: Add your specialized code here and/or call the base class
  61. CMyMdi Mdi;
  62. Mdi.SetSubView((CWnd*)GetParent(), (CWnd*)this);
  63. // Here we create the outbar control using the splitter as its parent
  64. // and setting its id to the first pane.
  65. CRect rc2;
  66. GetWindowRect(rc2);
  67. ::MoveWindow(m_hWnd,g_rc.left,g_rc.top,g_rc.Width(),g_rc.Height(),TRUE);
  68. EnumChildWindows(m_hWnd,(WNDENUMPROC)EnumChildProc,0);
  69. m_static1.SetFont (&g_titlefont);
  70. m_List1.SetHeadings( "编号,100;商品名称,150;销售价,100;类别,100" );
  71. m_List1.LoadColumnInfo (111);
  72. g_sendhead.bsql=0;
  73. g_sendhead.code[0]=8;
  74. g_sendhead.code[1]=2;
  75. g_sendhead.tabcount=2;
  76. g_pMainWnd->ProcessChatMessageRequest2(2);if(g_bSendOK==0)return;
  77. DataToArray(&m_List1array,&m_List2array);
  78. for(int i=0; i<m_List2array.GetSize (); i++)
  79. m_combo1.AddString (m_List2array.ElementAt (i).ElementAt (0));
  80. // if(m_combosplb.GetCount ())
  81. // m_combo1.SetCurSel (0);
  82. FillGrid();
  83. m_combo1.GetWindowRect (rc2);
  84. ScreenToClient(rc2);
  85. rc2.bottom +=200;
  86. m_combo1.MoveWindow (rc2);
  87. }
  88. void SPForm::FillGrid()
  89. {
  90. m_List1.DeleteAllItems2 ();
  91. int ii=0;
  92. m_List1.m_arLabels.SetSize( m_List1array.GetSize (), 1 );
  93. int count=0;
  94. if(m_filter.IsEmpty ())
  95. {
  96. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  97. {
  98. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  99. }
  100. }
  101. else
  102. {
  103. for(ii=0; ii<m_List1.m_arLabels.GetSize (); ii++)
  104. {
  105. if(m_List1array.ElementAt (ii).ElementAt (3)==m_filter || m_List1array.ElementAt (ii).ElementAt (1).Find (m_filter)!=-1)
  106. {
  107. m_List1.m_arLabels.ElementAt (count++).Copy (m_List1array.ElementAt (ii));
  108. }
  109. }
  110. }
  111. m_List1.m_arLabels.SetSize(count, 1);
  112. ii=count;
  113. m_List1.m_LabelCount=ii;
  114. m_List1.SetItemCountEx (ii);
  115. }
  116. void SPForm::OnBUTclose()
  117. {
  118. // TODO: Add your control notification handler code here
  119. GetParent()->SendMessage(WM_CLOSE);
  120. }
  121. void SPForm::OnButton1()
  122. {
  123. // TODO: Add your control notification handler code here
  124. UpdateData();
  125. m_filter.TrimLeft ();
  126. m_filter.TrimRight ();
  127. FillGrid();
  128. }
  129. void SPForm::OnSelchangeCombo1()
  130. {
  131. // TODO: Add your control notification handler code here
  132. SetTimer(1, 100, NULL);
  133. }
  134. void SPForm::OnTimer(UINT nIDEvent)
  135. {
  136. // TODO: Add your message handler code here and/or call default
  137. KillTimer(nIDEvent);
  138. OnButton1();
  139. }
  140. BOOL SPForm::PreTranslateMessage(MSG* pMsg)
  141. {
  142. // TODO: Add your specialized code here and/or call the base class
  143. try
  144. {
  145. if(pMsg->message==WM_KEYDOWN)
  146. {
  147. switch (pMsg->wParam)
  148. {
  149. case VK_RETURN:
  150. OnButton1();
  151. return 1;
  152. case 0x43: // copy
  153. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  154. {
  155. GetFocus()->SendMessage(WM_COPY);
  156. return TRUE;
  157. }
  158. break;
  159. case 0x56: //Ctrl + V:
  160. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  161. {
  162. GetFocus()->SendMessage(WM_PASTE);
  163. return TRUE;
  164. }
  165. break;
  166. case 0x58: // cut
  167. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  168. {
  169. GetFocus()->SendMessage(WM_CUT);
  170. return TRUE;
  171. }
  172. break;
  173. case 0x5A: //undo
  174. case 0x59: //redo
  175. if ( ( GetKeyState( VK_CONTROL ) & 0x80 ) )
  176. {
  177. GetFocus()->SendMessage(WM_UNDO);
  178. return TRUE;
  179. }
  180. break;
  181. }
  182. }
  183. return CFormView::PreTranslateMessage(pMsg);
  184. }
  185. catch(...)
  186. {
  187. }
  188. }