mybar.cpp
上传用户:nbkytg
上传日期:2021-02-14
资源大小:126k
文件大小:3k
- // mybar.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ctreecontrolbar.h"
- #include "mybar.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // mybar
- mybar::mybar()
- {
- }
- mybar::~mybar()
- {
- }
- BEGIN_MESSAGE_MAP(mybar, CSizingControlBar)
- //{{AFX_MSG_MAP(mybar)
- ON_WM_CREATE()
- ON_WM_SIZE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // mybar message handlers
- void mybar::OnUpdateCmdUI(CFrameWnd *pTarget, BOOL bDisableIfNoHndler)
- {
- UpdateDialogControls(pTarget, bDisableIfNoHndler);
- }
- int mybar::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CSizingControlBar::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- // TODO: Add your specialized creation code here
- m_TreeCtrl.Create(WS_VISIBLE | WS_TABSTOP | WS_CHILD | WS_BORDER
- | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_HASLINES
- | TVS_DISABLEDRAGDROP|TVS_EDITLABELS|TVS_TRACKSELECT,
- CRect(10, 10, 300, 100), this, ID_TREECTRL);
-
-
- // m_TreeCtrl.SetImageList(&m_images,TVSIL_NORMAL);
- // set "normal" GUI-font
- CFont *font = CFont::FromHandle((HFONT)::GetStockObject(DEFAULT_GUI_FONT));
- m_TreeCtrl.SetFont(font);
-
- HTREEITEM root = m_TreeCtrl.InsertItem("VCKBASE",0,0);
- HTREEITEM subroot1=m_TreeCtrl.InsertItem("程序员社区",1,1,root);
- HTREEITEM subroot2=m_TreeCtrl.InsertItem("文档中心",1,1,root);
- HTREEITEM subroot3=m_TreeCtrl.InsertItem("代码仓库",1,1,root);
- HTREEITEM subroot4=m_TreeCtrl.InsertItem("工具和资源",1,1,root);
- HTREEITEM subroot5=m_TreeCtrl.InsertItem("客服中心",1,1,root);
- HTREEITEM subroot6=m_TreeCtrl.InsertItem("个人专栏",1,1,root);
- /*
- m_TreeCtrl.SetItemImage(subroot1,1,0);
- m_TreeCtrl.SetItemImage(subroot2,1,0);
- m_TreeCtrl.SetItemImage(subroot3,1,0);
- */
- m_TreeCtrl.InsertItem("开发论坛",1,1,subroot1);
- m_TreeCtrl.InsertItem("开发联盟",1,1,subroot1);
- m_TreeCtrl.InsertItem("人才交流",1,1,subroot1);
- m_TreeCtrl.InsertItem("用户注册",1,1,subroot1);
- m_TreeCtrl.InsertItem("VCity",1,1,subroot1);
-
- m_TreeCtrl.InsertItem("在线杂志",1,1,subroot2);
- m_TreeCtrl.InsertItem("个人专辑",1,1,subroot2);
- m_TreeCtrl.InsertItem("论坛精华",1,1,subroot2);
- m_TreeCtrl.InsertItem("酷库",1,1,subroot2);
- m_TreeCtrl.InsertItem("所有文章",1,1,subroot2);
- m_TreeCtrl.InsertItem("所有代码",1,1,subroot3);
-
- m_TreeCtrl.InsertItem("程序工具箱",1,1,subroot4);
- m_TreeCtrl.InsertItem("程序工具箱",1,1,subroot5);
- m_TreeCtrl.InsertItem("用户注册",1,1,subroot5);
- m_TreeCtrl.InsertItem("修改信息",1,1,subroot5);
- m_TreeCtrl.InsertItem("取回密码",1,1,subroot5);
- m_TreeCtrl.InsertItem("问题解答",1,1,subroot5);
- m_TreeCtrl.InsertItem("投稿",1,1,subroot5);
- m_TreeCtrl.InsertItem("联系我们",1,1,subroot5);
-
- m_TreeCtrl.SelectItem(root);
- m_TreeCtrl.Expand(root, TVE_EXPAND);
- m_TreeCtrl.Expand(subroot1, TVE_EXPAND);
- m_TreeCtrl.Expand(subroot2, TVE_EXPAND);
- m_TreeCtrl.Expand(subroot3, TVE_EXPAND);
- m_TreeCtrl.Expand(subroot4, TVE_EXPAND);
- m_TreeCtrl.Expand(subroot5, TVE_EXPAND);
- return 0;
- }
- void mybar::OnSize(UINT nType, int cx, int cy)
- {
- CSizingControlBar::OnSize(nType, cx, cy);
-
- // TODO: Add your message handler code here
-
- CRect rc;
- GetClientRect(&rc);
- m_TreeCtrl.MoveWindow(&rc);
- }