changeset 136:04e357b8343d

DragSource
author Frank Benoit <benoit@tionex.de>
date Wed, 13 Feb 2008 14:24:54 +0100
parents 242e33c0e383
children 3665cb9211b2
files dwt/dnd/DragSource.d dwt/dnd/DropTarget.d dwt/dnd/TableDragSourceEffect.d dwt/dnd/Transfer.d dwt/dnd/TreeDragSourceEffect.d dwt/internal/win32/OS.d dwt/internal/win32/WINAPI.d
diffstat 7 files changed, 212 insertions(+), 147 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/dnd/DragSource.d	Wed Feb 13 04:51:22 2008 +0100
+++ b/dwt/dnd/DragSource.d	Wed Feb 13 14:24:54 2008 +0100
@@ -20,6 +20,10 @@
 import dwt.graphics.Point;
 import dwt.internal.ImageList;
 import dwt.internal.ole.win32.COM;
+import dwt.internal.ole.win32.OLEIDL;
+import dwt.internal.ole.win32.OBJIDL;
+import dwt.internal.ole.win32.ifs;
+import dwt.internal.ole.win32.extras;
 import dwt.internal.win32.OS;
 import dwt.widgets.Composite;
 import dwt.widgets.Control;
@@ -30,6 +34,19 @@
 import dwt.widgets.Tree;
 import dwt.widgets.Widget;
 
+import dwt.dnd.DragSourceEffect;
+import dwt.dnd.DragSourceListener;
+import dwt.dnd.Transfer;
+import dwt.dnd.TransferData;
+import dwt.dnd.DND;
+import dwt.dnd.DNDListener;
+import dwt.dnd.DNDEvent;
+import dwt.dnd.TreeDragSourceEffect;
+import dwt.dnd.TableDragSourceEffect;
+import dwt.dnd.OleEnumFORMATETC;
+
+import dwt.dwthelper.utils;
+
 /**
  *
  * <code>DragSource</code> defines the source object for a drag and drop transfer.
@@ -111,22 +128,24 @@
     // info for registering as a drag source
     Control control;
     Listener controlListener;
-    Transfer[] transferAgents = new Transfer[0];
+    Transfer[] transferAgents;
     DragSourceEffect dragEffect;
     Composite topControl;
 
     // ole interfaces
-    COMObject iDropSource;
-    COMObject iDataObject;
+    _IDropSourceImpl iDropSource;
+    _IDataObjectImpl iDataObject;
     int refCount;
 
     //workaround - track the operation performed by the drop target for DragEnd event
     int dataEffect = DND.DROP_NONE;
 
-    static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$
-    static final String DRAGSOURCEID = "DragSource"; //$NON-NLS-1$
-    static final int CFSTR_PERFORMEDDROPEFFECT  = Transfer.registerType("Performed DropEffect");     //$NON-NLS-1$
-
+    static const char[] DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$
+    static const char[] DRAGSOURCEID = "DragSource"; //$NON-NLS-1$
+    static const int CFSTR_PERFORMEDDROPEFFECT;
+    static this(){
+        CFSTR_PERFORMEDDROPEFFECT  = Transfer.registerType("Performed DropEffect");     //$NON-NLS-1$
+    }
 /**
  * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
  * Creating an instance of a DragSource may cause system resources to be allocated depending on the platform.
@@ -166,16 +185,16 @@
     createCOMInterfaces();
     this.AddRef();
 
-    controlListener = new Listener() {
+    controlListener = new class() Listener {
         public void handleEvent(Event event) {
             if (event.type is DWT.Dispose) {
-                if (!DragSource.this.isDisposed()) {
-                    DragSource.this.dispose();
+                if (!this.outer.isDisposed()) {
+                    this.outer.dispose();
                 }
             }
             if (event.type is DWT.DragDetect) {
-                if (!DragSource.this.isDisposed()) {
-                    DragSource.this.drag(event);
+                if (!this.outer.isDisposed()) {
+                    this.outer.drag(event);
                 }
             }
         }
@@ -183,19 +202,19 @@
     control.addListener(DWT.Dispose, controlListener);
     control.addListener(DWT.DragDetect, controlListener);
 
-    this.addListener(DWT.Dispose, new Listener() {
+    this.addListener(DWT.Dispose, new class() Listener {
         public void handleEvent(Event e) {
-            DragSource.this.onDispose();
+            this.outer.onDispose();
         }
     });
 
     Object effect = control.getData(DEFAULT_DRAG_SOURCE_EFFECT);
-    if (effect instanceof DragSourceEffect) {
-        dragEffect = (DragSourceEffect) effect;
-    } else if (control instanceof Tree) {
-        dragEffect = new TreeDragSourceEffect((Tree) control);
-    } else if (control instanceof Table) {
-        dragEffect = new TableDragSourceEffect((Table) control);
+    if ( auto dse = cast(DragSourceEffect)effect ) {
+        dragEffect = dse;
+    } else if ( auto tree = cast(Tree)control ) {
+        dragEffect = new TreeDragSourceEffect(tree);
+    } else if ( auto table = cast(Table)control ) {
+        dragEffect = new TableDragSourceEffect(table);
     }
 }
 
@@ -249,45 +268,20 @@
 
 private void createCOMInterfaces() {
     // register each of the interfaces that this object implements
-    iDropSource = new COMObject(new int[]{2, 0, 0, 2, 1}){
-        public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
-        public int method1(int[] args) {return AddRef();}
-        public int method2(int[] args) {return Release();}
-        public int method3(int[] args) {return QueryContinueDrag(args[0], args[1]);}
-        public int method4(int[] args) {return GiveFeedback(args[0]);}
-    };
-
-    iDataObject = new COMObject(new int[]{2, 0, 0, 2, 2, 1, 2, 3, 2, 4, 1, 1}){
-        public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
-        public int method1(int[] args) {return AddRef();}
-        public int method2(int[] args) {return Release();}
-        public int method3(int[] args) {return GetData(args[0], args[1]);}
-        // method4 GetDataHere - not implemented
-        public int method5(int[] args) {return QueryGetData(args[0]);}
-        // method6 GetCanonicalFormatEtc - not implemented
-        public int method7(int[] args) {return SetData(args[0], args[1], args[2]);}
-        public int method8(int[] args) {return EnumFormatEtc(args[0], args[1]);}
-        // method9 DAdvise - not implemented
-        // method10 DUnadvise - not implemented
-        // method11 EnumDAdvise - not implemented
-    };
+    iDropSource = new _IDropSourceImpl(this);
+    iDataObject = new _IDataObjectImpl(this);
 }
 
 protected void checkSubclass() {
-    String name = getClass().getName();
-    String validName = DragSource.class.getName();
-    if (!validName.equals(name)) {
+    char[] name = this.classinfo.name;
+    char[] validName = DragSource.classinfo.name;
+    if (validName!=/*eq*/name) {
         DND.error(DWT.ERROR_INVALID_SUBCLASS);
     }
 }
 
 private void disposeCOMInterfaces() {
-    if (iDropSource !is null)
-        iDropSource.dispose();
     iDropSource = null;
-
-    if (iDataObject !is null)
-        iDataObject.dispose();
     iDataObject = null;
 }
 
@@ -301,12 +295,12 @@
     notifyListeners(DND.DragStart,event);
     if (!event.doit || transferAgents is null || transferAgents.length is 0 ) return;
 
-    int[] pdwEffect = new int[1];
+    uint[1] pdwEffect;
     int operations = opToOs(getStyle());
     Display display = control.getDisplay();
-    String key = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$
+    char[] key = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$
     Object oldValue = display.getData(key);
-    display.setData(key, new bool(true));
+    display.setData(key, new ValueWrapperBool(true));
     ImageList imagelist = null;
     Image image = event.image;
     if (image !is null) {
@@ -327,11 +321,11 @@
             OS.UpdateWindow (topControl.handle);
         } else {
             int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
-            OS.RedrawWindow (topControl.handle, null, 0, flags);
+            OS.RedrawWindow (topControl.handle, null, null, flags);
         }
         OS.ImageList_DragEnter(topControl.handle, dragEvent.x - location.x, dragEvent.y - location.y);
     }
-    int result = COM.DoDragDrop(iDataObject.getAddress(), iDropSource.getAddress(), operations, pdwEffect);
+    int result = COM.DoDragDrop(iDataObject, iDropSource, operations, pdwEffect.ptr);
     if (imagelist !is null) {
         OS.ImageList_DragLeave(topControl.handle);
         OS.ImageList_EndDrag();
@@ -360,7 +354,7 @@
  * Ownership of ppenumFormatetc transfers from callee to caller so reference count on ppenumFormatetc
  * must be incremented before returning.  Caller is responsible for releasing ppenumFormatetc.
  */
-private int EnumFormatEtc(int dwDirection, int ppenumFormatetc) {
+private int EnumFormatEtc(int dwDirection, IEnumFORMATETC* ppenumFormatetc) {
     // only allow getting of data - SetData is not currently supported
     if (dwDirection is COM.DATADIR_SET) return COM.E_NOTIMPL;
 
@@ -380,13 +374,13 @@
     OleEnumFORMATETC enumFORMATETC = new OleEnumFORMATETC();
     enumFORMATETC.AddRef();
 
-    FORMATETC[] formats = new FORMATETC[allowedDataTypes.length];
+    FORMATETC*[] formats = new FORMATETC*[allowedDataTypes.length];
     for (int i = 0; i < formats.length; i++){
         formats[i] = allowedDataTypes[i].formatetc;
     }
     enumFORMATETC.setFormats(formats);
 
-    OS.MoveMemory(ppenumFormatetc, new int[] {enumFORMATETC.getAddress()}, 4);
+    *ppenumFormatetc = enumFORMATETC.getAddress();
     return COM.S_OK;
 }
 /**
@@ -399,13 +393,13 @@
     return control;
 }
 
-private int GetData(int pFormatetc, int pmedium) {
+.LRESULT GetData(FORMATETC *pFormatetc, STGMEDIUM *pmedium) {
     /* Called by a data consumer to obtain data from a source data object.
        The GetData method renders the data described in the specified FORMATETC
        structure and transfers it through the specified STGMEDIUM structure.
        The caller then assumes responsibility for releasing the STGMEDIUM structure.
     */
-    if (pFormatetc is 0 || pmedium is 0) return COM.E_INVALIDARG;
+    if (pFormatetc is null || pmedium is null) return COM.E_INVALIDARG;
 
     if (QueryGetData(pFormatetc) !is COM.S_OK) return COM.DV_E_FORMATETC;
 
@@ -460,11 +454,11 @@
     return transferAgents;
 }
 
-private int GiveFeedback(int dwEffect) {
+package .LRESULT GiveFeedback(DWORD dwEffect) {
     return COM.DRAGDROP_S_USEDEFAULTCURSORS;
 }
 
-private int QueryContinueDrag(int fEscapePressed, int grfKeyState) {
+package .LRESULT QueryContinueDrag(int fEscapePressed, DWORD grfKeyState) {
     if (fEscapePressed !is 0){
         if (topControl !is null) OS.ImageList_DragLeave(topControl.handle);
         return COM.DRAGDROP_S_CANCEL;
@@ -532,7 +526,7 @@
     return operation;
 }
 
-private int QueryGetData(int pFormatetc) {
+private .LRESULT QueryGetData(FORMATETC* pFormatetc) {
     if (transferAgents is null) return COM.E_FAIL;
     TransferData transferData = new TransferData();
     transferData.formatetc = new FORMATETC();
@@ -553,29 +547,27 @@
  * Ownership of ppvObject transfers from callee to caller so reference count on ppvObject
  * must be incremented before returning.  Caller is responsible for releasing ppvObject.
  */
-private int QueryInterface(int riid, int ppvObject) {
-    if (riid is 0 || ppvObject is 0)
+private HRESULT QueryInterface(REFIID riid, void** ppvObject) {
+    if (riid is null || ppvObject is null)
         return COM.E_INVALIDARG;
-    GUID guid = new GUID();
-    COM.MoveMemory(guid, riid, GUID.sizeof);
 
-    if (COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIDropSource)) {
-        OS.MoveMemory(ppvObject, new int[] {iDropSource.getAddress()}, 4);
+    if (COM.IsEqualGUID(riid, &COM.IIDIUnknown) || COM.IsEqualGUID(riid, &COM.IIDIDropSource)) {
+        *ppvObject = cast(void*)cast(IUnknown) iDropSource;
         AddRef();
         return COM.S_OK;
     }
 
-    if (COM.IsEqualGUID(guid, COM.IIDIDataObject) ) {
-        OS.MoveMemory(ppvObject, new int[] {iDataObject.getAddress()}, 4);
+    if (COM.IsEqualGUID(riid, &COM.IIDIDataObject) ) {
+        *ppvObject = cast(void*)cast(IDataObject) iDataObject;
         AddRef();
         return COM.S_OK;
     }
 
-    OS.MoveMemory(ppvObject, new int[] {0}, 4);
+    *ppvObject = null;
     return COM.E_NOINTERFACE;
 }
 
-private int Release() {
+private ULONG Release() {
     refCount--;
     if (refCount is 0) {
         disposeCOMInterfaces();
@@ -608,17 +600,17 @@
     removeListener(DND.DragEnd, listener);
 }
 
-private int SetData(int pFormatetc, int pmedium, int fRelease) {
-    if (pFormatetc is 0 || pmedium is 0) return COM.E_INVALIDARG;
-    FORMATETC formatetc = new FORMATETC();
+.LRESULT SetData(FORMATETC* pFormatetc, STGMEDIUM* pmedium, int fRelease) {
+    if (pFormatetc is null || pmedium is null) return COM.E_INVALIDARG;
+    FORMATETC* formatetc = new FORMATETC();
     COM.MoveMemory(formatetc, pFormatetc, FORMATETC.sizeof);
     if (formatetc.cfFormat is CFSTR_PERFORMEDDROPEFFECT && formatetc.tymed is COM.TYMED_HGLOBAL) {
-        STGMEDIUM stgmedium = new STGMEDIUM();
+        STGMEDIUM* stgmedium = new STGMEDIUM();
         COM.MoveMemory(stgmedium, pmedium,STGMEDIUM.sizeof);
-        int[] ptrEffect = new int[1];
-        OS.MoveMemory(ptrEffect, stgmedium.unionField,4);
-        int[] effect = new int[1];
-        OS.MoveMemory(effect, ptrEffect[0],4);
+        int[1] ptrEffect;
+        OS.MoveMemory(ptrEffect.ptr, stgmedium.unionField,4);
+        int[1] effect;
+        OS.MoveMemory(effect.ptr, ptrEffect[0],4);
         dataEffect = osToOp(effect[0]);
     }
     if (fRelease is 1) {
@@ -652,3 +644,42 @@
 }
 
 }
+
+
+private class _IDropSourceImpl : IDropSource {
+
+    DragSource  parent;
+    this(DragSource p) { parent = p; }
+extern (Windows):
+    // interface of IUnknown
+    HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); }
+    ULONG AddRef()  { return parent.AddRef(); }
+    ULONG Release() { return parent.Release(); }
+
+    // interface of IDropSource
+    HRESULT QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { return parent.QueryContinueDrag(fEscapePressed, grfKeyState); }
+    HRESULT GiveFeedback(DWORD dwEffect) { return parent.GiveFeedback(dwEffect);}
+}
+
+private class _IDataObjectImpl : IDataObject {
+
+    DragSource  parent;
+    this(DragSource p) { parent = p; }
+extern (Windows):
+    // interface of IUnknown
+    HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); }
+    ULONG AddRef()  { return parent.AddRef(); }
+    ULONG Release() { return parent.Release(); }
+
+
+    // interface IDataObject
+    LRESULT GetData( FORMATETC *pFormatetc, STGMEDIUM *pmedium) { return parent.GetData(pFormatetc, pmedium); }
+    LRESULT GetDataHere(FORMATETC * pFormatetc, STGMEDIUM * pmedium) { return COM.E_NOTIMPL; }
+    LRESULT QueryGetData(FORMATETC* pFormatetc) { return parent.QueryGetData(pFormatetc); }
+    LRESULT GetCanonicalFormatEtc(FORMATETC* pFormatetcIn, FORMATETC* pFormatetcOut) { return COM.E_NOTIMPL; }
+    LRESULT SetData(FORMATETC* pFormatetc, STGMEDIUM * pmedium, BOOL fRelease) { return parent.SetData(pFormatetc, pmedium, fRelease); }
+    LRESULT EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC * ppenumFormatetc) { return parent.EnumFormatEtc(dwDirection, ppenumFormatetc); }
+    LRESULT DAdvise(FORMATETC* pFormatetc, DWORD advf, IAdviseSink pAdvSink, DWORD* pdwConnection) { return COM.E_NOTIMPL; }
+    LRESULT DUnadvise(DWORD dwConnection) { return COM.E_NOTIMPL; }
+    LRESULT EnumDAdvise(IEnumSTATDATA * ppenumAdvise) { return COM.E_NOTIMPL; }
+}
--- a/dwt/dnd/DropTarget.d	Wed Feb 13 04:51:22 2008 +0100
+++ b/dwt/dnd/DropTarget.d	Wed Feb 13 14:24:54 2008 +0100
@@ -16,6 +16,10 @@
 import dwt.DWTError;
 import dwt.DWTException;
 import dwt.internal.ole.win32.COM;
+import dwt.internal.ole.win32.extras;
+import dwt.internal.ole.win32.OBJIDL;
+import dwt.internal.ole.win32.OLEIDL;
+import dwt.internal.ole.win32.ifs;
 import dwt.internal.win32.OS;
 import dwt.widgets.Control;
 import dwt.widgets.Event;
@@ -24,6 +28,14 @@
 import dwt.widgets.Tree;
 import dwt.widgets.Widget;
 
+import dwt.dnd.Transfer;
+import dwt.dnd.DropTargetEffect;
+import dwt.dnd.TransferData;
+import dwt.dnd.DropTargetListener;
+import dwt.dnd.DNDListener;
+import dwt.dnd.DNDEvent;
+import dwt.dnd.DND;
+
 /**
  *
  * Class <code>DropTarget</code> defines the target object for a drag and drop transfer.
@@ -79,7 +91,7 @@
 
     Control control;
     Listener controlListener;
-    Transfer[] transferAgents = new Transfer[0];
+    Transfer[] transferAgents;
     DropTargetEffect dropEffect;
 
     // Track application selections
@@ -95,11 +107,11 @@
     IDataObject iDataObject;
 
     // interfaces
-    COMObject iDropTarget;
+    _IDropTargetImpl iDropTarget;
     int refCount;
 
-    static final String DEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$
-    static final String DROPTARGETID = "DropTarget"; //$NON-NLS-1$
+    static final char[] DEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$
+    static final char[] DROPTARGETID = "DropTarget"; //$NON-NLS-1$
 
 /**
  * Creates a new <code>DropTarget</code> to allow data to be dropped on the specified
@@ -147,28 +159,28 @@
     if (COM.RegisterDragDrop( control.handle, iDropTarget.getAddress()) !is COM.S_OK)
         DND.error(DND.ERROR_CANNOT_INIT_DROP);
 
-    controlListener = new Listener () {
+    controlListener = new class() Listener {
         public void handleEvent (Event event) {
-            if (!DropTarget.this.isDisposed()){
-                DropTarget.this.dispose();
+            if (!this.outer.isDisposed()){
+                this.outer.dispose();
             }
         }
     };
     control.addListener (DWT.Dispose, controlListener);
 
-    this.addListener(DWT.Dispose, new Listener () {
+    this.addListener(DWT.Dispose, new class() Listener {
         public void handleEvent (Event event) {
             onDispose();
         }
     });
 
     Object effect = control.getData(DEFAULT_DROP_TARGET_EFFECT);
-    if (effect instanceof DropTargetEffect) {
-        dropEffect = (DropTargetEffect) effect;
-    } else if (control instanceof Table) {
-        dropEffect = new TableDropTargetEffect((Table) control);
-    } else if (control instanceof Tree) {
-        dropEffect = new TreeDropTargetEffect((Tree) control);
+    if ( auto dte = cast(DropTargetEffect) effect ) {
+        dropEffect = dte;
+    } else if ( auto table = cast(Table)control ) {
+        dropEffect = new TableDropTargetEffect(table);
+    } else if ( auto tree = cast(Tree)control ) {
+        dropEffect = new TreeDropTargetEffect(tree);
     }
 }
 
@@ -227,30 +239,19 @@
 }
 
 protected void checkSubclass () {
-    String name = getClass().getName ();
-    String validName = DropTarget.class.getName();
-    if (!validName.equals(name)) {
+    char[] name = this.classinfo.name;
+    char[] validName = DropTarget.classinfo.name;
+    if (validName!=/*eq*/name) {
         DND.error (DWT.ERROR_INVALID_SUBCLASS);
     }
 }
 
 void createCOMInterfaces() {
     // register each of the interfaces that this object implements
-    iDropTarget = new COMObject(new int[]{2, 0, 0, 5, 4, 0, 5}){
-        public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
-        public int method1(int[] args) {return AddRef();}
-        public int method2(int[] args) {return Release();}
-        public int method3(int[] args) {return DragEnter(args[0], args[1], args[2], args[3], args[4]);}
-        public int method4(int[] args) {return DragOver(args[0], args[1], args[2], args[3]);}
-        public int method5(int[] args) {return DragLeave();}
-        public int method6(int[] args) {return Drop(args[0], args[1], args[2], args[3], args[4]);}
-    };
-
+    iDropTarget = new _IDropTargetImpl(this);
 }
 
 void disposeCOMInterfaces() {
-    if (iDropTarget !is null)
-        iDropTarget.dispose();
     iDropTarget = null;
 }
 
@@ -262,7 +263,7 @@
 
     DNDEvent event = new DNDEvent();
     if (!setEventData(event, pDataObject, grfKeyState, pt_x, pt_y, pdwEffect)) {
-        OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);
+        *pdwEffect = COM.DROPEFFECT_NONE;
         return COM.S_FALSE;
     }
 
@@ -292,7 +293,7 @@
         selectedOperation = event.detail;
     }
 
-    OS.MoveMemory(pdwEffect, new int[] {opToOs(selectedOperation)}, 4);
+    *pdwEffect = opToOs(selectedOperation);
     return COM.S_OK;
 }
 
@@ -320,7 +321,7 @@
     DNDEvent event = new DNDEvent();
     if (!setEventData(event, iDataObject.getAddress(), grfKeyState, pt_x, pt_y, pdwEffect)) {
         keyOperation = -1;
-        OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);
+        *pdwEffect = COM.DROPEFFECT_NONE;
         return COM.S_FALSE;
     }
 
@@ -355,7 +356,7 @@
         selectedOperation = event.detail;
     }
 
-    OS.MoveMemory(pdwEffect, new int[] {opToOs(selectedOperation)}, 4);
+    *pdwEffect = opToOs(selectedOperation);
     return COM.S_OK;
 }
 
@@ -373,7 +374,7 @@
     event = new DNDEvent();
     if (!setEventData(event, pDataObject, grfKeyState, pt_x, pt_y, pdwEffect)) {
         keyOperation = -1;
-        OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);
+        *pdwEffect = COM.DROPEFFECT_NONE;
         return COM.S_FALSE;
     }
     keyOperation = -1;
@@ -398,7 +399,7 @@
     }
 
     if (selectedOperation is DND.DROP_NONE){
-        OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);
+        *pdwEffect = COM.DROPEFFECT_NONE;
         return COM.S_OK;
     }
 
@@ -430,7 +431,7 @@
         selectedOperation = event.detail;
     }
     //notify source of action taken
-    OS.MoveMemory(pdwEffect, new int[] {opToOs(selectedOperation)}, 4);
+    *pdwEffect = opToOs(selectedOperation);
     return COM.S_OK;
 }
 
@@ -533,17 +534,15 @@
  */
 int QueryInterface(int riid, int ppvObject) {
 
-    if (riid is 0 || ppvObject is 0)
+    if (riid is null || ppvObject is null)
         return COM.E_INVALIDARG;
-    GUID guid = new GUID();
-    COM.MoveMemory(guid, riid, GUID.sizeof);
-    if (COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIDropTarget)) {
-        OS.MoveMemory(ppvObject, new int[] {iDropTarget.getAddress()}, 4);
+    if (COM.IsEqualGUID(riid, &COM.IIDIUnknown) || COM.IsEqualGUID(riid, &COM.IIDIDropTarget)) {
+        *ppvObject = cast(void*)cast(IUnknown) iDropTarget.getAddress();
         AddRef();
         return COM.S_OK;
     }
 
-    OS.MoveMemory(ppvObject, new int[] {0}, 4);
+    *ppvObject = null;
     return COM.E_NOINTERFACE;
 }
 
@@ -561,10 +560,10 @@
 void refresh() {
     if (control is null || control.isDisposed()) return;
     int handle = control.handle;
-    RECT lpRect = new RECT();
-    if (OS.GetUpdateRect(handle, lpRect, false)) {
+    RECT lpRect;
+    if (OS.GetUpdateRect(handle, &lpRect, false)) {
         OS.ImageList_DragShowNolock(false);
-        OS.RedrawWindow(handle, lpRect, 0, OS.RDW_UPDATENOW | OS.RDW_INVALIDATE);
+        OS.RedrawWindow(handle, *lpRect, 0, OS.RDW_UPDATENOW | OS.RDW_INVALIDATE);
         OS.ImageList_DragShowNolock(true);
     }
 }
@@ -614,8 +613,8 @@
 
     // get allowed operations
     int style = getStyle();
-    int[] operations = new int[1];
-    OS.MoveMemory(operations, pdwEffect, 4);
+    int[1] operations;
+    OS.MoveMemory(operations.ptr, pdwEffect, 4);
     operations[0] = osToOp(operations[0]) & style;
     if (operations[0] is DND.DROP_NONE) return false;
 
@@ -635,8 +634,8 @@
     IDataObject dataObject = new IDataObject(pDataObject);
     dataObject.AddRef();
     try {
-        int[] address = new int[1];
-        if (dataObject.EnumFormatEtc(COM.DATADIR_GET, address) !is COM.S_OK) {
+        int[1] address;
+        if (dataObject.EnumFormatEtc(COM.DATADIR_GET, address.ptr) !is COM.S_OK) {
             return false;
         }
         IEnumFORMATETC enumFormatetc = new IEnumFORMATETC(address[0]);
@@ -707,3 +706,27 @@
     this.transferAgents = transferAgents;
 }
 }
+
+class _IDropTargetImpl : IDropTarget {
+
+    DropTarget  parent;
+    this(DropTarget p) { parent = p; }
+extern (Windows):
+    // interface of IUnknown
+    HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); }
+    ULONG AddRef()  { return parent.AddRef(); }
+    ULONG Release() { return parent.Release(); }
+
+    HRESULT DragEnter( IDataObject pDataObj, DWORD grfKeyState, POINT pt, DWORD *pdwEffect ) {
+        return parent.DragEnter(pDataObj, grfKeyState, pt, pdwEffect);
+    }
+    HRESULT DragOver( DWORD grfKeyState, POINT pt, DWORD *pdwEffect ) {
+        return parent.DragOver(grfKeyState, pt, pdwEffect);
+    }
+    HRESULT DragLeave(){ return parent.DragLeave(); }
+    HRESULT Drop(IDataObject pDataObj,DWORD grfKeyState,POINT pt,DWORD *pdwEffect){
+        return parent.Drop(pDataObj, grfKeyState, pt, pdwEffect);
+    }
+}
+
+
--- a/dwt/dnd/TableDragSourceEffect.d	Wed Feb 13 04:51:22 2008 +0100
+++ b/dwt/dnd/TableDragSourceEffect.d	Wed Feb 13 14:24:54 2008 +0100
@@ -20,6 +20,9 @@
 import dwt.widgets.Table;
 import dwt.widgets.TableItem;
 
+import dwt.dnd.DragSourceEffect;
+import dwt.dnd.DragSourceEvent;
+
 /**
  * This class provides default implementations to display a source image
  * when a drag is initiated from a <code>Table</code>.
@@ -82,7 +85,7 @@
     Image getDragSourceImage(DragSourceEvent event) {
         if (dragSourceImage !is null) dragSourceImage.dispose();
         dragSourceImage = null;
-        Table table = (Table) control;
+        Table table = cast(Table) control;
         TableItem[] selection = table.getSelection();
         if (selection.length is 0) return null;
         int tableImageList = OS.SendMessage (table.handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
@@ -90,12 +93,12 @@
             int count = Math.min(selection.length, 10);
             Rectangle bounds = selection[0].getBounds(0);
             for (int i = 1; i < count; i++) {
-                bounds = bounds.union(selection[i].getBounds(0));
+                bounds = bounds.union_(selection[i].getBounds(0));
             }
-            int hDC = OS.GetDC(0);
-            int hDC1 = OS.CreateCompatibleDC(hDC);
-            int bitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height);
-            int hOldBitmap = OS.SelectObject(hDC1, bitmap);
+            auto hDC = OS.GetDC(null);
+            auto hDC1 = OS.CreateCompatibleDC(hDC);
+            auto bitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height);
+            auto hOldBitmap = OS.SelectObject(hDC1, bitmap);
             RECT rect = new RECT();
             rect.right = bounds.width;
             rect.bottom = bounds.height;
@@ -111,7 +114,7 @@
             }
             OS.SelectObject(hDC1, hOldBitmap);
             OS.DeleteDC (hDC1);
-            OS.ReleaseDC (0, hDC);
+            OS.ReleaseDC (null, hDC);
             Display display = table.getDisplay();
             dragSourceImage = Image.win32_new(display, DWT.BITMAP, bitmap);
             return dragSourceImage;
--- a/dwt/dnd/Transfer.d	Wed Feb 13 04:51:22 2008 +0100
+++ b/dwt/dnd/Transfer.d	Wed Feb 13 14:24:54 2008 +0100
@@ -137,7 +137,7 @@
     // Look name up in the registry
     // If name is not in registry, add it and return assigned value.
     // If name already exists in registry, return its assigned value
-    TCHAR chFormatName = new TCHAR(0, formatName, true);
+    TCHAR* chFormatName = StrToTCHARz(0, formatName);
     return OS.RegisterClipboardFormat(chFormatName);
 }
 
--- a/dwt/dnd/TreeDragSourceEffect.d	Wed Feb 13 04:51:22 2008 +0100
+++ b/dwt/dnd/TreeDragSourceEffect.d	Wed Feb 13 14:24:54 2008 +0100
@@ -20,6 +20,9 @@
 import dwt.widgets.Tree;
 import dwt.widgets.TreeItem;
 
+import dwt.dnd.DragSourceEffect;
+import dwt.dnd.DragSourceEvent;
+
 /**
  * This class provides default implementations to display a source image
  * when a drag is initiated from a <code>Tree</code>.
@@ -81,7 +84,7 @@
     Image getDragSourceImage(DragSourceEvent event) {
         if (dragSourceImage !is null) dragSourceImage.dispose();
         dragSourceImage = null;
-        Tree tree = (Tree) control;
+        Tree tree = cast(Tree) control;
         TreeItem[] selection = tree.getSelection();
         if (selection.length is 0) return null;
         int treeImageList = OS.SendMessage (tree.handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
@@ -89,17 +92,17 @@
             int count = Math.min(selection.length, 10);
             Rectangle bounds = selection[0].getBounds(0);
             for (int i = 1; i < count; i++) {
-                bounds = bounds.union(selection[i].getBounds(0));
+                bounds = bounds.union_(selection[i].getBounds(0));
             }
             int hDC = OS.GetDC(0);
             int hDC1 = OS.CreateCompatibleDC(hDC);
             int bitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height);
             int hOldBitmap = OS.SelectObject(hDC1, bitmap);
-            RECT rect = new RECT();
+            RECT rect;
             rect.right = bounds.width;
             rect.bottom = bounds.height;
             int hBrush = OS.GetStockObject(OS.WHITE_BRUSH);
-            OS.FillRect(hDC1, rect, hBrush);
+            OS.FillRect(hDC1, &rect, hBrush);
             for (int i = 0; i < count; i++) {
                 TreeItem selected = selection[i];
                 Rectangle cell = selected.getBounds(0);
--- a/dwt/internal/win32/OS.d	Wed Feb 13 04:51:22 2008 +0100
+++ b/dwt/internal/win32/OS.d	Wed Feb 13 14:24:54 2008 +0100
@@ -4653,8 +4653,13 @@
 alias WINAPI.IIDFromString IIDFromString;
 alias WINAPI.ImageList_Add ImageList_Add;
 alias WINAPI.ImageList_AddMasked ImageList_AddMasked;
+alias WINAPI.ImageList_BeginDrag ImageList_BeginDrag;
 alias WINAPI.ImageList_Create ImageList_Create;
 alias WINAPI.ImageList_Destroy ImageList_Destroy;
+alias WINAPI.ImageList_DragEnter ImageList_DragEnter;
+alias WINAPI.ImageList_DragLeave ImageList_DragLeave;
+alias WINAPI.ImageList_DragMove ImageList_DragMove;
+alias WINAPI.ImageList_EndDrag ImageList_EndDrag;
 alias WINAPI.ImageList_GetIcon ImageList_GetIcon;
 alias WINAPI.ImageList_GetIconSize ImageList_GetIconSize;
 alias WINAPI.ImageList_GetImageCount ImageList_GetImageCount;
--- a/dwt/internal/win32/WINAPI.d	Wed Feb 13 04:51:22 2008 +0100
+++ b/dwt/internal/win32/WINAPI.d	Wed Feb 13 14:24:54 2008 +0100
@@ -1599,11 +1599,11 @@
 //     WINBOOL ImageList_DrawEx(HIMAGELIST, int, HDC, int, int, int, int, COLORREF, COLORREF, UINT);
 //     WINBOOL ImageList_Remove(HIMAGELIST, int);
 //     HICON ImageList_GetIcon(HIMAGELIST, int, UINT);
-//     WINBOOL ImageList_BeginDrag(HIMAGELIST, int, int, int);
-//     void ImageList_EndDrag();
-//     WINBOOL ImageList_DragEnter(HWND, int, int);
-//     WINBOOL ImageList_DragLeave(HWND);
-//     WINBOOL ImageList_DragMove(int, int);
+    WINBOOL ImageList_BeginDrag(HIMAGELIST, int, int, int);
+    void ImageList_EndDrag();
+    WINBOOL ImageList_DragEnter(HWND, int, int);
+    WINBOOL ImageList_DragLeave(HWND);
+    WINBOOL ImageList_DragMove(int, int);
 //     WINBOOL ImageList_SetDragCursorImage(HIMAGELIST, int, int, int);
 //     WINBOOL ImageList_DragShowNolock(WINBOOL);
 //     HIMAGELIST ImageList_GetDragImage(POINT*, POINT*);