The tree control of MFC

Source: Internet
Author: User

The class that corresponds to the tree control:

Ctreecontrol

To add a tree node:

1     Htreeitem Hrootnode = M_tvwtree.insertitem (_t (" person ")); 2     Htreeitem Hnode = M_tvwtree.insertitem (_t (" old man "), Hrootnode, tvi_last); 3     Htreeitem Hchildnode = M_tvwtree.insertitem (_t (" man "), Hnode, tvi_last);
View Code

Nm_click Message processing functions:

1 voidCtesttreecontroldlg::onnmclicktree1 (NMHDR *pnmhdr, LRESULT *PResult)2 {3 CPoint PT;4:: GetCursorPos (&PT);5:: ScreenToClient (Pnmhdr->hwndfrom, &PT);6 7 UINT uflags;8Htreeitem Hselecteditem = M_tvwtree.hittest (PT, &uflags);9     if(NULL = =Hselecteditem)Ten     { One         return; A     } -  -     if(Uflags &Tvht_onitem) the     { -CString str =M_tvwtree.getitemtext (hselecteditem); - AfxMessageBox (str); -     } +  -*presult =0; +}
View Code

Tvn_selchanged Message processing functions:

1 voidCtesttreecontroldlg::ontvnselchangedtree1 (NMHDR *pnmhdr, LRESULT *PResult)2 {3Lpnmtreeview Pnmtreeview = reinterpret_cast<lpnmtreeview>(PNMHDR);4 5Htreeitem Hselecteditem =M_tvwtree.getselecteditem ();6     if(NULL = =Hselecteditem)7     {8         return;9     }Ten  OneCString str =M_tvwtree.getitemtext (hselecteditem); A     if(str. IsEmpty ()) -     { -         return; the     } -  - AfxMessageBox (str); -  +*presult =0; -}
View Code

The tree control of MFC

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.