利用Codejock创建TaskPanel(ToolBox) - 2
Toolbox也可以使用真彩色图标
步骤如下:
1)
将真彩色icon添加到vs2005工程中
2)
BOOL CMainFrame::CreateTaskPanel()
{
if (!m_wndTaskPanel.Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP, CRect(0, 0, 0, 0), &m_wndSplitter, m_wndSplitter.IdFromRowCol(0, 0)))
return FALSE;
m_wndTaskPanel.SetOwner(this);
m_wndTaskPanel.GetImageManager()->SetIcon(IDI_ICON1, 0);
m_wndTaskPanel.GetImageManager()->SetIcon(IDI_ICON2, 1);
m_wndTaskPanel.GetImageManager()->SetIcon(IDI_ICON3, 2);
m_wndTaskPanel.SetBehaviour(xtpTaskPanelBehaviourToolbox);
m_wndTaskPanel.SetTheme(xtpTaskPanelThemeShortcutBarOffice2007);
m_wndTaskPanel.SetSelectItemOnFocus(TRUE);
m_wndTaskPanel.AllowDrag(TRUE);
m_wndTaskPanel.SetIconSize(CSize(32, 32));
m_wndTaskPanel.SetItemLayout(xtpTaskItemLayoutImagesWithTextBelow);
m_wndSplitter.SetColumnInfo(0, 210, 0);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////
//CXTPTaskPanel也可以直接放到View中
/////////////////////////////////////////////////////////////////////////
步骤如下:
1)
新建一个SDI
2)
View.h中
CXTPTaskPanel m_wndTaskPanel;
CXTPTaskPanelGroup* CreateToolboxGroup(UINT nID);
3)
View.cpp中
void CToolBox2View::OnInitialUpdate()
{
... ...
// TODO: Add your specialized code here and/or call the base class
if (!m_wndTaskPanel.Create(WS_CHILD|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_TABSTOP,
rc, this, 1231))
return ;
m_wndTaskPanel.SetOwner(this);
m_wndTaskPanel.GetImageManager()->SetIcon(IDI_ICON1, 0);
m_wndTaskPanel.GetImageManager()->SetIcon(IDI_ICON2, 1);
m_wndTaskPanel.GetImageManager()->SetIcon(IDI_ICON3, 2);
m_wndTaskPanel.SetBehaviour(xtpTaskPanelBehaviourToolbox);
m_wndTaskPanel.SetTheme(xtpTaskPanelThemeShortcutBarOffice2007);
m_wndTaskPanel.SetSelectItemOnFocus(TRUE);
m_wndTaskPanel.AllowDrag(TRUE);
m_wndTaskPanel.SetIconSize(CSize(32, 32));
m_wndTaskPanel.SetItemLayout(xtpTaskItemLayoutImagesWithTextBelow);
///////////////////////////////////////////////////////////////////////
m_wndTaskPanel.GetGroups()->Clear(FALSE);
CXTPTaskPanelGroup* pFolderPropertyPanes = CreateToolboxGroup(ID_TOOLBOXFOLDER_PROPERTYPANES);
CXTPTaskPanelGroup* pFolderData = CreateToolboxGroup(ID_TOOLBOXFOLDER_DATA);
pFolderData->AddLinkItem(ID_TOOLBOXITEM_DATASET ,1);
pFolderData->AddLinkItem(ID_TOOLBOXITEM_OLEDBDATAADAPTER ,1);
CXTPTaskPanelGroup* pFolderComponents = CreateToolboxGroup(ID_TOOLBOXFOLDER_PROPERTYPANES);
pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_DATASET ,2);
pFolderComponents->AddLinkItem(ID_TOOLBOXITEM_OLEDBDATAADAPTER ,1);
CreateToolboxGroup(ID_TOOLBOXFOLDER_GENERAL);
pFolderPropertyPanes->SetExpanded(TRUE);
}
CXTPTaskPanelGroup* CToolBox2View::CreateToolboxGroup(UINT nID)
{
CXTPTaskPanelGroup* pFolder = m_wndTaskPanel.AddGroup(nID);
CXTPTaskPanelGroupItem* pPointer = pFolder->AddLinkItem(ID_TOOLBOXITEM_POINTER, 0);
pPointer->SetItemSelected(TRUE);
pPointer->AllowDrag(FALSE);
pPointer->AllowDrop(FALSE);
pFolder->SetIconIndex(IDR_MAINFRAME);
return pFolder;
}