ComboListCtrl6.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. // ComboBoxListCtrl4.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ComboListCtrl6.h"
  5. #include <windowsx.h>
  6. #include "ylgl.h"
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. #define IDC_ComboBox 0X01
  13. #define PROPERTY_ITEM 0x02
  14. #define PROPERTY_SUB 0x03
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CComboBoxListCtrl6
  17. //ComboBox////////////////////////////////////////////////////////////////////////
  18. CListCtrlComboBox6::CListCtrlComboBox6()
  19. {
  20. }
  21. CListCtrlComboBox6::~CListCtrlComboBox6()
  22. {
  23. }
  24. BEGIN_MESSAGE_MAP(CListCtrlComboBox6, CComboBox)
  25. //{{AFX_MSG_MAP(CListCtrlComboBox6)
  26. ON_WM_KILLFOCUS()
  27. ON_WM_SETFOCUS()
  28. ON_CONTROL_REFLECT(CBN_CLOSEUP, OnCloseup)
  29. //}}AFX_MSG_MAP
  30. END_MESSAGE_MAP()
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CListCtrlComboBox6 message handlers
  33. void CListCtrlComboBox6::SetCtrlData(DWORD dwData)
  34. {
  35. m_dwData = dwData;
  36. }
  37. DWORD CListCtrlComboBox6::GetCtrlData()
  38. {
  39. return m_dwData;
  40. }
  41. void CListCtrlComboBox6::OnKillFocus(CWnd* pNewWnd)
  42. {
  43. CComboBox::OnKillFocus(pNewWnd);
  44. CWnd* pParent = this->GetParent();
  45. // ::PostMessage(pParent->GetSafeHwnd(),WM_USER_ComboBox_END,m_bExchange,0);
  46. }
  47. BOOL CListCtrlComboBox6::PreTranslateMessage(MSG* pMsg)
  48. {
  49. if(pMsg->message == WM_KEYDOWN)
  50. {
  51. if(pMsg->wParam == VK_RETURN)
  52. {
  53. CWnd* pParent = this->GetParent();
  54. m_bExchange = TRUE;
  55. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_ComboBox_END,m_bExchange,0);
  56. }
  57. else if(pMsg->wParam == VK_ESCAPE)
  58. {
  59. CWnd* pParent = this->GetParent();
  60. m_bExchange = FALSE;
  61. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_ComboBox_END,m_bExchange,0);
  62. }
  63. }
  64. return CComboBox::PreTranslateMessage(pMsg);
  65. }
  66. void CListCtrlComboBox6::OnSetFocus(CWnd* pOldWnd)
  67. {
  68. CComboBox::OnSetFocus(pOldWnd);
  69. m_bExchange = TRUE;
  70. }
  71. void CListCtrlComboBox6::OnCloseup()
  72. {
  73. // TODO: Add your control notification handler code here
  74. CWnd* pParent = this->GetParent();
  75. ::PostMessage(pParent->GetSafeHwnd(),WM_USER_ComboBox_END,m_bExchange,0);
  76. }
  77. ///ListCtrl/////////////////////////////////////////////////////
  78. CComboBoxListCtrl6::CComboBoxListCtrl6()
  79. {
  80. // m_pComboBox->m_hWnd = NULL;
  81. }
  82. CComboBoxListCtrl6::~CComboBoxListCtrl6()
  83. {
  84. }
  85. BEGIN_MESSAGE_MAP(CComboBoxListCtrl6, CListCtrl)
  86. //{{AFX_MSG_MAP(CComboBoxListCtrl6)
  87. ON_WM_LBUTTONDBLCLK()
  88. ON_WM_LBUTTONDOWN()
  89. ON_WM_PARENTNOTIFY()
  90. ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomdrawList)
  91. //}}AFX_MSG_MAP
  92. ON_MESSAGE(WM_USER_ComboBox_END,OnComboBoxEnd)
  93. ON_MESSAGE(WM_USER_EDIT_END,OnEditEnd)
  94. END_MESSAGE_MAP()
  95. void CComboBoxListCtrl6::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
  96. {
  97. NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
  98. // Take the default processing unless we set this to something else below.
  99. *pResult = 0;
  100. // First thing - check the draw stage. If it's the control's prepaint
  101. // stage, then tell Windows we want messages for every item.
  102. if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
  103. {
  104. *pResult = CDRF_NOTIFYITEMDRAW;
  105. }
  106. else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
  107. {
  108. // This is the prepaint stage for an item. Here's where we set the
  109. // item's text color. Our return value will tell Windows to draw the
  110. // item itself, but it will use the new color we set here.
  111. // We'll cycle the colors through red, green, and light blue.
  112. COLORREF crText;
  113. int pos=pLVCD->nmcd.dwItemSpec;
  114. if(pos%2)
  115. {
  116. pLVCD->clrTextBk = g_gridcol1;
  117. }
  118. else
  119. {
  120. pLVCD->clrTextBk = g_gridcol2;
  121. }
  122. // Tell Windows to paint the control itself.
  123. *pResult = CDRF_DODEFAULT;
  124. }
  125. }
  126. void CComboBoxListCtrl6::OnLButtonDown(UINT nFlags, CPoint point)
  127. {
  128. ::PostMessage(this->GetSafeHwnd(),WM_USER_ComboBox_END,1,0);
  129. CListCtrl::OnLButtonDown( nFlags, point) ;
  130. }
  131. void CComboBoxListCtrl6::OnLButtonDblClk(UINT nFlags, CPoint point)
  132. {
  133. CRect rcCtrl;
  134. LVHITTESTINFO lvhti;
  135. lvhti.pt = point;
  136. int nItem = CListCtrl::SubItemHitTest(&lvhti);
  137. if(nItem == -1)
  138. return;
  139. int nSubItem = lvhti.iSubItem;
  140. CListCtrl::GetSubItemRect(nItem,nSubItem,LVIR_LABEL,rcCtrl);
  141. rcCtrl.top -=4;
  142. if(nSubItem==2 || nSubItem==7)
  143. {
  144. rcCtrl.bottom +=200;
  145. rcCtrl.top +=2;
  146. ShowComboBox2(TRUE,nItem,nSubItem,rcCtrl);
  147. }
  148. else if(nSubItem==8)
  149. {
  150. ShowEdit(TRUE,nItem,nSubItem,rcCtrl);
  151. }
  152. else if(nSubItem==4)
  153. {
  154. rcCtrl.bottom +=200;
  155. rcCtrl.top +=2;
  156. ShowComboBox3(TRUE,nItem,nSubItem,rcCtrl);
  157. }
  158. else if(nSubItem==5 || nSubItem==6)
  159. {
  160. rcCtrl.bottom +=200;
  161. rcCtrl.top +=2;
  162. ShowComboBox(TRUE,nItem,nSubItem,rcCtrl);
  163. }
  164. else if(nSubItem==3 )
  165. ShowDateCtrl(TRUE,nItem,nSubItem,rcCtrl);
  166. CListCtrl::OnLButtonDblClk(nFlags, point);
  167. }
  168. void CComboBoxListCtrl6::ShowEdit(BOOL bShow,int nItem,int nIndex,CRect rcCtrl)
  169. {
  170. if(m_edit.m_hWnd == NULL)
  171. {
  172. m_edit.Create(ES_AUTOHSCROLL|WS_CHILD|ES_LEFT|ES_WANTRETURN|WS_BORDER,CRect(0,0,0,0),this,101);
  173. m_edit.ShowWindow(SW_HIDE);
  174. CFont tpFont;
  175. tpFont.CreateStockObject(DEFAULT_GUI_FONT);
  176. m_edit.SetFont(&tpFont);
  177. tpFont.DeleteObject();
  178. }
  179. if(bShow == TRUE)
  180. {
  181. CString strItem = CListCtrl::GetItemText(nItem,nIndex);
  182. m_edit.MoveWindow(rcCtrl);
  183. m_edit.ShowWindow(SW_SHOW);
  184. m_edit.SetWindowText(strItem);
  185. ::SetFocus(m_edit.GetSafeHwnd());
  186. m_edit.SetSel(-1);
  187. m_edit.SetCtrlData(MAKEWPARAM(nIndex,nItem));
  188. }
  189. else
  190. m_edit.ShowWindow(SW_HIDE);
  191. }
  192. void CComboBoxListCtrl6::ShowDateCtrl(BOOL bShow,int nItem,int nIndex,CRect rcCtrl)
  193. {
  194. if(m_DateCtrl.m_hWnd == NULL)
  195. {
  196. m_DateCtrl.Create(WS_CHILD,CRect(0,0,0,0),this,IDC_ComboBox);
  197. m_DateCtrl.ShowWindow(SW_HIDE);
  198. }
  199. if(bShow == TRUE)
  200. {
  201. CString strItem = CListCtrl::GetItemText(nItem,nIndex);
  202. if(strItem.GetLength ()==10)
  203. {
  204. CTime tm(atoi(strItem.Mid (0,4)), atoi(strItem.Mid (5,2)), atoi(strItem.Mid (8,2)), 0,0,0);
  205. m_DateCtrl.SetTime(&tm);
  206. }
  207. else
  208. {
  209. CTime tm=CTime::GetCurrentTime ();
  210. // CTimeSpan dt(3, 0, 0, 0);
  211. // tm+=dt;
  212. m_DateCtrl.SetTime(&tm);
  213. }
  214. m_DateCtrl.MoveWindow(rcCtrl);
  215. m_DateCtrl.ShowWindow(SW_SHOW);
  216. ::SetFocus(m_DateCtrl.GetSafeHwnd());
  217. m_nSub=nIndex;
  218. m_nItem=nItem;
  219. }
  220. else
  221. m_DateCtrl.ShowWindow(SW_HIDE);
  222. }
  223. void CComboBoxListCtrl6::ShowComboBox2(BOOL bShow,int nItem,int nIndex,CRect rcCtrl)
  224. {
  225. if(m_ComboBox.m_hWnd == NULL)
  226. {
  227. m_ComboBox.Create(WS_VSCROLL|WS_CHILD|CBS_DROPDOWNLIST,CRect(0,0,0,0),this,IDC_ComboBox);
  228. m_ComboBox.ShowWindow(SW_HIDE);
  229. }
  230. if(bShow == TRUE)
  231. {
  232. CString strItem = CListCtrl::GetItemText(nItem,nIndex);
  233. m_ComboBox.MoveWindow(rcCtrl);
  234. m_ComboBox.ShowWindow(SW_SHOW);
  235. ::SetFocus(m_ComboBox.GetSafeHwnd());
  236. m_ComboBox.ResetContent ();
  237. if(nIndex==2)
  238. {
  239. m_ComboBox.AddString ("¹«Àú");
  240. m_ComboBox.AddString ("Å©Àú");
  241. }
  242. else if(nIndex==7)
  243. {
  244. m_ComboBox.AddString ("δ¿ªÊ¼");
  245. m_ComboBox.AddString ("½øÐÐÖÐ");
  246. m_ComboBox.AddString ("OK");
  247. }
  248. m_ComboBox.SetCurSel (m_ComboBox.FindString (0, strItem));
  249. m_ComboBox.SetCtrlData(MAKEWPARAM(nIndex,nItem));
  250. }
  251. else
  252. m_ComboBox.ShowWindow(SW_HIDE);
  253. }
  254. void CComboBoxListCtrl6::ShowComboBox3(BOOL bShow,int nItem,int nIndex,CRect rcCtrl)
  255. {
  256. if(m_ComboBox2.m_hWnd == NULL)
  257. {
  258. m_ComboBox2.Create(WS_VSCROLL|WS_CHILD|CBS_DROPDOWN,CRect(0,0,0,0),this,IDC_ComboBox);
  259. m_ComboBox2.ShowWindow(SW_HIDE);
  260. m_ComboBox2.AddString ("09:00");
  261. m_ComboBox2.AddString ("10:00");
  262. m_ComboBox2.AddString ("11:00");
  263. m_ComboBox2.AddString ("12:00");
  264. m_ComboBox2.AddString ("13:00");
  265. m_ComboBox2.AddString ("14:00");
  266. m_ComboBox2.AddString ("15:00");
  267. m_ComboBox2.AddString ("16:00");
  268. m_ComboBox2.AddString ("17:00");
  269. m_ComboBox2.AddString ("18:00");
  270. m_ComboBox2.AddString ("19:00");
  271. m_ComboBox2.AddString ("20:00");
  272. m_ComboBox2.AddString ("21:00");
  273. m_ComboBox2.AddString ("22:00");
  274. }
  275. if(bShow == TRUE)
  276. {
  277. CString strItem = CListCtrl::GetItemText(nItem,nIndex);
  278. m_ComboBox2.MoveWindow(rcCtrl);
  279. m_ComboBox2.ShowWindow(SW_SHOW);
  280. ::SetFocus(m_ComboBox2.GetSafeHwnd());
  281. // m_ComboBox2.SetCurSel (m_ComboBox2.FindString (0, strItem));
  282. m_ComboBox2.SetWindowText ( strItem );
  283. m_ComboBox2.SetCtrlData(MAKEWPARAM(nIndex,nItem));
  284. }
  285. else
  286. m_ComboBox2.ShowWindow(SW_HIDE);
  287. }
  288. void CComboBoxListCtrl6::ShowComboBox(BOOL bShow,int nItem,int nIndex,CRect rcCtrl)
  289. {
  290. if(0)//m_pComboBox->m_hWnd == NULL)
  291. {
  292. m_pComboBox->Create(WS_VSCROLL|WS_CHILD|CBS_DROPDOWNLIST,CRect(0,0,0,0),this,IDC_ComboBox);
  293. m_pComboBox->ShowWindow(SW_HIDE);
  294. for(int i=0; i<g_List1array.GetSize (); i++)
  295. m_pComboBox->AddString (g_List1array.ElementAt (i).ElementAt (0));
  296. m_pComboBox->AddString ("");
  297. }
  298. if(bShow == TRUE)
  299. {
  300. CString strItem = CListCtrl::GetItemText(nItem,nIndex);
  301. ClientToScreen(rcCtrl);
  302. GetParent()->ScreenToClient(rcCtrl);
  303. m_pComboBox->MoveWindow(rcCtrl);
  304. m_pComboBox->ShowWindow(SW_SHOW);
  305. m_pComboBox->SetWindowPos(&wndTopMost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
  306. ::SetFocus(m_pComboBox->GetSafeHwnd());
  307. m_pComboBox->ResetContent();
  308. m_pComboBox->AddString(strItem);
  309. m_pComboBox->SetCurSel (0);
  310. m_pComboBox->SetCtrlData(MAKEWPARAM(nIndex,nItem));
  311. m_pComboBox->RefDroppedWidth();
  312. }
  313. else
  314. m_pComboBox->ShowWindow(SW_HIDE);
  315. }
  316. #ifdef VC60
  317. void CComboBoxListCtrl6::OnEditEnd(WPARAM wParam,LPARAM lParam)
  318. {
  319. if(wParam == TRUE)
  320. {
  321. CString strText(_T(""));
  322. m_edit.GetWindowText(strText);
  323. DWORD dwData = m_edit.GetCtrlData();
  324. int nItem= dwData>>16;
  325. int nIndex = dwData&0x0000ffff;
  326. CListCtrl::SetItemText(nItem,nIndex,strText);
  327. }
  328. else
  329. {
  330. }
  331. if(lParam == FALSE)
  332. m_edit.ShowWindow(SW_HIDE);
  333. }
  334. void CComboBoxListCtrl6::OnComboBoxEnd(WPARAM wParam,LPARAM lParam)
  335. {
  336. if(m_DateCtrl.m_hWnd)
  337. {
  338. if(m_DateCtrl.IsWindowVisible ())
  339. {
  340. if(wParam == TRUE)
  341. {
  342. CString strText(_T(""));
  343. CTime tm;
  344. m_DateCtrl.GetTime(tm);
  345. strText=tm.Format ("%Y-%m-%d");
  346. CListCtrl::SetItemText(m_nItem,m_nSub,strText);
  347. }
  348. if(lParam == FALSE)
  349. m_DateCtrl.ShowWindow(SW_HIDE);
  350. return;
  351. }
  352. }
  353. if(m_ComboBox.m_hWnd)
  354. {
  355. if(m_ComboBox.IsWindowVisible ())
  356. {
  357. if(wParam == TRUE)
  358. {
  359. CString strText(_T(""));
  360. int pos=m_ComboBox.GetCurSel ();
  361. if(pos!=-1)
  362. {
  363. m_ComboBox.GetLBText (pos, strText);
  364. DWORD dwData = m_ComboBox.GetCtrlData();
  365. int nItem= dwData>>16;
  366. int nIndex = dwData&0x0000ffff;
  367. CListCtrl::SetItemText(nItem,nIndex,strText);
  368. }
  369. }
  370. else
  371. {
  372. }
  373. if(lParam == FALSE)
  374. m_ComboBox.ShowWindow(SW_HIDE);
  375. return;
  376. }
  377. }
  378. if(m_ComboBox2.m_hWnd)
  379. {
  380. if(m_ComboBox2.IsWindowVisible ())
  381. {
  382. if(wParam == TRUE)
  383. {
  384. CString strText(_T(""));
  385. /* int pos=m_ComboBox2.GetCurSel ();
  386. if(pos!=-1)
  387. {
  388. m_ComboBox2.GetLBText (pos, strText);*/
  389. m_ComboBox2.GetWindowText ( strText);
  390. DWORD dwData = m_ComboBox2.GetCtrlData();
  391. int nItem= dwData>>16;
  392. int nIndex = dwData&0x0000ffff;
  393. CListCtrl::SetItemText(nItem,nIndex,strText);
  394. // }
  395. }
  396. else
  397. {
  398. }
  399. if(lParam == FALSE)
  400. m_ComboBox2.ShowWindow(SW_HIDE);
  401. return;
  402. }
  403. }
  404. if(m_pComboBox->m_hWnd)
  405. {
  406. if(!m_pComboBox->IsWindowVisible ())return;
  407. if(wParam == TRUE)
  408. {
  409. CString strText(_T(""));
  410. int pos=m_pComboBox->GetCurSel ();
  411. if(pos!=-1)
  412. {
  413. m_pComboBox->GetLBText (pos, strText);
  414. DWORD dwData = m_pComboBox->GetCtrlData();
  415. int nItem= dwData>>16;
  416. int nIndex = dwData&0x0000ffff;
  417. CListCtrl::SetItemText(nItem,nIndex,strText);
  418. }
  419. }
  420. else
  421. {
  422. }
  423. if(lParam == FALSE)
  424. m_pComboBox->ShowWindow(SW_HIDE);
  425. }
  426. }
  427. #else
  428. LRESULT CComboBoxListCtrl6::OnEditEnd(WPARAM wParam,LPARAM lParam)
  429. {
  430. if(wParam == TRUE)
  431. {
  432. CString strText(_T(""));
  433. m_edit.GetWindowText(strText);
  434. DWORD dwData = m_edit.GetCtrlData();
  435. int nItem= dwData>>16;
  436. int nIndex = dwData&0x0000ffff;
  437. CListCtrl::SetItemText(nItem,nIndex,strText);
  438. }
  439. else
  440. {
  441. }
  442. if(lParam == FALSE)
  443. m_edit.ShowWindow(SW_HIDE);
  444. return 0;
  445. }
  446. LRESULT CComboBoxListCtrl6::OnComboBoxEnd(WPARAM wParam,LPARAM lParam)
  447. {
  448. if(m_DateCtrl.m_hWnd)
  449. {
  450. if(m_DateCtrl.IsWindowVisible ())
  451. {
  452. if(wParam == TRUE)
  453. {
  454. CString strText(_T(""));
  455. CTime tm;
  456. m_DateCtrl.GetTime(tm);
  457. strText=tm.Format ("%Y-%m-%d");
  458. CListCtrl::SetItemText(m_nItem,m_nSub,strText);
  459. }
  460. if(lParam == FALSE)
  461. m_DateCtrl.ShowWindow(SW_HIDE);
  462. return 0;
  463. }
  464. }
  465. if(m_ComboBox.m_hWnd)
  466. {
  467. if(m_ComboBox.IsWindowVisible ())
  468. {
  469. if(wParam == TRUE)
  470. {
  471. CString strText(_T(""));
  472. int pos=m_ComboBox.GetCurSel ();
  473. if(pos!=-1)
  474. {
  475. m_ComboBox.GetLBText (pos, strText);
  476. DWORD dwData = m_ComboBox.GetCtrlData();
  477. int nItem= dwData>>16;
  478. int nIndex = dwData&0x0000ffff;
  479. CListCtrl::SetItemText(nItem,nIndex,strText);
  480. }
  481. }
  482. else
  483. {
  484. }
  485. if(lParam == FALSE)
  486. m_ComboBox.ShowWindow(SW_HIDE);
  487. return 0;
  488. }
  489. }
  490. if(m_ComboBox2.m_hWnd)
  491. {
  492. if(m_ComboBox2.IsWindowVisible ())
  493. {
  494. if(wParam == TRUE)
  495. {
  496. CString strText(_T(""));
  497. /* int pos=m_ComboBox2.GetCurSel ();
  498. if(pos!=-1)
  499. {
  500. m_ComboBox2.GetLBText (pos, strText);*/
  501. m_ComboBox2.GetWindowText ( strText);
  502. DWORD dwData = m_ComboBox2.GetCtrlData();
  503. int nItem= dwData>>16;
  504. int nIndex = dwData&0x0000ffff;
  505. CListCtrl::SetItemText(nItem,nIndex,strText);
  506. // }
  507. }
  508. else
  509. {
  510. }
  511. if(lParam == FALSE)
  512. m_ComboBox2.ShowWindow(SW_HIDE);
  513. return 0;
  514. }
  515. }
  516. if(m_pComboBox->m_hWnd)
  517. {
  518. if(!m_pComboBox->IsWindowVisible ())return 0;
  519. if(wParam == TRUE)
  520. {
  521. CString strText(_T(""));
  522. int pos=m_pComboBox->GetCurSel ();
  523. if(pos!=-1)
  524. {
  525. m_pComboBox->GetLBText (pos, strText);
  526. DWORD dwData = m_pComboBox->GetCtrlData();
  527. int nItem= dwData>>16;
  528. int nIndex = dwData&0x0000ffff;
  529. CListCtrl::SetItemText(nItem,nIndex,strText);
  530. }
  531. }
  532. else
  533. {
  534. }
  535. if(lParam == FALSE)
  536. m_pComboBox->ShowWindow(SW_HIDE);
  537. }
  538. return 0;
  539. }
  540. #endif
  541. void CComboBoxListCtrl6::OnParentNotify(UINT message, LPARAM lParam)
  542. {
  543. CListCtrl::OnParentNotify(message, lParam);
  544. //////////////////////////////////////////////////////////////////////////
  545. CHeaderCtrl* pHeaderCtrl = CListCtrl::GetHeaderCtrl();
  546. if(pHeaderCtrl == NULL)
  547. return;
  548. CRect rcHeader;
  549. pHeaderCtrl->GetWindowRect(rcHeader);
  550. ScreenToClient(rcHeader);
  551. //The x coordinate is in the low-order word and the y coordinate is in the high-order word.
  552. CPoint pt;
  553. pt.x = GET_X_LPARAM(lParam);
  554. pt.y = GET_Y_LPARAM(lParam);
  555. if(rcHeader.PtInRect(pt) && message == WM_LBUTTONDOWN)
  556. {
  557. if(m_pComboBox->m_hWnd != NULL)
  558. {
  559. DWORD dwStyle = m_pComboBox->GetStyle();
  560. if((dwStyle&WS_VISIBLE) == WS_VISIBLE)
  561. {
  562. m_pComboBox->ShowWindow(SW_HIDE);
  563. }
  564. }
  565. if(m_DateCtrl.m_hWnd)
  566. {
  567. if(m_DateCtrl.IsWindowVisible ())m_DateCtrl.ShowWindow(SW_HIDE);
  568. }
  569. }
  570. }
  571. BOOL CComboBoxListCtrl6::PreTranslateMessage(MSG* pMsg)
  572. {
  573. /* if(pMsg->message == WM_LBUTTONUP)
  574. {
  575. if(m_DateCtrl.m_hWnd)
  576. {
  577. if(m_DateCtrl.IsWindowVisible ())
  578. {
  579. ::PostMessage(this->GetSafeHwnd(),WM_USER_ComboBox_END,1,0);
  580. m_DateCtrl.ShowWindow(SW_HIDE);
  581. }
  582. }
  583. }*/
  584. return CListCtrl::PreTranslateMessage(pMsg);
  585. }
  586. BOOL CComboBoxListCtrl6::Key_Shift(int& nItem,int& nSub)
  587. {
  588. int nItemCount = CListCtrl::GetItemCount();
  589. DWORD dwData = m_pComboBox->GetCtrlData();
  590. nItem= dwData>>16;
  591. nSub = dwData&0x0000ffff;
  592. CHeaderCtrl* pHeader = CListCtrl::GetHeaderCtrl();
  593. if(pHeader == NULL)
  594. return FALSE;
  595. short sRet = GetKeyState(VK_SHIFT);
  596. int nSubcCount = pHeader->GetItemCount();
  597. sRet = sRet >>15;
  598. if(sRet == 0)
  599. {
  600. nSub += 1;
  601. if(nSub >= nSubcCount)
  602. {
  603. if(nItem == nItemCount-1)
  604. {
  605. nItem = 0;
  606. nSub = 0;
  607. }
  608. else
  609. {
  610. nSub = 0;
  611. nItem += 1;
  612. }
  613. }
  614. if(nItem >= nItemCount)
  615. nItem = nItemCount-1;
  616. return FALSE;
  617. }
  618. else
  619. {
  620. nSub -= 1;
  621. if(nSub < 0)
  622. {
  623. nSub = nSubcCount -1;
  624. nItem --;
  625. }
  626. if(nItem < 0)
  627. nItem = nItemCount-1;
  628. return TRUE;
  629. }
  630. return FALSE;
  631. }
  632. BOOL CComboBoxListCtrl6::Key_Ctrl(int& nItem,int &nSub)
  633. {
  634. short sRet = GetKeyState(VK_CONTROL);
  635. DWORD dwData = m_pComboBox->GetCtrlData();
  636. nItem= dwData>>16;
  637. nSub = dwData&0x0000ffff;
  638. sRet = sRet >>15;
  639. int nItemCount = CListCtrl::GetItemCount();
  640. if(sRet == 0)
  641. {
  642. }
  643. else
  644. {
  645. nItem = nItem >=nItemCount-1? 0:nItem+=1;
  646. return TRUE;
  647. }
  648. return FALSE;
  649. }
  650. void CComboBoxListCtrl6::InitStyle()
  651. {
  652. SetFont (&g_listctrlfont);
  653. SetExtendedStyle(LVS_EX_FLATSB|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP);
  654. }
  655. #undef SubclassWindow
  656. void CComboBoxListCtrl6::PreSubclassWindow()
  657. {
  658. // the list control must have the report style.
  659. CListCtrl::PreSubclassWindow();
  660. m_ctlHeader.SubclassWindow ( GetHeaderCtrl()->GetSafeHwnd());
  661. }