workbar.cpp
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:3k
- // mybar.cpp : implementation file
- //
- #include "stdafx.h"
- #include "resource.h"
- #include "workbar.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMyWorkBar
- CMyWorkBar::CMyWorkBar()
- {
- }
- CMyWorkBar::~CMyWorkBar()
- {
- }
- BEGIN_MESSAGE_MAP(CMyWorkBar, CSizingControlBar)
- //{{AFX_MSG_MAP(CMyWorkBar)
- ON_WM_CREATE()
- ON_WM_SIZE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyWorkBar message handlers
- int CMyWorkBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CSizingControlBar::OnCreate(lpCreateStruct) == -1)
- return -1;
- if (!m_wndTab.Create(WS_CHILD | WS_VISIBLE, CRect(0,0,0,0), this, IDC_TAB))
- return -1;
- if (!m_wndTree.Create(WS_CHILD | WS_VISIBLE | TVS_LINESATROOT | TVS_HASLINES
- | TVS_HASBUTTONS | WS_BORDER | WS_TABSTOP | WS_VSCROLL, CRect(0,0,0,0),
- this, IDC_TREE))
- return -1;
- //设置3D外观
- m_wndTree.ModifyStyleEx(0, WS_EX_CLIENTEDGE);
- if (!m_wndList.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | WS_EX_CLIENTEDGE,
- CRect(0,0,0,0), this, IDC_LIST))
- return -1;
- //设置3D外观的另一种方法
- SetWindowLong(m_wndList.GetSafeHwnd(), GWL_EXSTYLE, WS_EX_CLIENTEDGE);
- //设置字体
- if (!m_font.CreateStockObject(DEFAULT_GUI_FONT))
- return -1;
- m_wndTab.SetFont(&m_font);
- //初始化工作区
- m_wndTab.InsertItem(0, "项目");
- m_wndTab.InsertItem(1, "元件");
- //初始化树形框
- CImageList m_TreeImageList;
- m_TreeImageList.Create(16, 16, ILC_MASK, 2, 2);
- m_TreeImageList.Add(AfxGetApp()->LoadIcon(IDI_PROJECT));
- m_TreeImageList.Add(AfxGetApp()->LoadIcon(IDI_FILE));
- m_wndTree.SetImageList(&m_TreeImageList, TVSIL_NORMAL);
- m_TreeImageList.Detach();
- m_wndTree.ShowWindow(FALSE);
-
- //初始化列表框
- CImageList m_ListImageList;
- m_ListImageList.Create(32, 32, ILC_MASK, 2, 2);
- m_ListImageList.Add(AfxGetApp()->LoadIcon(IDI_FILE));
- m_ListImageList.Add(AfxGetApp()->LoadIcon(IDI_FILE));
- m_wndList.SetImageList(&m_ListImageList, TVSIL_NORMAL);
- m_ListImageList.Detach();
- m_wndList.ShowWindow(FALSE);
- return 0;
- }
- void CMyWorkBar::OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler)
- {
- UpdateDialogControls(pTarget, bDisableIfNoHndler);
- }
- void CMyWorkBar::OnSize(UINT nType, int cx, int cy)
- {
- CSizingControlBar::OnSize(nType, cx, cy);
-
- // TODO: Add your message handler code here
- CRect rc;
- GetClientRect(rc);
- rc.DeflateRect(4, 4);
- m_wndTab.MoveWindow(rc);
- rc.left += 5;
- rc.top += 30;
- rc.right -= 5;
- rc.bottom -= 10;
- m_wndTree.MoveWindow(rc);
- m_wndList.MoveWindow(rc);
- }