Type | Description | |||
Item as HITEM | A long expression that specifies the handle of the item being dragged. | |||
NewParent as HITEM | A long expression that specifies the handle of the newly parent, to insert the dragging Item. If 0, it indicates root items. The ItemParent property indicates the currently parent of the item. | |||
InsertA as HITEM | A long expression that specifies the handle of the item to insert the dragging Item after. If 0, it indicates that no item after. | |||
InsertB as HITEM | A long expression that specifies the handle of the item to insert the dragging Item before. If 0, it indicates that no item before. | |||
Cancel as Boolean | (By Reference) A Boolean expression that specifies whether the operation can continue ( this parameter is by reference ) |
You can use the AllowAutoDrag event to cancel or continue drag and drop operation using the AutoDrag property.
The following screen shot shows the NewParent, InsertA and InsertB parameters, when "Task 2" is dragging to a new position:
private void AllowAutoDrag(object sender,int Item,int NewParent,int InsertA,int InsertB,ref bool Cancel) { } Private Sub AllowAutoDrag(ByVal sender As System.Object,ByVal Item As Integer,ByVal NewParent As Integer,ByVal InsertA As Integer,ByVal InsertB As Integer,ByRef Cancel As Boolean) Handles AllowAutoDrag End Sub |
private void AllowAutoDrag(object sender, AxEXTREELib._ITreeEvents_AllowAutoDragEvent e) { } void OnAllowAutoDrag(long Item,long NewParent,long InsertA,long InsertB,BOOL FAR* Cancel) { } void __fastcall AllowAutoDrag(TObject *Sender,Extreelib_tlb::HITEM Item,Extreelib_tlb::HITEM NewParent,Extreelib_tlb::HITEM InsertA,Extreelib_tlb::HITEM InsertB,VARIANT_BOOL * Cancel) { } procedure AllowAutoDrag(ASender: TObject; Item : HITEM;NewParent : HITEM;InsertA : HITEM;InsertB : HITEM;var Cancel : WordBool); begin end; procedure AllowAutoDrag(sender: System.Object; e: AxEXTREELib._ITreeEvents_AllowAutoDragEvent); begin end; begin event AllowAutoDrag(long Item,long NewParent,long InsertA,long InsertB,boolean Cancel) end event AllowAutoDrag Private Sub AllowAutoDrag(ByVal sender As System.Object, ByVal e As AxEXTREELib._ITreeEvents_AllowAutoDragEvent) Handles AllowAutoDrag End Sub Private Sub AllowAutoDrag(ByVal Item As EXTREELibCtl.HITEM,ByVal NewParent As EXTREELibCtl.HITEM,ByVal InsertA As EXTREELibCtl.HITEM,ByVal InsertB As EXTREELibCtl.HITEM,Cancel As Boolean) End Sub Private Sub AllowAutoDrag(ByVal Item As Long,ByVal NewParent As Long,ByVal InsertA As Long,ByVal InsertB As Long,Cancel As Boolean) End Sub LPARAMETERS Item,NewParent,InsertA,InsertB,Cancel PROCEDURE OnAllowAutoDrag(oTree,Item,NewParent,InsertA,InsertB,Cancel) RETURN |
<SCRIPT EVENT="AllowAutoDrag(Item,NewParent,InsertA,InsertB,Cancel)" LANGUAGE="JScript"> </SCRIPT> <SCRIPT LANGUAGE="VBScript"> Function AllowAutoDrag(Item,NewParent,InsertA,InsertB,Cancel) End Function </SCRIPT> Procedure OnComAllowAutoDrag HITEM llItem HITEM llNewParent HITEM llInsertA HITEM llInsertB Boolean llCancel Forward Send OnComAllowAutoDrag llItem llNewParent llInsertA llInsertB llCancel End_Procedure METHOD OCX_AllowAutoDrag(Item,NewParent,InsertA,InsertB,Cancel) CLASS MainDialog RETURN NIL void onEvent_AllowAutoDrag(int _Item,int _NewParent,int _InsertA,int _InsertB,COMVariant /*bool*/ _Cancel) { } function AllowAutoDrag as v (Item as OLE::Exontrol.Tree.1::HITEM,NewParent as OLE::Exontrol.Tree.1::HITEM,InsertA as OLE::Exontrol.Tree.1::HITEM,InsertB as OLE::Exontrol.Tree.1::HITEM,Cancel as L) end function function nativeObject_AllowAutoDrag(Item,NewParent,InsertA,InsertB,Cancel) return |
The AllowDragDrop event triggers contiguously while the user drags / hovers
the focus/selection of items over the control. The GetAsyncKeyState API method
can be used to detect whether the mouse button has been released, and so the
drop action occurs.
The following VB sample displays "Drag" while user dragging the
items, and displays "Drop", when drop operation starts.
Private Sub Tree1_AllowAutoDrag(ByVal Item As EXTREELibCtl.HITEM, ByVal NewParent As EXTREELibCtl.HITEM, ByVal InsertA As EXTREELibCtl.HITEM, ByVal InsertB As EXTREELibCtl.HITEM, Cancel As Boolean) With Tree1 Debug.Print "Drag" If (GetAsyncKeyState(VK_LBUTTON) = 0) Then Debug.Print "Drop" End If End With End Sub
where declarations for GetAsyncKeyState API used is:
Private Const VK_LBUTTON = &H1 Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Once you run the code, you will notice that the AllowAutoDrag event "Drop" may be fired multiple times, so we suggest to postpone any of your actions ( like displaying a message box ), by posting a window message or use a timer event, to let the control handles / completes the event as in the following sample:
Private Sub Tree1_AllowAutoDrag(ByVal Item As EXTREELibCtl.HITEM, ByVal NewParent As EXTREELibCtl.HITEM, ByVal InsertA As EXTREELibCtl.HITEM, ByVal InsertB As EXTREELibCtl.HITEM, Cancel As Boolean) With Tree1 Debug.Print "Drag" If (GetAsyncKeyState(VK_LBUTTON) = 0) Then mctlTimerDrop.Enabled = True End If End With End Sub
where mctlTimerDrop is defined as follows:
Dim WithEvents mctlTimerDrop As VB.Timer Private Sub mctlTimerDrop_Timer() mctlTimerDrop.Enabled = False MsgBox "Drop." End Sub Private Sub Form_Load() Set mctlTimerDrop = Me.Controls.Add("VB.Timer", "DropTimer1") With mctlTimerDrop .Enabled = False .Interval = 100 End With End Sub