CTreeCtrl Problem
-
What I am doing may be stupid. But if I want to do like this then what to do... In the doubleclick of the tree view item I delete that item. In that case the application crashed. What to do if I want to delete the item in the doubleclick. What is the reason that it is crashing.
Regards Anil
-
What I am doing may be stupid. But if I want to do like this then what to do... In the doubleclick of the tree view item I delete that item. In that case the application crashed. What to do if I want to delete the item in the doubleclick. What is the reason that it is crashing.
Regards Anil
Almost sounds like some still points to the item.. Gotta post some code.. ;)
-
Almost sounds like some still points to the item.. Gotta post some code.. ;)
For your reference I make the code like this...
void CBackupTreeBar::OnNMDblclkBckTree(NMHDR *pNMHDR, LRESULT *pResult) { if( IsSelectFile() == TRUE ){ m_BackupTree.DeleteItem( m_BackupTree.GetRootItem() ); } *pResult = 0; }
This code will crash... But If make *pResult = -1; it is working. Of course the tree items won't be there.Regards Anil
-
For your reference I make the code like this...
void CBackupTreeBar::OnNMDblclkBckTree(NMHDR *pNMHDR, LRESULT *pResult) { if( IsSelectFile() == TRUE ){ m_BackupTree.DeleteItem( m_BackupTree.GetRootItem() ); } *pResult = 0; }
This code will crash... But If make *pResult = -1; it is working. Of course the tree items won't be there.Regards Anil
You're deleting a tree item in an event handler that is processing an event fired by that very item. Chances are, the tree control is going to do some other work after your handler returns that will involve that tree item. You could see how deleting it would be a bad idea.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
-
For your reference I make the code like this...
void CBackupTreeBar::OnNMDblclkBckTree(NMHDR *pNMHDR, LRESULT *pResult) { if( IsSelectFile() == TRUE ){ m_BackupTree.DeleteItem( m_BackupTree.GetRootItem() ); } *pResult = 0; }
This code will crash... But If make *pResult = -1; it is working. Of course the tree items won't be there.Regards Anil
_anil_ wrote:
m_BackupTree.DeleteItem( m_BackupTree.GetRootItem() );
You are deleting the whole tree item here, is this your intension?
_anil_ wrote:
*pResult = 0; } This code will crash... But If make *pResult = -1; it is working.
I'm not sure, but i think this is why your code get crashed. If you set pResult is 0, then the frame work thinks that you didn't handle this notification,so it'll proceed with its task. But you already deleted the tree items, so its crashing. If you set values other than zero then, the framework knows that you handled the notifaction and it does nothing.
Do your Duty and Don't expect the Result
-
What I am doing may be stupid. But if I want to do like this then what to do... In the doubleclick of the tree view item I delete that item. In that case the application crashed. What to do if I want to delete the item in the doubleclick. What is the reason that it is crashing.
Regards Anil
-
What I am doing may be stupid. But if I want to do like this then what to do... In the doubleclick of the tree view item I delete that item. In that case the application crashed. What to do if I want to delete the item in the doubleclick. What is the reason that it is crashing.
Regards Anil