Click derecho y CTreeCtrl.

01/03/2004 - 19:06 por William GS | Informe spam
Hola a todos, tengo un diálogo modal y en él un CTreeCtrl,
al capturar el evento NM_RCLICK de este árbol el
ClassWizard me crea la siguiente función:

void CorgProfilesDlg::OnRclickTree(NMHDR* pNMHDR, LRESULT*
pResult)
{
*pResult = 0;

// TODO: Add your control notification handler code here
UINT nFlags = 0;
HTREEITEM hNodo;
CPoint posMouse;
GetCursorPos(&posMouse);

hNodo = m_treeProfiles.HitTest(posMouse, &nFlags);

}

Esta función no me da la posición del mouse por lo que la
estoy obteniendo con 'GetCursorPos(&posMouse)', luego
llamó a 'm_treeProfiles.HitTest(posMouse, &nFlags)' para
saber sobre que nodo se hizo el click derecho
pero 'HitTest' me devuelve NULL ¿Cual puede ser el
problema?. Asimismo, el puntero 'pNMHDR' que pasa la
funcion antes mecionada, ¿como lo puedo usar? ¿se 'castea'
a alguna estructura como en CListCtrl?.

Muchas gracias,

William GS
 

Leer las respuestas

#1 Alex
01/03/2004 - 20:37 | Informe spam
no sé si t puede servir. yo uso el context menú para añadir elementos a un
CTreeCtrl con el boton derecho. Es algo parecido a:

void CDialogoDlg::OnContextMenu(CWnd* pWnd, CPoint point)
{
TVINSERTSTRUCT tvInsert;
if ( pWnd != &m_tree )
{
CWnd::OnContextMenu(pWnd, point);
return;
}
UINT nFlags;
CPoint curPoint;
// Get the current position of the cursor
GetCursorPos(&curPoint);
m_tree.ScreenToClient(&curPoint);
HTREEITEM m_ItemSel;
// Check if the user clicked on any of the tree items
m_ItemSel = m_tree.HitTest(curPoint, &nFlags);
if (m_ItemSel != NULL)
m_tree.SelectItem( m_ItemSel);
if (m_ItemSel == NULL)
tvInsert.hParent = TVI_ROOT;
else
tvInsert.hParent = m_ItemSel;
tvInsert.hInsertAfter = TVI_FIRST;
tvInsert.item.mask = TVIF_TEXT;
m_tree.InsertItem(&tvInsert);
}

espero q t sirva

Preguntas similares