1.) You can use the MIAbort, MICopy, MIMove or MISCut property.
2.) Modify the method SetCaptionOfMenuItems for your language.It is really simple to modify, you will see. It is welcomed, if you mail me the modified version. But before you do that, check on MY HOMEPAGE, if the language is already supported. Please send me only that, you have add/modified, not the whole code - I already have it :).
If your language is not supported, the language is automatically set to English.
The component is designed for easy use. For more infomation to Drag&Drop consult the Delphi online-help. In the most cases (okay, delete the "on" at "onXXXXXX" etc) you will get help.
I have heard, that Borland C++ user even can use this unit. The automatic created headers may have some bugs. After you have solved this problem, you should use it without problems!
For DragNDrop(D2).zip users only:
This unit is written with Delphi2. Newer versions of Delphi may have problems to install this unit. Usually you have to search the unit "OLE2" on your Delphi CD and copy it in the same path, were this unit is located. Then, it should works!
AcceptOwnDnD published |
If your DragDropControl is able to be source AND target of d&d-operations you can determine here, if your DragDropControl should accept its own d&d-operation. This is important in example, if you want to change the order of Listbox items using this component and not the internal d&d-operations. |
AutoDetectDnD published |
If your DragDropControl is able to be source of d&d-operations you can define here, if this component should detect drag operations or not. DragDetectDelta is involved in the detection. If you are using a grid, check the "Known Bugs" section below. |
BringToFront published |
If you have drop something on the target control, you can determine here if the form should come to front after the d&d-operation or not. |
CHCopy public |
Use this property to set a custom cursor for the copy-effect during d&d. |
CHLink public |
Use this property to set a custom cursor for the link-effect during d&d. |
CHMove public |
Use this property to set a custom cursor for the move-effect during d&d. |
CHScrollCopy public |
Use this property to set a custom cursor for the copy-effect during d&d and scrolling in the target window. |
CHScrollLink public |
Use this property to set a custom cursor for the link-effect during d&d and scrolling in the target window. |
CHScrollMove public |
Use this property to set a custom cursor for the move-effect during d&d and scrolling in the target window. |
DragDetectDelta published |
Is the drag detection enabled by AutoDetectDnD or calling StartDnDDetection, the drag detection has succeed, if the mouse was moved over more than in this property defined pixels. |
DragDropControl published |
Choose here a component like Listbox etc. which were handled as source and target for d&d-operations. If you are using a grid, check the "Known Bugs" section below. |
Menu public |
This property gives you the instance of that popup-menu, which appears, if you drop datas with the RIGHT mousbutton on the DragDropControl (read-only!). |
MIAbort public |
The "abort" menu-item of the Menu (read-only!). |
MICopy public |
The "copy" menu-item of the Menu (read-only!). |
MIMove public |
The "move" menu-item of the Menu (read-only!). |
MISCut public |
The "shortcut" menu-item of the Menu (read-only!). |
Name published |
Name of the component |
OwnerIsSource public |
This property indicates during a d&d-operation, if the DragDropControl is the source of the d&d-operation or not (read-only!). |
Registered public |
You can determine here, if the DragDropControl is registered as Target of Drag&Drop operations or not. |
RenderOn public |
You can determine here, when the dropped data should be rendered (only important for the inherited classes). If it is set to rdoDropSync, the data is rendered before calling the event-handler OnDrop. If it is set to rdoDropAsync, the data is rendered before calling the event-handler OnProcessDropped. If it is set to rdoEnter, the data is rendered before calling the event-handler OnDragEnter. If it is set to rdoEnterAndDropSync, the data is rendered before calling the event-handler OnDragEnter AND before calling the event-handler OnDrop (yes two times - in some cases it's necessary). If it is set to rdoEnterAndDropAsync, the data is rendered before calling the event-handler OnDragEnter AND the data is rendered before calling the event-handler OnProcessDropped (yes two times - in some cases it's necessary). If it is set to rdoNever, the data is never rendered. Normally, you never need this value - it makes only sense for application-internal d&d (the app knows the data; why should we spend our precious time on rendering the known data?)
Be careful, if you set this property to rdoDropAsync, rdoDropEnterAndDropSync, rdoDropEnterAndDropAsync or rdoEnter, because the OLE2 Drag&Drop isn't correctly implemented in every program. On testing (high recommend!!!), you will be supprised, how many well-known progs makes trouble because of wrong implemention. |
ScrollDetectOptions published |
This property has many sub-properties: AreaBottom, AreaLeft, AreaRight, AreaTop have the sub-properties Margin, Range. You can determine with Margin where the scroll-detect-area begins, measured from the clientarea-border. You can determine with Range the width resp. height of the scroll-detect-area. The properties AreaBottom and AreaTop are used for the vertical scroll detection, AreaLeft and AreaRight for the horizontal detection. HorzScrolling and VertScrolling are further sub-properties under ScrollDetectOptions. You can enable/disable the scroll detection with these properties. HorzPageScroll and VertPageScroll are even further sub-properties under ScrollDetectOptions. You can switch here between line or page scrolling. ScrollDelay is even a sub-property under ScrollDetectOptions. You can determine with property the delay time to the next scroll event in the DragDropControl. StartDelay is even a further sub-property under ScrollDetectOptions. You can determine with property the delay time till the first scroll event is sent to the DragDropControl. |
SourceCompatibility published |
This property was added due to incompatible implemention of d&d in other apps. They set some value incorrectly in the FormatEtc record, because these values aren't used for the dragged format. With this property you can determine, if you don't to check these values for a successful d&d. If you disable a check, you take risk to drop data in a invalid format. Normally, you need not to switch this property. |
SourceEffects published |
Choose the effects which the DragDropControl should support. If you don't want that the DragDropControl serve as d&d source all items must be false. If you are using a grid, check the "Known Bugs" section below. |
TargetEffects published |
Choose the effects which the DragDropControl should support. If you don't want that the DragDropControl serve as d&d target, all items must be false. |
TargetPopUpMenu published |
Here you determine, should the PopUpMenu get visible if a d&d-operations occurs with the right mouse button or not. (Only for target control!!!) |
OnBeforeScrolling published |
This event is called before a scroll-event is sent to the DragDropControl. The scroll-detection must be enabled for this event. |
OnAfterScrolling published |
This event is called after a scroll-event is sent to the DragDropControl. The scroll-detection must be enabled for this event. |
OnDragDetect published |
Is called on starting (parameter DragStatus=ddsLeft or ddsRight,
depends which mousebutton is pressed), on dragging (DragStatus=ddsDrag), on finishing detection (DragStatus=ddsNone)
and cancelling the detection (DragStatus=ddsCancelled). If DragStatus=ddsDrag,
the d&d operation won't be started automatically. If you want to start d&d, you must call Execute on yourself. The parameters DetectStartX and
DetectStartY specify the cursor position, when the detection has started. The parameters x and y specify the current position of the cursor. If you are using a grid, check the "Known Bugs" section below. |
OnDragEnter published |
Is called, when the DragDropControl is a target of d&d-operations. The d&d-mouse cursor moves ON (one call only) the DragDropControl. Here, you influence if a drop can be accepted and the drop's effect if accepted. |
OnDragLeave published |
Is called, when the DragDropControl is a target of d&d-operations. The d&d-mouse cursor leaves the DragDropControl (one call only) or the d&d-operation is cancelled. |
OnDragOver published |
Is called, when the DragDropControl is a target of d&d-operations. The mouse cursor moves OVER (called on every mouse move) the DragDropControl. Even here may you influence if a drop can be accepted and the drop's effect if accepted. Because this function is very often called YOUR function should be very efficient programmed. |
OnDrop published |
Is called, when the DragDropControl is a target of d&d-operations. Instructs DragDropControl to handle the datas which are dropped on it. Save here only the dropped data (, if this isn't done by the child-class), because the source of the d&d-operation isn't accessable until this event-method was left. For processing use OnProcessDropped. |
OnGiveFeedback published |
Is called, when the DragDropControl is a source of d&d-operations. Enables a source application to give visual feedback to its end user during a drag-and-drop operation by providing the OLE DoDragDrop function with an enumeration value specifying the visual effect. Mostly you don't need this event. |
OnProcessDropped published |
Is called after OnDrop by "PostMessage". This has the effect, that the user can access to the source of the d&d-operation during you process the dropped data. Of course, you have to save the dropped data in OnDrop. In my child-classes you haven't care about this. |
OnQueryContinueDrag published |
Is called, when the DragDropControl is a source of d&d-operations. Determines whether a drag-and-drop operation should be continued, cancelled, or completed. You do not call this method directly. The OLE DoDragDrop function calls this method during a drag-and-drop operation. Mostly you don't need this event. |
CopyToClipboard public |
Call this method, if you want to copy your data to the clipboard. |
Execute public |
Call this method, if you detect that the user wants to start a d&d-operation (i.e.: MouseDown). Before calling, you have to create a valid IDataObject (for more infos, look over the source of the components "TDragDropFiles" or "TDragDropFiles"). If you are using a grid, check the "Known Bugs" section below. |
GetFromClipboard public |
Call this method, if you want to get data from the clipboard. This will only succeed, if the data formats are supported. |
StartDnDDetection public |
Call this method, if you want to start the drag detection manually. Normally, you call this method in the OnMouseDown-event. |
Constants
DropEffect_None, DropEffect_Copy, DropEffect_Move, DropEffect_Link, DropEffect_Scroll |
Describe the kind of drop effect the user want to have. These values are used by the parameter dwEffect of methodes. |
TDataObject
TDropTarget
I think, the methods names explain their purpose. But for more info, take a look over the code of my child-classes.
A: You've to write your own child-class from TDragDrop. But can copy the most of my child-classes together, for faster developing vour class.
You can't access the dropped data directly. For this you have the class TDataObject (look at params of methods ...). To every data(-set) in your dataobj you have format description. You can enumerate the available formats with EnumFormatEtc. With "QueryGetData" you can check, if a special format is available. The data itself you can get with "GetData". Because of my components design you should better use my new introduced method "RenderData".
I hope, it helps a little bit. Don't be disappointed, if you don't understand d&d immediately. I've even needed some month to understand the mechanisms completely. Dieter
© 1998 by Dieter Steinwedel