15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


CTreeCtrl and double clicks

Jeff Eldridge -- jeldridge@cix.compulink.co.uk
Tuesday, May 07, 1996

In-Reply-To: <96Apr22.071047cdt.17862@mail.aegonusa.com>

Environment: NT 3.51 (SP3), VC++ 4.1

I have a property page with a CTreeCtrl in it. I'm trapping the double 
click notification but I'm getting a strange access violation. My handler 
looks like:

void X::OnDblClickTree(NMHDR* pNMHDR, LRESULT* pResult)
{
        // Get the selected item. m_Tree is a CTreeCtrl
        HTREEITEM hItem = m_Tree.GetSelectedItem();
        TV_ITEM tvi;
        if (NULL != hItem)
        {
                // Get the selected items text
                tvi.hItem = hItem;
                tvi.mask = TVIF_TEXT;
                m_Tree.GetItem (&tvi);
        }

        *pResult = 0;
}

This code causes an access violation in wincore.cpp line 209 in 
AfxCallWndProc. If the call to m_Tree.GetItem is commented out, 
everything is fine.

Anyone any ideas?



Cheers, Jeff




LeRoy Baxter -- lbaxter@cinfo.com
Thursday, May 09, 1996

[Moderator's note: There were 9 responses.  The first is good enough.]

you need a buffer for the item you are retrieving.

void X::OnDblClickTree(NMHDR* pNMHDR, LRESULT* pResult)
{
      char buf[256];

        // Get the selected item. m_Tree is a CTreeCtrl
        HTREEITEM hItem = m_Tree.GetSelectedItem();
        TV_ITEM tvi;
        if (NULL != hItem)
        {
                // Get the selected items text
                tvi.hItem = hItem;
                tvi.mask = TVIF_TEXT;
                tvi.pszText = buf;
                tvi.cchTextMax = 256;
                m_Tree.GetItem (&tvi);
        }

        *pResult = 0;
}




| Вернуться в корень Архива |