From: Leandro Delamare on
Hello Friends

I add some values to my treeview, but now I want to write the selected value
in a EDIT BOX, how can I do this ?

is in the item bellow correct ? but what the command to get the value of
selected item ?

Regards
Leandro
void CTeste1Dlg::OnTvnItemexpandedTree1(NMHDR *pNMHDR, LRESULT *pResult)

{

LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);

// TODO: Add your control notification handler code here

*pResult = 0;

CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE1);

ASSERT(pCtrl != NULL);


SetDlgItemText(IDC_EDIT1,??);

}


From: AliR on
Look in the help!
I would say that you should catch the TVN_SELCHANGED message, this notify
message will get sent to you when an item is selected.
something like this

void CMyDlg::OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
// TODO: Add your control notification handler code here
CString Temp = m_Tree.GetItemText(pNMTreeView->itemNew.hItem);
*pResult = 0;
}

you can also call GetSelectedItem at any point to get the tree's selected
item

HTREEITEM hItem = m_Tree.GetSelectedItem();
if (hItem != NULL)
{
Temp = m_Tree.GetItemText(hItem);
}

AliR.


"Leandro Delamare" <lhdelamare(a)uol.com.br> wrote in message
news:Oy8WfRFFFHA.2176(a)TK2MSFTNGP15.phx.gbl...
> Hello Friends
>
> I add some values to my treeview, but now I want to write the selected
value
> in a EDIT BOX, how can I do this ?
>
> is in the item bellow correct ? but what the command to get the value of
> selected item ?
>
> Regards
> Leandro
> void CTeste1Dlg::OnTvnItemexpandedTree1(NMHDR *pNMHDR, LRESULT *pResult)
>
> {
>
> LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
>
> // TODO: Add your control notification handler code here
>
> *pResult = 0;
>
> CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE1);
>
> ASSERT(pCtrl != NULL);
>
>
> SetDlgItemText(IDC_EDIT1,??);
>
> }
>
>


From: Ajay Kalra on
You can use GetSelectedItem() to get the item that is currently
selected in your treeview.

---------
Ajay Kalra
ajaykalra(a)yahoo.com

From: Leandro Delamare on
Ok, Works fine..
Thank you

Regards
"AliR" <AliR(a)newsgroup.nospam> wrote in message
news:5pMQd.10619$D34.1261(a)newssvr12.news.prodigy.com...
> Look in the help!
> I would say that you should catch the TVN_SELCHANGED message, this notify
> message will get sent to you when an item is selected.
> something like this
>
> void CMyDlg::OnTvnSelchangedTree1(NMHDR *pNMHDR, LRESULT *pResult)
> {
> LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
> // TODO: Add your control notification handler code here
> CString Temp = m_Tree.GetItemText(pNMTreeView->itemNew.hItem);
> *pResult = 0;
> }
>
> you can also call GetSelectedItem at any point to get the tree's selected
> item
>
> HTREEITEM hItem = m_Tree.GetSelectedItem();
> if (hItem != NULL)
> {
> Temp = m_Tree.GetItemText(hItem);
> }
>
> AliR.
>
>
> "Leandro Delamare" <lhdelamare(a)uol.com.br> wrote in message
> news:Oy8WfRFFFHA.2176(a)TK2MSFTNGP15.phx.gbl...
> > Hello Friends
> >
> > I add some values to my treeview, but now I want to write the selected
> value
> > in a EDIT BOX, how can I do this ?
> >
> > is in the item bellow correct ? but what the command to get the value of
> > selected item ?
> >
> > Regards
> > Leandro
> > void CTeste1Dlg::OnTvnItemexpandedTree1(NMHDR *pNMHDR, LRESULT *pResult)
> >
> > {
> >
> > LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
> >
> > // TODO: Add your control notification handler code here
> >
> > *pResult = 0;
> >
> > CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE1);
> >
> > ASSERT(pCtrl != NULL);
> >
> >
> > SetDlgItemText(IDC_EDIT1,??);
> >
> > }
> >
> >
>
>


From: Joseph M. Newcomer on
Lose the GetDlgItem. I don't know why everyone in sight uses GetDlgItem, but this is the
third time today I've had to point this out. Create a control member variable for each
control. See my essay on avoiding GetDlgItem.

Also, it is a very good idea to change those stupid names assigned by the dialog editor to
something that make sense. IDC_EDIT1 is useless. Give it a real name. Then create a
control variable with a meaningful name.,

I've used c_MyTree and c_MyEdit although sensible names should be used to indicate what
these mean.

HTREEITEM item = c_MyTree.GetSelectedItem();
if(item == NULL)
return; // we should never gotten here...

CString text = c_MyTree.GetItemText(item);
c_MyEdit.SetWindowText(text);

joe

On Wed, 16 Feb 2005 16:21:37 -0300, "Leandro Delamare" <lhdelamare(a)uol.com.br> wrote:

>Hello Friends
>
>I add some values to my treeview, but now I want to write the selected value
>in a EDIT BOX, how can I do this ?
>
>is in the item bellow correct ? but what the command to get the value of
>selected item ?
>
>Regards
>Leandro
>void CTeste1Dlg::OnTvnItemexpandedTree1(NMHDR *pNMHDR, LRESULT *pResult)
>
>{
>
>LPNMTREEVIEW pNMTreeView = reinterpret_cast<LPNMTREEVIEW>(pNMHDR);
>
>// TODO: Add your control notification handler code here
>
>*pResult = 0;
>
>CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE1);
>
>ASSERT(pCtrl != NULL);
>
>
>SetDlgItemText(IDC_EDIT1,??);
>
>}
>

Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm