#include "stdafx.h" #include "MyToolBar.h" #include "YLGL.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // MyToolBar MyToolBar::MyToolBar() { } MyToolBar::~MyToolBar() { } BEGIN_MESSAGE_MAP(MyToolBar, CToolBar) //{{AFX_MSG_MAP(MyToolBar) //}}AFX_MSG_MAP ON_MESSAGE(XTWM_OUTBAR_NOTIFY, OnOutbarNotify) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // MyToolBar message handlers void MyToolBar::Init() { CRect rc=g_rc; rc.right -=rc.left ; rc.bottom -=rc.top ; rc.left =rc.top =0; rc.right =rc.left +157; rc.bottom =rc.top+g_rc.Height()-53; if (!m_wndOutlookBar.Create(WS_CHILD|WS_VISIBLE|WS_CLIPCHILDREN, rc,this, 0, OBS_XT_DEFAULT)) { TRACE0("Failed to create outlook bar."); return; } // Set the background and text color of the outlook bar. m_wndOutlookBar.SetBackColor(RGB(0x3a,0x6e,0xa5)); m_wndOutlookBar.SetTextColor(RGB(0xff,0xff,0xff)); // Add items to the outlook bar. InitializeOutlookBar(); } static UINT nIcons[] = { IDI_ICON1, IDI_ICON3, IDI_ICON4, IDI_ICON7, IDI_ICON8, IDI_ICON2, IDI_ICON11, IDI_ICON6, IDI_ICON9, IDI_ICON10, IDI_ICON5 }; void MyToolBar::InitializeOutlookBar() { // Create the image lists used by the outlook bar. m_ImageSmall.Create (16, 16, ILC_COLOR16|ILC_MASK, 2, 1); m_ImageLarge.Create (32, 32, ILC_COLOR16|ILC_MASK, 2, 1); // initiailize the image lists. for (int i = 0; i < 11; ++i) { HICON hIcon = AfxGetApp()->LoadIcon(nIcons[i]); ASSERT(hIcon); m_ImageSmall.Add(hIcon); m_ImageLarge.Add(hIcon); } int iFolder; // index of the added folder // set the image lists for the outlook bar. m_wndOutlookBar.SetImageList(&m_ImageLarge, OBS_XT_LARGEICON); m_wndOutlookBar.SetImageList(&m_ImageSmall, OBS_XT_SMALLICON); // Add the first folder to the outlook bar. iFolder = m_wndOutlookBar.AddFolder(_T("门市流程"), 0); // Add items to the folder, syntax is folder, index, text, image, and item data. m_wndOutlookBar.InsertItem(iFolder, 1, _T("预约"), 0, NULL); m_wndOutlookBar.InsertItem(iFolder, 2, _T("拍照"), 1, NULL); m_wndOutlookBar.InsertItem(iFolder, 3, _T("修片"), 2, NULL); m_wndOutlookBar.InsertItem(iFolder, 4, _T("选片"), 3, NULL); m_wndOutlookBar.InsertItem(iFolder, 5, _T("精修"), 4, NULL); m_wndOutlookBar.InsertItem(iFolder, 6, _T("设计"), 5, NULL); m_wndOutlookBar.InsertItem(iFolder, 7, _T("刻盘"), 6, NULL); m_wndOutlookBar.InsertItem(iFolder, 8, _T("发片/取件"), 7, NULL); // Add the second folder to the outlook bar. iFolder = m_wndOutlookBar.AddFolder(_T("财务管理"), 1); // Add items to the folder, syntax is folder, index, text, image, and item data. m_wndOutlookBar.InsertItem(iFolder, 1, _T("订单收款"), 0, NULL); m_wndOutlookBar.InsertItem(iFolder, 2, _T("现金支出"), 1, NULL); m_wndOutlookBar.InsertItem(iFolder, 3, _T("其它收入"), 0, NULL); m_wndOutlookBar.InsertItem(iFolder, 4, _T("日财务表"), 3, NULL); m_wndOutlookBar.InsertItem(iFolder, 5, _T("工资管理"), 4, NULL); m_wndOutlookBar.InsertItem(iFolder, 6, _T("客人付款"), 5, NULL); iFolder = m_wndOutlookBar.AddFolder(_T("统计查询"), 2); // Add items to the folder, syntax is folder, index, text, image, and item data. m_wndOutlookBar.InsertItem(iFolder, 1, _T("日财务表"), 0, NULL); m_wndOutlookBar.InsertItem(iFolder, 2, _T("月财务表"), 1, NULL); m_wndOutlookBar.InsertItem(iFolder, 3, _T("年财务表"), 2, NULL); m_wndOutlookBar.InsertItem(iFolder, 4, _T("年财务图表"), 3, NULL); m_wndOutlookBar.InsertItem(iFolder, 5, _T("工资报表"), 4, NULL); m_wndOutlookBar.InsertItem(iFolder, 6, _T("员工业绩"), 5, NULL); // iFolder = m_wndOutlookBar.AddFolder(_T("短信群发"), 3); iFolder = m_wndOutlookBar.AddFolder(_T("短信管理"), 3); // 2014.05.19 Jeff // Add items to the folder, syntax is folder, index, text, image, and item data. m_wndOutlookBar.InsertItem(iFolder, 1, _T("短信群发"), 0, NULL); m_wndOutlookBar.InsertItem(iFolder, 2, _T("短信发送"), 1, NULL); m_wndOutlookBar.InsertItem(iFolder, 3, _T("员工短信"), 2, NULL); m_wndOutlookBar.InsertItem(iFolder, 4, _T("发送记录"), 3, NULL); m_wndOutlookBar.InsertItem(iFolder, 5, _T("短信设置"), 4, NULL); iFolder = m_wndOutlookBar.AddFolder(_T("会员管理"), 4); // Add items to the folder, syntax is folder, index, text, image, and item data. m_wndOutlookBar.InsertItem(iFolder, 1, _T("查看会员"), 0, NULL); m_wndOutlookBar.InsertItem(iFolder, 2, _T("积分设置"), 1, NULL); iFolder = m_wndOutlookBar.AddFolder(_T("礼服管理"), 5); // Add items to the folder, syntax is folder, index, text, image, and item data. m_wndOutlookBar.InsertItem(iFolder, 1, _T("礼服录入"), 0, NULL); m_wndOutlookBar.InsertItem(iFolder, 2, _T("礼服查看"), 1, NULL); m_wndOutlookBar.InsertItem(iFolder, 3, _T("图片欣赏"), 2, NULL); m_wndOutlookBar.InsertItem(iFolder, 4, _T("礼服出租"), 3, NULL); iFolder = m_wndOutlookBar.AddFolder(_T("库存管理"), 6); // Add items to the folder, syntax is folder, index, text, image, and item data. m_wndOutlookBar.InsertItem(iFolder, 1, _T("商品类别设置"), 0, NULL); m_wndOutlookBar.InsertItem(iFolder, 2, _T("商品名称设置"), 1, NULL); m_wndOutlookBar.InsertItem(iFolder, 3, _T("入库单"), 2, NULL); m_wndOutlookBar.InsertItem(iFolder, 4, _T("出库单"), 3, NULL); m_wndOutlookBar.InsertItem(iFolder, 5, _T("库存查询"), 4, NULL); // Add the tree control to the outlook bar. //xu iFolder = m_wndOutlookBar.AddFolderBar(_T("Tree Control"), &m_wndTreeCtrl ); // Set the default font used by the outlook bar. //xu m_wndOutlookBar.SetFontX(&xtAfxData.font); // We want to receive notification messages. m_wndOutlookBar.SetOwner(this); // Select the first folder in the bar. m_wndOutlookBar.SetSelFolder(0); } LRESULT MyToolBar::OnOutbarNotify(WPARAM wParam, LPARAM lParam) { int nBarAction = (int)wParam; // Cast the lParam to a XT_OUTBAR_INFO* struct pointer. XT_OUTBAR_INFO* pOBInfo = (XT_OUTBAR_INFO*)lParam; ASSERT(pOBInfo); switch (nBarAction) { case OBN_XT_ITEMCLICK: { CString strMsg=pOBInfo->lpszText; g_pMainWnd->OnOutbarNotify (strMsg); // AfxMessageBox(strMsg); // TRACE2( "Item selected: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText); } break; /* case OBN_XT_FOLDERCHANGE: TRACE2( "Folder selected: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText); break; case OBN_XT_ONLABELENDEDIT: TRACE2( "Item edited: %d, New name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText); break; case OBN_XT_ONGROUPENDEDIT: TRACE2( "Folder edited: %d, New name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText); break; case OBN_XT_DRAGITEM: TRACE3( "Dragging From: %d, To: %d, Name: %s.\n", pOBInfo->nDragFrom, pOBInfo->nDragTo, pOBInfo->lpszText); break; case OBN_XT_ITEMHOVER: TRACE2( "Hovering Item: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText); break; case OBN_XT_DELETEITEM: if (!m_bDestroy && AfxMessageBox(_T("Are you sure you want to remove this folder shortcut?"), MB_ICONWARNING|MB_YESNO) == IDNO) { // The user selected No, return FALSE to abort the action. return FALSE; } TRACE2( "Item deleted: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText); break; case OBN_XT_DELETEFOLDER: if (!m_bDestroy && AfxMessageBox(_T("Are you sure you want to remove the specified folder?"), MB_ICONWARNING|MB_YESNO) == IDNO) { // The user selected No, return FALSE to abort the action. return FALSE; } TRACE2( "Folder deleted: %d, Name: %s.\n", pOBInfo->nIndex, pOBInfo->lpszText); break;*/ } return TRUE; } void MyToolBar::SetSelFolder(int pos) { m_wndOutlookBar.SetSelFolder(pos); } BOOL MyToolBar::OnEraseBkgnd(CDC* pDC) { return 1; // TODO: Add your message handler code here and/or call default CRect rect; CBrush *pnewBrush=new CBrush(RGB(225,0,0));//(RGB(198,186,156)); GetClientRect(&rect); pDC->FillRect (&rect,pnewBrush); delete pnewBrush; return 1; }