Type | Description | |||
Data as ExDataObject | An ExDataObject object containing formats that the source will provide and, in addition, possibly the data for those formats. If no data is contained in the ExDataObject, it is provided when the control calls the GetData method. The SetData and Clear methods cannot be used here. | |||
Effect as Long | A Long set by the target component identifying the action that has been performed (if any), thus allowing the source to take appropriate action if the component was moved (such as the source deleting the data). The possible values are listed in bellow. | |||
Button as Integer | An integer which acts as a bit field corresponding to the state of a mouse button when it is depressed. The left button is bit 0, the right button is bit 1, and the middle button is bit 2. These bits correspond to the values 1, 2, and 4, respectively. It indicates the state of the mouse buttons; some, all, or none of these three bits can be set, indicating that some, all, or none of the buttons are depressed. | |||
Shift as Integer | An integer which acts as a bit field corresponding to the state of the SHIFT, CTRL, and ALT keys when they are depressed. The SHIFT key is bit 0, the CTRL key is bit 1, and the ALT key is bit 2. These bits correspond to the values 1, 2, and 4, respectively. The shift parameter indicates the state of these keys; some, all, or none of the bits can be set, indicating that some, all, or none of the keys are depressed. For example, if both the CTRL and ALT keys were depressed, the value of shift would be 6. | |||
X as OLE_XPOS_PIXELS | A single that specifies the current X location of the mouse pointer. The X value is always expressed in container coordinates. | |||
Y as OLE_YPOS_PIXELS | A single that specifies the current Y location of the mouse pointer. The Y value is always expressed in container coordinates. |
Use the OLEDragDrop event to notify your application that user drags some data to the control. Use the Add method to insert new nodes to the control. Use the NodeFromPoint property to retrieve the node from the cursor. If the OLEDropMode property to exOLEDropManual and you need to drag data from the eXMLGrid control you need to handle the OLEStartDrag event. Use the Selected property to select a node. Use the EnsureVisibleNode method to ensure that a node fits the control's client area.
Syntax for OLEDragOver event, /NET version, on:
// OLEDragOver event is not supported. Use the DragEnter,DragLeave,DragOver, DragDrop ... events. // OLEDragOver event is not supported. Use the DragEnter,DragLeave,DragOver, DragDrop ... events. |
private void OLEDragOver(object sender, AxEXMLGRIDLib._IXMLGridEvents_OLEDragOverEvent e) { } void OnOLEDragOver(LPDISPATCH Data,long FAR* Effect,short Button,short Shift,long X,long Y,short State) { } void __fastcall OLEDragOver(TObject *Sender,Exmlgridlib_tlb::IExDataObject *Data,long * Effect,short Button,short Shift,int X,int Y,short State) { } procedure OLEDragOver(ASender: TObject; Data : IExDataObject;var Effect : Integer;Button : Smallint;Shift : Smallint;X : Integer;Y : Integer;State : Smallint); begin end; procedure OLEDragOver(sender: System.Object; e: AxEXMLGRIDLib._IXMLGridEvents_OLEDragOverEvent); begin end; begin event OLEDragOver(oleobject Data,long Effect,integer Button,integer Shift,long X,long Y,integer State) end event OLEDragOver Private Sub OLEDragOver(ByVal sender As System.Object, ByVal e As AxEXMLGRIDLib._IXMLGridEvents_OLEDragOverEvent) Handles OLEDragOver End Sub Private Sub OLEDragOver(ByVal Data As EXMLGRIDLibCtl.IExDataObject,Effect As Long,ByVal Button As Integer,ByVal Shift As Integer,ByVal X As Single,ByVal Y As Single,ByVal State As Integer) End Sub Private Sub OLEDragOver(ByVal Data As Object,Effect As Long,ByVal Button As Integer,ByVal Shift As Integer,ByVal X As Long,ByVal Y As Long,ByVal State As Integer) End Sub LPARAMETERS Data,Effect,Button,Shift,X,Y,State PROCEDURE OnOLEDragOver(oXMLGrid,Data,Effect,Button,Shift,X,Y,State) RETURN |
<SCRIPT EVENT="OLEDragOver(Data,Effect,Button,Shift,X,Y,State)" LANGUAGE="JScript"> </SCRIPT> <SCRIPT LANGUAGE="VBScript"> Function OLEDragOver(Data,Effect,Button,Shift,X,Y,State) End Function </SCRIPT> Procedure OnComOLEDragOver Variant llData Integer llEffect Short llButton Short llShift OLE_XPOS_PIXELS llX OLE_YPOS_PIXELS llY Short llState Forward Send OnComOLEDragOver llData llEffect llButton llShift llX llY llState End_Procedure METHOD OCX_OLEDragOver(Data,Effect,Button,Shift,X,Y,State) CLASS MainDialog RETURN NIL // OLEDragOver event is not supported. Use the DragEnter,DragLeave,DragOver, DragDrop ... events. function OLEDragOver as v (Data as OLE::Exontrol.XMLGrid.1::IExDataObject,Effect as N,Button as N,Shift as N,X as OLE::Exontrol.XMLGrid.1::OLE_XPOS_PIXELS,Y as OLE::Exontrol.XMLGrid.1::OLE_YPOS_PIXELS,State as N) end function function nativeObject_OLEDragOver(Data,Effect,Button,Shift,X,Y,State) return |
The following VB sample adds a new node when user drags data to the control:
Private Sub XMLGrid1_OLEDragDrop(ByVal Data As EXMLGRIDLibCtl.IExDataObject, Effect As Long, ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single) With XMLGrid1 Dim n As EXMLGRIDLibCtl.Node, nds As EXMLGRIDLibCtl.nodes Set nds = .nodes Set n = .NodeFromPoint(X / Screen.TwipsPerPixelX, Y / Screen.TwipsPerPixelY) If Not n Is Nothing Then Set nds = n.nodes End If With nds Dim strData As String strData = Data.GetData(exCFText) .Add(strData).Selected = True End With If Not n Is Nothing Then n.Expanded = True End If End With End Sub
The following C++ sample adds a new node when user drags data to the control:
#include "Node.h" #import <exmlgrid.dll> void OnOLEDragDropXmlgrid1(LPDISPATCH Data, long FAR* Effect, short Button, short Shift, long X, long Y) { COleVariant vtMissing; V_VT( &vtMissing ) = VT_ERROR; if ( EXMLGRIDLib::IExDataObjectPtr spData = Data ) { CString strData = V2S( &spData->GetData( EXMLGRIDLib::exCFText ) ); CNodes nodes = m_xmlgrid.GetNodes(); CNode node = m_xmlgrid.GetNodeFromPoint( X, Y ); if ( node.m_lpDispatch != NULL ) nodes = node.GetNodes(); nodes.Add( strData, vtMissing, vtMissing ).SetSelected( TRUE ); if ( node.m_lpDispatch != NULL ) node.SetExpanded( TRUE ); } }
The #import <exmlgrid.dll> is called to import definitions for ExDataObject and ExDataObjectFiles objects. The #import <exmlgrid.dll> creates the EXMLGRIDLib namespace where all objects and types that eXMLGrid exports. If you need to drag data from eXMLGrid control to a window you need to use RegisterDragDrop API function. The RegisterDragDrop API function registers the specified window as one that can be the target of an OLE drag-and-drop operation and specifies the IDropTarget instance to use for drop operations. Shortly, you need an object that implements the IDropTarget interface, and to call the RegisterDragDrop API function.
The V2S function converts a VARIANT expression to a string expression:
static CString V2S( const VARIANT* pvtValue ) { COleVariant vtString; vtString.ChangeType( VT_BSTR, (VARIANT*)pvtValue ); return V_BSTR( &vtString ); }
The following VB.NET sample adds a new node when user drags data to the control:
Private Sub AxXMLGrid1_OLEDragDrop(ByVal sender As Object, ByVal e As AxEXMLGRIDLib._IXMLGridEvents_OLEDragDropEvent) Handles AxXMLGrid1.OLEDragDrop With AxXMLGrid1 Dim n As EXMLGRIDLib.Node = .get_NodeFromPoint(e.x, e.y), nds As EXMLGRIDLib.Nodes = .Nodes If Not n Is Nothing Then nds = n.Nodes End If With nds Dim strData As String = e.data.GetData(EXMLGRIDLib.exClipboardFormatEnum.exCFText) .Add(strData).Selected = True End With If Not n Is Nothing Then n.Expanded = True End If End With End Sub
The following C# sample adds a new node when user drags data to the control:
private void axXMLGrid1_OLEDragDrop(object sender, AxEXMLGRIDLib._IXMLGridEvents_OLEDragDropEvent e) { EXMLGRIDLib.Nodes nodes = axXMLGrid1.Nodes; EXMLGRIDLib.Node n = axXMLGrid1.get_NodeFromPoint(e.x, e.y); if (n != null) nodes = n.Nodes; nodes.Add(e.data.GetData(Convert.ToInt16(EXMLGRIDLib.exClipboardFormatEnum.exCFText)).ToString(), null, null).Selected = true; if (n != null) n.Expanded = true; }
The following VFP sample adds a new node when user drags data to the control:
*** ActiveX Control Event *** LPARAMETERS data, effect, button, shift, x, y With thisform.XMLGrid1 nds = .Nodes n = .NodeFromPoint(x , y) If !isnull(n) Then nds = n.Nodes EndIf With nds .Add(Data.GetData(1)).Selected = .t. && exCFText EndWith If !isnull(n) Then n.Expanded = .t. EndIf EndWith