NM_TREEVIEW is in commctrl.h, hdr code etc are members of this structure.<br>
<br>
Learned from books of course! Inside Visual C++, is a good one. Also Using Visual C++ although it spends alot of time on the beginning stuff.<br>
<br>
MSDN CD's is a must also, but I'm sure you have them, I have the Sep 2000 ver on DVD, its fast! I understand that this only comes with MSDN subscription (not free), maybe you can find a friend who has it.<br>
<br>
You are welcome to send new messages! <br>
<br>
: I see, but it is a few things I don't realy<br>
: understand:<br>
: 1. LPNM_TREEVIEW<br>
: 2. hdr (where is it declared, or is it a standard thing?)<br>
: 3. code(where is it declared, or is it a standard thing?)<br>
: <br>
: where did you learned this stuff??<br>
: <br>
: with a book? the web?? pleas tell me!<br>
: <br>
: now I promise i wont send any more messages! :)<br>
: <br>
: <br>
: : I got it now!<br>
: : <br>
: : What you need to do is use WM_NOTIFY (Which of course is sent to the parent of the control ) and look for TVN_SELCHANGED.<br>
: : <br>
: : For example, say you have IDC_TREE1 on CMyDlg, you would do:<br>
: : <br>
: : BOOL CMyDlg::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) <br>
: : {<br>
: : LPNM_TREEVIEW p = (LPNM_TREEVIEW) lParam;<br>
: : if( wParam == IDC_TREE1 && p->hdr.code == TVN_SELCHANGED )<br>
: : {<br>
: : // p->itemNew.hItem holds the handle of the new item to be selected.<br>
: : <br>
: : // we want to show the text in a message box, so<br>
: : CHAR szBuffer[ 1024 ];<br>
: : <br>
: : TV_ITEM Item;<br>
: : ZeroMemory( &Item, sizeof( Item ) );<br>
: : Item.mask = TVIF_TEXT;<br>
: : Item.hItem = p->itemNew.hItem;<br>
: : Item.pszText = szBuffer;<br>
: : Item.cchTextMax = sizeof( szBuffer );<br>
: : m_MyTree.GetItem( &Item );<br>
: : AfxMessageBox( szBuffer );<br>
: : }<br>
: : <br>
: : return CDialog::OnNotify(wParam, lParam, pResult);<br>
: : }<br>
: : <br>
: : <br>
: : : KMS<br>
: : : <br>
: : : I don't know how to erite the code right!<br>
: : : If I click one time on TreCtrl and the choose NM_CLICK<br>
: : : in a pop domn menu, then I can edit the code for<br>
: : : clicking the TREE control, not the items.... how to do so it<br>
: : : knows it is an item thats was clicked.<br>
: : : <br>
: : : hope that will work..... :)<br>
: : : <br>
: : <br>
: : <br>
: : <br>
: <br>
: <br>
: <br>
<br>