|
-
April 26th, 1999, 02:39 PM
#1
CTreeCtrl bug with GetItem()
I have encountered some bizarre behaviour with a dialog based app. Hopefully, I'm doing something wrong, but suggestions for investigations are welcome.
The dialog has a Tree Control mapped to a class member of type CTreeCtrl. There are also some buttons and the dialog class handles the BN_CLICK message. The code for this method is as follows.
void CTreeCtrlBugDlg::OnButton1()
{
TV_ITEM SelectedItem;
SelectedItem.hItem = m_tcTree.GetSelectedItem();
if ( SelectedItem.hItem == NULL )
return;
if ( !m_tcTree.GetItem(&SelectedItem) )
return;
}
When there is no data in the tree control, the code functions fine and the first call to GetSelectedItem, returns NULL; However when there is data in the tree control, but *NO* item is selected, the call returns a non NULL value. Under this situation, the subsequent call to GetItem returns TRUE, but as soon as the method returns, the program crashes with a page fault in MFC42D.DLL.
Conversely, when there is data in the tree control and an item is selected, all works as expected and no difficulties occur. The application links with MFC dynamically and so to make this even more bizarre, I can not duplicate the difficulty with the release mode version of the application!
Thanks for any hints!
Chris Meech
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|