CTreeCtrl weird problem
-
The problem is the following: The text of inserted items do not appear if and only if i call DeleteAllItems() before inserting them. Something like this: CTreeCtrl* pTreeCtrl = ( CTreeCtrl* ) GetDlgItem( IDC_TREE ); if ( !pTreeCtrl ) return; if ( !pTreeCtrl->DeleteAllItems() ) return; pTreeCtrl->InsertItem( "testing" ); pTreeCtrl->InsertItem( "testing1" ); If i remove the DeleteAllItems() function call everything works as it should. Any tip ? Thanks
-
The problem is the following: The text of inserted items do not appear if and only if i call DeleteAllItems() before inserting them. Something like this: CTreeCtrl* pTreeCtrl = ( CTreeCtrl* ) GetDlgItem( IDC_TREE ); if ( !pTreeCtrl ) return; if ( !pTreeCtrl->DeleteAllItems() ) return; pTreeCtrl->InsertItem( "testing" ); pTreeCtrl->InsertItem( "testing1" ); If i remove the DeleteAllItems() function call everything works as it should. Any tip ? Thanks
This is a known issue. There is a MS article about that. The problem can be resolved by calling SetRedraw(TRUE). Example: DeleteAllItems(); SetRedraw(TRUE); InsertItem(...); The problem is that DeleteAllItems resets internal counter (number of items) to -1 instead of 0.
-
This is a known issue. There is a MS article about that. The problem can be resolved by calling SetRedraw(TRUE). Example: DeleteAllItems(); SetRedraw(TRUE); InsertItem(...); The problem is that DeleteAllItems resets internal counter (number of items) to -1 instead of 0.