Implementation of drag-and-drop in C + + Builder

Source: Internet
Author: User

Drag-and-drop in Windows Everyone must be familiar with, such as file transfer, copy, and other operations with the mouse gently drag, in the writing program is sometimes used to drag and drop, then how to achieve it? This paper takes C + + BUILDER5 (CB5) as an example to analyze the concrete implementation of the drag-and-drop function.

A Drag and drop of the tool bar

----to implement drag-and-drop functionality, you must first understand several drag-and-drop properties and methods, and for the Tcontrol control, CB5 provides three properties, Docksite,dragkind, and DragMode. The flexibility to use these three properties will result in unexpected results. The meaning of these three attributes is:

----Docksite: Specifies whether the current control accepts drag-and-dock types of operations

----Dragkind: Drag and drop species, divided into Dkdrag and dkdock two species

----DragMode: Drag-and-drop mode, divided into two types of automatic and manual mode

----Where the dock operation refers to a control that is detached from its parent and becomes the child of another control, that is, two control merges. A control whose docksite is true indicates that it accepts a control that performs the dock operation and becomes its parent.

----The famous Office toolbar can be dragged and dropped at will, in fact it is simple: put a CoolBar control on the form, and then put a few toolbar controls on the CoolBar control, their property setting code is as follows:

Coolbar1.docksite=true;

Toolbar1.dragkind=dkdock;

Toolbar1.dragmode= dmautomatic;

----Other Toolbar property settings are the same as the ToolBar1 property settings, compile and run the program, drag the tool bar to try, cool pole.

Ii. drag-and-drop between any two controls

----Several functions related to this operation are:

----BeginDrag: Start a drag-and-drop operation, if the control's DragMode is dmmanual, you must call this function, and if DragMode is dmautomatic, do not call.

----OnDragOver: This event is triggered when a dragged object passes through this control, where the parameter accept indicates whether the object being dragged and dropped is accepted.

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.