The perfect realization of the VC tree control drag

Source: Internet
Author: User

tree controls are used to display data items with a certain level of structure is convenient, intuitive, widely used in various software, such as the disk directory in the resource manager with the tree control, we will often use in programming, but MFC provided in the CTreeCtrl class does not directly support the advanced features such as drag nodes, which makes us programmers have great limitations in programming, and also brings some inconvenience to software users. Let us solve this problem by ourselves and implement the drag of the nodes in the tree control.

We derive a class Cxtreectrl from the CTreeCtrl, which has the following characteristics:

⑴ the implementation of the basic drag.

⑵ handles unintentional drag.

⑶ can handle scrolling problems in the drag process.

The nodes are intelligently expanded during ⑷ drag.

Figure 1 is the running interface for the sample program.

(Figure 1)

OK, let's step through the above function.

Create a new dialog box project, edit the resource, add a tree control Idc_tree to the dialog box, and the property setting, as shown in Figure 2, adds a member variable m_wndtree to the control.

The type is changed to Cxtreectrl. Derives a class Cxtreectrl from the CTreeCtrl.

(Figure 2)

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.