CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Help! Errors

  1. #1
    Join Date
    Apr 1999
    Posts
    121

    Help! Errors

    I've numbered the errors and showed in the code where it points to with the number of the error.

    If someone can sheed some light on what I'm doing wrong it would be appreciated.

    Thank you in advance

    void CVRSessionView::GetSelectedTreeItems( vector<HTREEITEM> &list)
    {
    list.clear();

    CListCtrl &ctlList = GetListCtrl();
    int index= ctlList.GetNextItem( -1, LVNI_SELECTED);
    while( index >= 0) {
    CObject *pObject= (CObject *) ctlList.GetItemData( index);
    HTREEITEM hTreeItem= (HTREEITEM) ctlList.GetItemData( index);
    //if( hTreeItem != NULL)
    //if(CObject != NULL)
    if( pObject != NULL && pObject->IsKindOf( RUNTIME_CLASS(CNodeInfo))) #1 & #2
    list.push_back( hTreeItem);


    index= ctlList.GetNextItem( index, LVNI_SELECTED);
    }
    }

    void CVRSessionView::OnDblclk(NMHDR* pNMHDR, LRESULT* pResult)
    {

    CListCtrl &ctlList = GetListCtrl();
    if( ctlList.GetSelectedCount() == 1) {
    int index= ctlList.GetNextItem( -1, LVNI_SELECTED);
    if( index >= 0) {
    CObject *pObject= (CObject *) ctlList.GetItemData( index);
    HTREEITEM hTreeItem= (HTREEITEM) ctlList.GetItemData( index);
    //if( hTreeItem != NULL) {
    //if(CObject != NULL){
    if( pObject != NULL && pObject->IsKindOf( RUNTIME_CLASS(CNodeInfo))){ #3
    pTree->GetTreeCtrl().Select( hTreeItem, TVGN_CARET);
    }
    }
    }


    *pResult = 0;
    }

    void CVRUtilitiesTree::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
    {
    NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
    // TODO: Add your control notification handler code here

    CTreeCtrl &ctlTree = GetTreeCtrl();
    HTREEITEM selItem= pNMTreeView->itemNew.hItem;
    CListCtrl &ctlList= pListView->GetListCtrl();
    ctlList.DeleteAllItems();

    if( ctlTree.ItemHasChildren( selItem)) {
    int i= 0;

    HTREEITEM childItem= ctlTree.GetChildItem( selItem);

    while( childItem != NULL) {
    int image, dummy;
    ctlTree.GetItemImage( childItem, image, dummy);
    ctlList.InsertItem(i,ctlTree.GetItemText( childItem),image);
    CNodeInfo *pNodeInfo= new CNodeInfo;
    pNodeInfo->SetNodeInfo( childItem);
    ctlList.SetItemData( i, DWORD (CObject*) pNodeInfo); #4
    i++;
    childItem= ctlTree.GetNextSiblingItem( childItem);
    }
    }
    else{
    Session *pSession= (Session *) ctlTree.GetItemData( selItem);
    if( pSession != NULL) {
    Directory reponseDir( pSession->GetPath());
    FileVector responseFiles;
    reponseDir.EnumChilds( "*.wav", responseFiles);
    for( int i= 0; i < responseFiles.size(); i++) {
    ctlList.InsertItem(i,ToCString( responseFiles[ i].GetBase()),4);
    CFileInfo *pFileInfo= new CFileInfo;
    pFileInfo->SetFileInfo( responseFiles[i]);
    ctlList.SetItemData( i, DWORD (CObject*) pNodeInfo); #5
    }
    }
    }

    *pResult = 0;
    }

    class CNodeInfo : public CObject
    {
    public:
    void SetNodeInfo(HTREEITEM item);
    HTREEITEM GetNodeInfo();
    CNodeInfo();
    virtual ~CNodeInfo();

    private:
    HTREEITEM m_nodeInfo;
    };


    1) K:\projet2\VRUtilities\VRSessionView.cpp(164) : error C2039: 'classCNodeInfo' : is not a member of 'CNodeInfo'
    k:\projet2\vrutilities\nodeinfo.h(13) : see declaration of 'CNodeInfo'
    2) K:\projet2\VRUtilities\VRSessionView.cpp(164) : error C2065: 'classCNodeInfo' : undeclared identifier
    3) K:\projet2\VRUtilities\VRSessionView.cpp(281) : error C2039: 'classCNodeInfo' : is not a member of 'CNodeInfo'
    k:\projet2\vrutilities\nodeinfo.h(13) : see declaration of 'CNodeInfo'
    VRUtilitiesTree.cpp
    4) K:\projet2\VRUtilities\VRUtilitiesTree.cpp(293) : error C2059: syntax error : ')'
    5) K:\projet2\VRUtilities\VRUtilitiesTree.cpp(308) : error C2059: syntax error : ')'



  2. #2
    Guest

    Re: Help! Errors

    If you have derived your class from CObject you must use the DECLARE_DYNAMIC and IMPLEMENT_DYNAMIC, the DECLARE_DYNCREATE and IMPLEMENT_DYNCREATE macros explained in the online help article "Deriving a Class from CObject". If you do not you can not determine class of an object at run time.


  3. #3
    Guest

    Re: Help! Errors

    For point #1#2#3 you should add DECLARE_DYNCREATE macro and IMPLEMENT_DYNCREATE macro

    class CNodeInfo : public CObject
    {
    DECLARE_DYNCREATE(CNodeInfo)
    public:
    void SetNodeInfo(HTREEITEM item);
    HTREEITEM GetNodeInfo();
    CNodeInfo();
    virtual ~CNodeInfo();

    private:
    HTREEITEM m_nodeInfo;
    };


    in .CPP

    IMPLEMENT_DYNCREATE(CNodeInfo,CObject)

    Stéphane Blanc
    [email protected]


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured