Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Problem with CExtTreeCtrl and DeleteAllItems() Collapse All
Subject Author Date
Lars Mohr Jun 17, 2011 - 6:06 PM

Dear Support-Team,

there are two bugs in the CExtTreeCtrl class.

First case:

If you insert more items with parent = NULL and call the DeleteAllItems function then CExtTreeCtrl::_UnregisterItemsFromMap delete all TREEITEMINFO_t of first root item and all children but not the sibling items. The CExtTreeCtrl::WindowProc will detect the misstake and the ASSERT is triggered.


LRESULT CExtTreeCtrl::WindowProc( UINT message, WPARAM wParam, LPARAM lParam )
{
    switch( message )
    {

...

    case TVM_DELETEITEM:
    {
        HTREEITEM hti = (HTREEITEM)lParam;
        _UnregisterItemsFromMap( hti );
    }
    break;
    } // switch( message )
LRESULT lResult = CTreeCtrl::WindowProc( message, wParam, lParam );
    switch( message )
    {

...

    case TVM_DELETEITEM:
    {
        HTREEITEM hti = (HTREEITEM)lParam;
        if( m_htiDelayedFocus == hti )
        {
            m_htiDelayedFocus = NULL;
            KillTimer( m_nDelayedFocusTimerID );
            KillTimer( m_nDelayedEditingTimerID );
        }
        m_wndContentExpand.Deactivate();
        if( m_hWndChildControl != NULL )
            SendMessage( WM_CANCELMODE );
////    _UnregisterItemsFromMap( hti );
#ifdef _DEBUG
        if( hti == NULL || hti == TVI_ROOT )
        {
            ASSERT( m_mapItemInfo.GetCount() == 0 );
        }
#endif // _DEBUG
    }

...

Second case (That was harder to find out):

If you have only one root item with severel child items and one of it is selected and you call the DeleteAllItems function then CExtTreeCtrl::_UnregisterItemsFromMap delete all TREEITEMINFO_t perfect BUT the CTreeCtrl::WindowProc calls unfortunatlly the OnPaint and this in turn call the TreeItemInfoGet which generate a new TREEITEMINFO_t and the ASSERT is fired again. To prevent this OnPaint call you have to unselect all items before:


    m_wndTree.FocusItem(m_wndTree.GetRootItem(),FALSE,TRUE,FALSE);
    m_wndTree.DeleteAllItems();

 Best regards

Technical Support Jun 18, 2011 - 11:10 AM

The assertion is obsolete and should be removed. Thank you.