Re: Message handling in class
Thank you, Dave. I knew this approach, but when I did this:
void CtreeDlg::OnItemexpandingTree(NMHDR* pNMHDR, LRESULT* pResult)
{
fsp.OnItemexpandingTree(pNMHDR, pResult);
}
runtime error occured in this line (which is outside of
FileSystemParser::OnItemexpandingTree method -- in )
NETRESOURCE *const pNetResource = (NETRESOURCE *)(Tree-
GetItemData( hItem ) );
it says: "Unhandled exception at 0x78a74dee (mfc90ud.dll) in tree.exe:
0xC0000005: Access violation reading location 0x00000020."
HERE:
// winctrl2.cpp
DWORD_PTR CTreeCtrl::GetItemData(HTREEITEM hItem) const
{
ENSURE(::IsWindow(m_hWnd)); // <---- here error happens
// ......... other code
}
If you need the code:
void FileSystemParser::OnItemexpandingTree(NMHDR* pNMHDR, LRESULT*
pResult)
{
TRACE( _T("CDlgGetPath::OnItemexpandingTree(%p)\n"), pNMHDR );
CWaitCursor CursorWaiting; //Show the wait cursor while
expanding
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
ASSERT( pNMTreeView );
ASSERT( pResult );
//Only action 2 notifications
if( pNMTreeView->action == 2 )
{
//Update location display
CString sPath = GetItemPath( pNMTreeView->itemNew.hItem );
//Refresh children
if( !Tree->GetChildItem( pNMTreeView->itemNew.hItem ) )
{
PopulateTree(pNMTreeView->itemNew.hItem );
if(Tree->GetSelectedItem( ) != pNMTreeView->itemNew.hItem )
Tree->SelectItem( pNMTreeView->itemNew.hItem );
}
}
*pResult = 0;
}
CString FileSystemParser::GetItemPath( HTREEITEM hItem )
{
TRACE( _T("CtreeDlg::GetItemPath(%p)\n"), hItem );
CString sRet;
do
{
//End with a share name.
NETRESOURCE *const pNetResource = (NETRESOURCE *)(Tree-
GetItemData( hItem ) );
if( pNetResource )
{
sRet = CString(pNetResource->lpRemoteName) + _T('\\')+ sRet;
break;
}
//Add the directory name to the path.
sRet = Tree->GetItemText( hItem ) + _T('\\')+ sRet;
hItem = Tree->GetParentItem( hItem );
} while( hItem );
return sRet;
}