MyToolBar.cpp 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. #include "stdafx.h"
  2. #include "MyToolBar.h"
  3. #include "YLGL.h"
  4. #ifdef _DEBUG
  5. #define new DEBUG_NEW
  6. #undef THIS_FILE
  7. static char THIS_FILE[] = __FILE__;
  8. #endif
  9. /////////////////////////////////////////////////////////////////////////////
  10. // MyToolBar
  11. MyToolBar::MyToolBar()
  12. {
  13. }
  14. MyToolBar::~MyToolBar()
  15. {
  16. }
  17. BEGIN_MESSAGE_MAP(MyToolBar, CToolBar)
  18. //{{AFX_MSG_MAP(MyToolBar)
  19. //}}AFX_MSG_MAP
  20. ON_MESSAGE(XTWM_OUTBAR_NOTIFY, OnOutbarNotify)
  21. END_MESSAGE_MAP()
  22. /////////////////////////////////////////////////////////////////////////////
  23. // MyToolBar message handlers
  24. void MyToolBar::Init()
  25. {
  26. CRect rc=g_rc;
  27. rc.right -=rc.left ;
  28. rc.bottom -=rc.top ;
  29. rc.left =rc.top =0;
  30. rc.right =rc.left +157;
  31. rc.bottom =rc.top+g_rc.Height()-53;
  32. if (!m_wndOutlookBar.Create(WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN, rc,this, 0, OBS_XT_DEFAULT))
  33. {
  34. TRACE0("Failed to create outlook bar.");
  35. return;
  36. }
  37. // Set the background and text color of the outlook bar.
  38. m_wndOutlookBar.SetBackColor(RGB(0x3a,0x6e,0xa5));
  39. m_wndOutlookBar.SetTextColor(RGB(0xff,0xff,0xff));
  40. // Add items to the outlook bar.
  41. InitializeOutlookBar();
  42. }
  43. static UINT nIcons[] =
  44. {
  45. IDI_ICON1, IDI_ICON3, IDI_ICON4, IDI_ICON7,
  46. IDI_ICON8, IDI_ICON2, IDI_ICON11, IDI_ICON6,
  47. IDI_ICON9, IDI_ICON10, IDI_ICON5
  48. };
  49. void MyToolBar::InitializeOutlookBar()
  50. {
  51. // Create the image lists used by the outlook bar.
  52. m_ImageSmall.Create (16, 16, ILC_COLOR16|ILC_MASK, 2, 1);
  53. m_ImageLarge.Create (32, 32, ILC_COLOR16|ILC_MASK, 2, 1);
  54. // initiailize the image lists.
  55. for (int i = 0; i < 11; ++i)
  56. {
  57. HICON hIcon = AfxGetApp()->LoadIcon(nIcons[i]);
  58. ASSERT(hIcon);
  59. m_ImageSmall.Add(hIcon);
  60. m_ImageLarge.Add(hIcon);
  61. }
  62. int iFolder; // index of the added folder
  63. // set the image lists for the outlook bar.
  64. m_wndOutlookBar.SetImageList(&m_ImageLarge, OBS_XT_LARGEICON);
  65. m_wndOutlookBar.SetImageList(&m_ImageSmall, OBS_XT_SMALLICON);
  66. // Add the first folder to the outlook bar.
  67. iFolder = m_wndOutlookBar.AddFolder(_T("门市流程"), 0);
  68. // Add items to the folder, syntax is folder, index, text, image, and item data.
  69. m_wndOutlookBar.InsertItem(iFolder, 1, _T("预约"), 0, NULL);
  70. m_wndOutlookBar.InsertItem(iFolder, 2, _T("拍照"), 1, NULL);
  71. m_wndOutlookBar.InsertItem(iFolder, 3, _T("修片"), 2, NULL);
  72. m_wndOutlookBar.InsertItem(iFolder, 4, _T("选片"), 3, NULL);
  73. m_wndOutlookBar.InsertItem(iFolder, 5, _T("精修"), 4, NULL);
  74. m_wndOutlookBar.InsertItem(iFolder, 6, _T("设计"), 5, NULL);
  75. m_wndOutlookBar.InsertItem(iFolder, 7, _T("刻盘"), 6, NULL);
  76. m_wndOutlookBar.InsertItem(iFolder, 8, _T("发片/取件"), 7, NULL);
  77. // Add the second folder to the outlook bar.
  78. iFolder = m_wndOutlookBar.AddFolder(_T("财务管理"), 1);
  79. // Add items to the folder, syntax is folder, index, text, image, and item data.
  80. m_wndOutlookBar.InsertItem(iFolder, 1, _T("订单收款"), 0, NULL);
  81. m_wndOutlookBar.InsertItem(iFolder, 2, _T("现金支出"), 1, NULL);
  82. m_wndOutlookBar.InsertItem(iFolder, 3, _T("其它收入"), 0, NULL);
  83. m_wndOutlookBar.InsertItem(iFolder, 4, _T("日财务表"), 3, NULL);
  84. m_wndOutlookBar.InsertItem(iFolder, 5, _T("工资管理"), 4, NULL);
  85. m_wndOutlookBar.InsertItem(iFolder, 6, _T("客人付款"), 5, NULL);
  86. iFolder = m_wndOutlookBar.AddFolder(_T("统计查询"), 2);
  87. // Add items to the folder, syntax is folder, index, text, image, and item data.
  88. m_wndOutlookBar.InsertItem(iFolder, 1, _T("日财务表"), 0, NULL);
  89. m_wndOutlookBar.InsertItem(iFolder, 2, _T("月财务表"), 1, NULL);
  90. m_wndOutlookBar.InsertItem(iFolder, 3, _T("年财务表"), 2, NULL);
  91. m_wndOutlookBar.InsertItem(iFolder, 4, _T("年财务图表"), 3, NULL);
  92. m_wndOutlookBar.InsertItem(iFolder, 5, _T("工资报表"), 4, NULL);
  93. m_wndOutlookBar.InsertItem(iFolder, 6, _T("员工业绩"), 5, NULL);
  94. // iFolder = m_wndOutlookBar.AddFolder(_T("短信群发"), 3);
  95. iFolder = m_wndOutlookBar.AddFolder(_T("短信管理"), 3); // 2014.05.19 Jeff
  96. // Add items to the folder, syntax is folder, index, text, image, and item data.
  97. m_wndOutlookBar.InsertItem(iFolder, 1, _T("短信群发"), 0, NULL);
  98. m_wndOutlookBar.InsertItem(iFolder, 2, _T("短信发送"), 1, NULL);
  99. m_wndOutlookBar.InsertItem(iFolder, 3, _T("员工短信"), 2, NULL);
  100. m_wndOutlookBar.InsertItem(iFolder, 4, _T("发送记录"), 3, NULL);
  101. m_wndOutlookBar.InsertItem(iFolder, 5, _T("短信设置"), 4, NULL);
  102. iFolder = m_wndOutlookBar.AddFolder(_T("会员管理"), 4);
  103. // Add items to the folder, syntax is folder, index, text, image, and item data.
  104. m_wndOutlookBar.InsertItem(iFolder, 1, _T("查看会员"), 0, NULL);
  105. m_wndOutlookBar.InsertItem(iFolder, 2, _T("积分设置"), 1, NULL);
  106. iFolder = m_wndOutlookBar.AddFolder(_T("礼服管理"), 5);
  107. // Add items to the folder, syntax is folder, index, text, image, and item data.
  108. m_wndOutlookBar.InsertItem(iFolder, 1, _T("礼服录入"), 0, NULL);
  109. m_wndOutlookBar.InsertItem(iFolder, 2, _T("礼服查看"), 1, NULL);
  110. m_wndOutlookBar.InsertItem(iFolder, 3, _T("图片欣赏"), 2, NULL);
  111. m_wndOutlookBar.InsertItem(iFolder, 4, _T("礼服出租"), 3, NULL);
  112. iFolder = m_wndOutlookBar.AddFolder(_T("库存管理"), 6);
  113. // Add items to the folder, syntax is folder, index, text, image, and item data.
  114. m_wndOutlookBar.InsertItem(iFolder, 1, _T("商品类别设置"), 0, NULL);
  115. m_wndOutlookBar.InsertItem(iFolder, 2, _T("商品名称设置"), 1, NULL);
  116. m_wndOutlookBar.InsertItem(iFolder, 3, _T("入库单"), 2, NULL);
  117. m_wndOutlookBar.InsertItem(iFolder, 4, _T("出库单"), 3, NULL);
  118. m_wndOutlookBar.InsertItem(iFolder, 5, _T("库存查询"), 4, NULL);
  119. // Add the tree control to the outlook bar.
  120. //xu iFolder = m_wndOutlookBar.AddFolderBar(_T("Tree Control"), &m_wndTreeCtrl );
  121. // Set the default font used by the outlook bar.
  122. //xu m_wndOutlookBar.SetFontX(&xtAfxData.font);
  123. // We want to receive notification messages.
  124. m_wndOutlookBar.SetOwner(this);
  125. // Select the first folder in the bar.
  126. m_wndOutlookBar.SetSelFolder(0);
  127. }
  128. LRESULT MyToolBar::OnOutbarNotify(WPARAM wParam, LPARAM lParam)
  129. {
  130. int nBarAction = (int)wParam;
  131. // Cast the lParam to a XT_OUTBAR_INFO* struct pointer.
  132. XT_OUTBAR_INFO* pOBInfo = (XT_OUTBAR_INFO*)lParam;
  133. ASSERT(pOBInfo);
  134. switch (nBarAction)
  135. {
  136. case OBN_XT_ITEMCLICK:
  137. {
  138. CString strMsg=pOBInfo->lpszText;
  139. g_pMainWnd->OnOutbarNotify (strMsg);
  140. // AfxMessageBox(strMsg);
  141. // TRACE2( "Item selected: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
  142. }
  143. break;
  144. /* case OBN_XT_FOLDERCHANGE:
  145. TRACE2( "Folder selected: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
  146. break;
  147. case OBN_XT_ONLABELENDEDIT:
  148. TRACE2( "Item edited: %d, New name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
  149. break;
  150. case OBN_XT_ONGROUPENDEDIT:
  151. TRACE2( "Folder edited: %d, New name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
  152. break;
  153. case OBN_XT_DRAGITEM:
  154. TRACE3( "Dragging From: %d, To: %d, Name: %s.\n", pOBInfo->nDragFrom, pOBInfo->nDragTo, pOBInfo->lpszText);
  155. break;
  156. case OBN_XT_ITEMHOVER:
  157. TRACE2( "Hovering Item: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
  158. break;
  159. case OBN_XT_DELETEITEM:
  160. if (!m_bDestroy && AfxMessageBox(_T("Are you sure you want to remove this folder shortcut?"),
  161. MB_ICONWARNING|MB_YESNO) == IDNO)
  162. {
  163. // The user selected No, return FALSE to abort the action.
  164. return FALSE;
  165. }
  166. TRACE2( "Item deleted: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
  167. break;
  168. case OBN_XT_DELETEFOLDER:
  169. if (!m_bDestroy && AfxMessageBox(_T("Are you sure you want to remove the specified folder?"),
  170. MB_ICONWARNING|MB_YESNO) == IDNO)
  171. {
  172. // The user selected No, return FALSE to abort the action.
  173. return FALSE;
  174. }
  175. TRACE2( "Folder deleted: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText);
  176. break;*/
  177. }
  178. return TRUE;
  179. }
  180. void MyToolBar::SetSelFolder(int pos)
  181. {
  182. m_wndOutlookBar.SetSelFolder(pos);
  183. }
  184. BOOL MyToolBar::OnEraseBkgnd(CDC* pDC)
  185. {
  186. return 1;
  187. // TODO: Add your message handler code here and/or call default
  188. CRect rect;
  189. CBrush *pnewBrush=new CBrush(RGB(225,0,0));//(RGB(198,186,156));
  190. GetClientRect(&rect);
  191. pDC->FillRect (&rect,pnewBrush);
  192. delete pnewBrush;
  193. return 1;
  194. }