ComboListCtrl6.cpp 16 KB

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