I get an error when tryng to clear the list.
When I call:
GetTreeCtrl().DeleteAllItems();
I get a debug assertion error.
I'd appreciate if you could help me.
Assume you have CMainFrame window class and the view associated with is a CTreeView let say CTek04View.
The following code is working :
CMainFrame * pFrame = (CMainFrame *) AfxGetMainWnd();
if (pFrame)
{
CTek04View * pView = (CTek04View *) pFrame->GetActiveView();
if (pView)
{
pView->GetTreeCtrl().DeleteAllItems();
}
else
{
// error no view object with this Frame window
}
}
else
{
// error no Frame window !
}
-obislavu-
I'm sorry. It was my fault I didn't gave details. My code is exactly like the one you gave me.
The thing is that I don't always get an error. When I open a new document or an old one I try to delete all the items in the list. If the last item is selected, the list is cleared and nothing happens. But if any other item but the last one is selected, I get an assertion error. It's very confusing. I thought that it has something to do with the item's handle (HTREEITEM), but I'm not sure.
If you have a pointer to the control and it is not null then DeleteAllItems() should work even there are no items in the tree or they are selected or not.
Put more code here.
-obislavu-
I was using the DeleteAllItems() function in OnNewDocumnent() and in OnOpenDocument() and it didn't work. Now I've moved it into DeleteContents() and is working perfectly. Can you explain me why is that? It seemed to be more logically that the function would be in OnNewDocumnent() and OnOpenDocument(),because it's an initialization of a view.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.