Hi,
I would like to have the possibility to put a CXTPTaskPanelGroup inside of a CXTPTaskPanelGroupItems class. Since CXTPTaskPanelGroup is a child of CXTPTaskPanelItem, this should be pretty straightforward. In doing so, I could have multiple levels of nested groups inside my task panels (kink of like in a treeview). Here is the code I used to nest my groups (modified version of toolbox sample) (I force the call to ResetToolboxItems at every program startup):
void CMainFrame::ResetToolboxItems() { m_wndTaskPanel.GetGroups()->Clear(FALSE);
CXTPTaskPanelGroup* pFolderData = CreateToolboxGroup(ID_TOOLBOXFOLDER_DATA); pFolderData->AddLinkItem(ID_TOOLBOXITEM_DATASET&nbs p; &nbs p; ,26); pFolderData->AddLinkItem(ID_TOOLBOXITEM_OLEDBDATAAD APTER ,27); pFolderData->AddLinkItem(ID_TOOLBOXITEM_OLEDBCONNEC TION ,28); pFolderData->AddLinkItem(ID_TOOLBOXITEM_OLEDBCOMMAN D   ; ,29); pFolderData->AddLinkItem(ID_TOOLBOXITEM_SQLDATAADAP TER ,30); pFolderData->AddLinkItem(ID_TOOLBOXITEM_SQLCONNECTI ON &nbs p; ,31); pFolderData->AddLinkItem(ID_TOOLBOXITEM_SQLCOMMAND& nbsp; & nbsp; ,32); pFolderData->AddLinkItem(ID_TOOLBOXITEM_DATAVIEW&nb sp; &nb sp; ,33);
{ CXTPTaskPanelGroup* pFolderGeneral = new CXTPTaskPanelGroup(&m_wndTaskPanel); CXTPTaskPanelGroupItem* pPointer = pFolderGeneral->AddLinkItem(ID_TOOLBOXITEM_POINTER, 0); pPointer->SetItemSelected(TRUE); pPointer->AllowDrag(FALSE); pPointer->AllowDrop(FALSE); pFolderGeneral->SetIconIndex(IDR_MAINFRAME); pFolderGeneral->SetCaption( L"BOB" ); pFolderData->GetItems()->Add( pFolderGeneral, ID_TOOLBOXFOLDER_GENERAL ); }
pFolderData->SetExpanded(TRUE); }
With the above code, everything compiles (all I do is legal according to the class hierarchy and the documentation). The problem occurs at runtime. I get a crash in this function:
void CXTPTaskPanelPaintManager::DrawGroupClientItems(CDC* pDC, CXTPTaskPanelGroup* pGroup, CRect rc) { int nOffset = rc.top - pGroup->GetScrollOffsetPos();
for (int i = pGroup->GetOffsetItem(); i < pGroup->GetItemCount(); i++) { CXTPTaskPanelGroupItem* pItem = pGroup->GetAt(i); if (!pItem->IsVisible()) continue;
CRect rcItem = pItem->GetItemRect(); rcItem.OffsetRect(0, nOffset);
pItem->OnDrawItem(pDC, rcItem); } }
The problem comes from the GetAt function which does a c static cast on the returned pointer assuming that the base class pointer is of a certain derived type (which is a bug or a lack of documentation, in my opinion) Here is the code of GetAt:
CXTPTaskPanelGroupItem* CXTPTaskPanelGroup::GetAt(int nIndex) const { return (CXTPTaskPanelGroupItem*)m_pItems->GetAt(nIndex); }
I would really appreciate if someone at codejock could tell me if you are going to support nested CXTPTaskPanelGroup in a short period of time. We would need such a feature as soon as it would be available.
------------- Frédérick Beaupré
Software Developper
InnovMetric Software Inc.
|