Changeset 136:04e357b8343d

Show
Ignore:
Timestamp:
02/13/08 08:24:54 (10 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

DragSource?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dnd/DragSource.d

    r135 r136  
    2121import dwt.internal.ImageList; 
    2222import dwt.internal.ole.win32.COM; 
     23import dwt.internal.ole.win32.OLEIDL; 
     24import dwt.internal.ole.win32.OBJIDL; 
     25import dwt.internal.ole.win32.ifs; 
     26import dwt.internal.ole.win32.extras; 
    2327import dwt.internal.win32.OS; 
    2428import dwt.widgets.Composite; 
     
    3034import dwt.widgets.Tree; 
    3135import dwt.widgets.Widget; 
     36 
     37import dwt.dnd.DragSourceEffect; 
     38import dwt.dnd.DragSourceListener; 
     39import dwt.dnd.Transfer; 
     40import dwt.dnd.TransferData; 
     41import dwt.dnd.DND; 
     42import dwt.dnd.DNDListener; 
     43import dwt.dnd.DNDEvent; 
     44import dwt.dnd.TreeDragSourceEffect; 
     45import dwt.dnd.TableDragSourceEffect; 
     46import dwt.dnd.OleEnumFORMATETC; 
     47 
     48import dwt.dwthelper.utils; 
    3249 
    3350/** 
     
    112129    Control control; 
    113130    Listener controlListener; 
    114     Transfer[] transferAgents = new Transfer[0]
     131    Transfer[] transferAgents
    115132    DragSourceEffect dragEffect; 
    116133    Composite topControl; 
    117134 
    118135    // ole interfaces 
    119     COMObject iDropSource; 
    120     COMObject iDataObject; 
     136    _IDropSourceImpl iDropSource; 
     137    _IDataObjectImpl iDataObject; 
    121138    int refCount; 
    122139 
     
    124141    int dataEffect = DND.DROP_NONE; 
    125142 
    126     static final String DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$ 
    127     static final String DRAGSOURCEID = "DragSource"; //$NON-NLS-1$ 
    128     static final int CFSTR_PERFORMEDDROPEFFECT  = Transfer.registerType("Performed DropEffect");     //$NON-NLS-1$ 
    129  
     143    static const char[] DEFAULT_DRAG_SOURCE_EFFECT = "DEFAULT_DRAG_SOURCE_EFFECT"; //$NON-NLS-1$ 
     144    static const char[] DRAGSOURCEID = "DragSource"; //$NON-NLS-1$ 
     145    static const int CFSTR_PERFORMEDDROPEFFECT; 
     146    static this(){ 
     147        CFSTR_PERFORMEDDROPEFFECT  = Transfer.registerType("Performed DropEffect");     //$NON-NLS-1$ 
     148    } 
    130149/** 
    131150 * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>. 
     
    167186    this.AddRef(); 
    168187 
    169     controlListener = new Listener()
     188    controlListener = new class() Listener
    170189        public void handleEvent(Event event) { 
    171190            if (event.type is DWT.Dispose) { 
    172                 if (!DragSource.this.isDisposed()) { 
    173                     DragSource.this.dispose(); 
     191                if (!this.outer.isDisposed()) { 
     192                    this.outer.dispose(); 
    174193                } 
    175194            } 
    176195            if (event.type is DWT.DragDetect) { 
    177                 if (!DragSource.this.isDisposed()) { 
    178                     DragSource.this.drag(event); 
     196                if (!this.outer.isDisposed()) { 
     197                    this.outer.drag(event); 
    179198                } 
    180199            } 
     
    184203    control.addListener(DWT.DragDetect, controlListener); 
    185204 
    186     this.addListener(DWT.Dispose, new Listener()
     205    this.addListener(DWT.Dispose, new class() Listener
    187206        public void handleEvent(Event e) { 
    188             DragSource.this.onDispose(); 
     207            this.outer.onDispose(); 
    189208        } 
    190209    }); 
    191210 
    192211    Object effect = control.getData(DEFAULT_DRAG_SOURCE_EFFECT); 
    193     if (effect instanceof DragSourceEffect) { 
    194         dragEffect = (DragSourceEffect) effect
    195     } else if (control instanceof Tree) { 
    196         dragEffect = new TreeDragSourceEffect((Tree) control); 
    197     } else if (control instanceof Table) { 
    198         dragEffect = new TableDragSourceEffect((Table) control); 
     212    if ( auto dse = cast(DragSourceEffect)effect ) { 
     213        dragEffect = dse
     214    } else if ( auto tree = cast(Tree)control ) { 
     215        dragEffect = new TreeDragSourceEffect(tree); 
     216    } else if ( auto table = cast(Table)control ) { 
     217        dragEffect = new TableDragSourceEffect(table); 
    199218    } 
    200219} 
     
    250269private void createCOMInterfaces() { 
    251270    // register each of the interfaces that this object implements 
    252     iDropSource = new COMObject(new int[]{2, 0, 0, 2, 1}){ 
    253         public int method0(int[] args) {return QueryInterface(args[0], args[1]);} 
    254         public int method1(int[] args) {return AddRef();} 
    255         public int method2(int[] args) {return Release();} 
    256         public int method3(int[] args) {return QueryContinueDrag(args[0], args[1]);} 
    257         public int method4(int[] args) {return GiveFeedback(args[0]);} 
    258     }; 
    259  
    260     iDataObject = new COMObject(new int[]{2, 0, 0, 2, 2, 1, 2, 3, 2, 4, 1, 1}){ 
    261         public int method0(int[] args) {return QueryInterface(args[0], args[1]);} 
    262         public int method1(int[] args) {return AddRef();} 
    263         public int method2(int[] args) {return Release();} 
    264         public int method3(int[] args) {return GetData(args[0], args[1]);} 
    265         // method4 GetDataHere - not implemented 
    266         public int method5(int[] args) {return QueryGetData(args[0]);} 
    267         // method6 GetCanonicalFormatEtc - not implemented 
    268         public int method7(int[] args) {return SetData(args[0], args[1], args[2]);} 
    269         public int method8(int[] args) {return EnumFormatEtc(args[0], args[1]);} 
    270         // method9 DAdvise - not implemented 
    271         // method10 DUnadvise - not implemented 
    272         // method11 EnumDAdvise - not implemented 
    273     }; 
     271    iDropSource = new _IDropSourceImpl(this); 
     272    iDataObject = new _IDataObjectImpl(this); 
    274273} 
    275274 
    276275protected void checkSubclass() { 
    277     String name = getClass().getName()
    278     String validName = DragSource.class.getName()
    279     if (!validName.equals(name)) { 
     276    char[] name = this.classinfo.name
     277    char[] validName = DragSource.classinfo.name
     278    if (validName!=/*eq*/name) { 
    280279        DND.error(DWT.ERROR_INVALID_SUBCLASS); 
    281280    } 
     
    283282 
    284283private void disposeCOMInterfaces() { 
    285     if (iDropSource !is null) 
    286         iDropSource.dispose(); 
    287284    iDropSource = null; 
    288  
    289     if (iDataObject !is null) 
    290         iDataObject.dispose(); 
    291285    iDataObject = null; 
    292286} 
     
    302296    if (!event.doit || transferAgents is null || transferAgents.length is 0 ) return; 
    303297 
    304     int[] pdwEffect = new int[1]
     298    uint[1] pdwEffect
    305299    int operations = opToOs(getStyle()); 
    306300    Display display = control.getDisplay(); 
    307     String key = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ 
     301    char[] key = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$ 
    308302    Object oldValue = display.getData(key); 
    309     display.setData(key, new bool(true)); 
     303    display.setData(key, new ValueWrapperBool(true)); 
    310304    ImageList imagelist = null; 
    311305    Image image = event.image; 
     
    328322        } else { 
    329323            int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN; 
    330             OS.RedrawWindow (topControl.handle, null, 0, flags); 
     324            OS.RedrawWindow (topControl.handle, null, null, flags); 
    331325        } 
    332326        OS.ImageList_DragEnter(topControl.handle, dragEvent.x - location.x, dragEvent.y - location.y); 
    333327    } 
    334     int result = COM.DoDragDrop(iDataObject.getAddress(), iDropSource.getAddress(), operations, pdwEffect); 
     328    int result = COM.DoDragDrop(iDataObject, iDropSource, operations, pdwEffect.ptr); 
    335329    if (imagelist !is null) { 
    336330        OS.ImageList_DragLeave(topControl.handle); 
     
    361355 * must be incremented before returning.  Caller is responsible for releasing ppenumFormatetc. 
    362356 */ 
    363 private int EnumFormatEtc(int dwDirection, int ppenumFormatetc) { 
     357private int EnumFormatEtc(int dwDirection, IEnumFORMATETC* ppenumFormatetc) { 
    364358    // only allow getting of data - SetData is not currently supported 
    365359    if (dwDirection is COM.DATADIR_SET) return COM.E_NOTIMPL; 
     
    381375    enumFORMATETC.AddRef(); 
    382376 
    383     FORMATETC[] formats = new FORMATETC[allowedDataTypes.length]; 
     377    FORMATETC*[] formats = new FORMATETC*[allowedDataTypes.length]; 
    384378    for (int i = 0; i < formats.length; i++){ 
    385379        formats[i] = allowedDataTypes[i].formatetc; 
     
    387381    enumFORMATETC.setFormats(formats); 
    388382 
    389     OS.MoveMemory(ppenumFormatetc, new int[] {enumFORMATETC.getAddress()}, 4); 
     383    *ppenumFormatetc = enumFORMATETC.getAddress(); 
    390384    return COM.S_OK; 
    391385} 
     
    400394} 
    401395 
    402 private int GetData(int pFormatetc, int pmedium) { 
     396.LRESULT GetData(FORMATETC *pFormatetc, STGMEDIUM *pmedium) { 
    403397    /* Called by a data consumer to obtain data from a source data object. 
    404398       The GetData method renders the data described in the specified FORMATETC 
     
    406400       The caller then assumes responsibility for releasing the STGMEDIUM structure. 
    407401    */ 
    408     if (pFormatetc is 0 || pmedium is 0) return COM.E_INVALIDARG; 
     402    if (pFormatetc is null || pmedium is null) return COM.E_INVALIDARG; 
    409403 
    410404    if (QueryGetData(pFormatetc) !is COM.S_OK) return COM.DV_E_FORMATETC; 
     
    461455} 
    462456 
    463 private int GiveFeedback(int dwEffect) { 
     457package .LRESULT GiveFeedback(DWORD dwEffect) { 
    464458    return COM.DRAGDROP_S_USEDEFAULTCURSORS; 
    465459} 
    466460 
    467 private int QueryContinueDrag(int fEscapePressed, int grfKeyState) { 
     461package .LRESULT QueryContinueDrag(int fEscapePressed, DWORD grfKeyState) { 
    468462    if (fEscapePressed !is 0){ 
    469463        if (topControl !is null) OS.ImageList_DragLeave(topControl.handle); 
     
    533527} 
    534528 
    535 private int QueryGetData(int pFormatetc) { 
     529private .LRESULT QueryGetData(FORMATETC* pFormatetc) { 
    536530    if (transferAgents is null) return COM.E_FAIL; 
    537531    TransferData transferData = new TransferData(); 
     
    554548 * must be incremented before returning.  Caller is responsible for releasing ppvObject. 
    555549 */ 
    556 private int QueryInterface(int riid, int ppvObject) { 
    557     if (riid is 0 || ppvObject is 0
     550private HRESULT QueryInterface(REFIID riid, void** ppvObject) { 
     551    if (riid is null || ppvObject is null
    558552        return COM.E_INVALIDARG; 
    559     GUID guid = new GUID(); 
    560     COM.MoveMemory(guid, riid, GUID.sizeof); 
    561  
    562     if (COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIDropSource)) { 
    563         OS.MoveMemory(ppvObject, new int[] {iDropSource.getAddress()}, 4); 
     553 
     554    if (COM.IsEqualGUID(riid, &COM.IIDIUnknown) || COM.IsEqualGUID(riid, &COM.IIDIDropSource)) { 
     555        *ppvObject = cast(void*)cast(IUnknown) iDropSource; 
    564556        AddRef(); 
    565557        return COM.S_OK; 
    566558    } 
    567559 
    568     if (COM.IsEqualGUID(guid, COM.IIDIDataObject) ) { 
    569         OS.MoveMemory(ppvObject, new int[] {iDataObject.getAddress()}, 4)
     560    if (COM.IsEqualGUID(riid, &COM.IIDIDataObject) ) { 
     561        *ppvObject = cast(void*)cast(IDataObject) iDataObject
    570562        AddRef(); 
    571563        return COM.S_OK; 
    572564    } 
    573565 
    574     OS.MoveMemory(ppvObject, new int[] {0}, 4)
     566    *ppvObject = null
    575567    return COM.E_NOINTERFACE; 
    576568} 
    577569 
    578 private int Release() { 
     570private ULONG Release() { 
    579571    refCount--; 
    580572    if (refCount is 0) { 
     
    609601} 
    610602 
    611 private int SetData(int pFormatetc, int pmedium, int fRelease) { 
    612     if (pFormatetc is 0 || pmedium is 0) return COM.E_INVALIDARG; 
    613     FORMATETC formatetc = new FORMATETC(); 
     603.LRESULT SetData(FORMATETC* pFormatetc, STGMEDIUM* pmedium, int fRelease) { 
     604    if (pFormatetc is null || pmedium is null) return COM.E_INVALIDARG; 
     605    FORMATETC* formatetc = new FORMATETC(); 
    614606    COM.MoveMemory(formatetc, pFormatetc, FORMATETC.sizeof); 
    615607    if (formatetc.cfFormat is CFSTR_PERFORMEDDROPEFFECT && formatetc.tymed is COM.TYMED_HGLOBAL) { 
    616         STGMEDIUM stgmedium = new STGMEDIUM(); 
     608        STGMEDIUM* stgmedium = new STGMEDIUM(); 
    617609        COM.MoveMemory(stgmedium, pmedium,STGMEDIUM.sizeof); 
    618         int[] ptrEffect = new int[1]
    619         OS.MoveMemory(ptrEffect, stgmedium.unionField,4); 
    620         int[] effect = new int[1]
    621         OS.MoveMemory(effect, ptrEffect[0],4); 
     610        int[1] ptrEffect
     611        OS.MoveMemory(ptrEffect.ptr, stgmedium.unionField,4); 
     612        int[1] effect
     613        OS.MoveMemory(effect.ptr, ptrEffect[0],4); 
    622614        dataEffect = osToOp(effect[0]); 
    623615    } 
     
    653645 
    654646} 
     647 
     648 
     649private class _IDropSourceImpl : IDropSource { 
     650 
     651    DragSource  parent; 
     652    this(DragSource p) { parent = p; } 
     653extern (Windows): 
     654    // interface of IUnknown 
     655    HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } 
     656    ULONG AddRef()  { return parent.AddRef(); } 
     657    ULONG Release() { return parent.Release(); } 
     658 
     659    // interface of IDropSource 
     660    HRESULT QueryContinueDrag(BOOL fEscapePressed, DWORD grfKeyState) { return parent.QueryContinueDrag(fEscapePressed, grfKeyState); } 
     661    HRESULT GiveFeedback(DWORD dwEffect) { return parent.GiveFeedback(dwEffect);} 
     662} 
     663 
     664private class _IDataObjectImpl : IDataObject { 
     665 
     666    DragSource  parent; 
     667    this(DragSource p) { parent = p; } 
     668extern (Windows): 
     669    // interface of IUnknown 
     670    HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } 
     671    ULONG AddRef()  { return parent.AddRef(); } 
     672    ULONG Release() { return parent.Release(); } 
     673 
     674 
     675    // interface IDataObject 
     676    LRESULT GetData( FORMATETC *pFormatetc, STGMEDIUM *pmedium) { return parent.GetData(pFormatetc, pmedium); } 
     677    LRESULT GetDataHere(FORMATETC * pFormatetc, STGMEDIUM * pmedium) { return COM.E_NOTIMPL; } 
     678    LRESULT QueryGetData(FORMATETC* pFormatetc) { return parent.QueryGetData(pFormatetc); } 
     679    LRESULT GetCanonicalFormatEtc(FORMATETC* pFormatetcIn, FORMATETC* pFormatetcOut) { return COM.E_NOTIMPL; } 
     680    LRESULT SetData(FORMATETC* pFormatetc, STGMEDIUM * pmedium, BOOL fRelease) { return parent.SetData(pFormatetc, pmedium, fRelease); } 
     681    LRESULT EnumFormatEtc(DWORD dwDirection, IEnumFORMATETC * ppenumFormatetc) { return parent.EnumFormatEtc(dwDirection, ppenumFormatetc); } 
     682    LRESULT DAdvise(FORMATETC* pFormatetc, DWORD advf, IAdviseSink pAdvSink, DWORD* pdwConnection) { return COM.E_NOTIMPL; } 
     683    LRESULT DUnadvise(DWORD dwConnection) { return COM.E_NOTIMPL; } 
     684    LRESULT EnumDAdvise(IEnumSTATDATA * ppenumAdvise) { return COM.E_NOTIMPL; } 
     685} 
  • dwt/dnd/DropTarget.d

    r135 r136  
    1717import dwt.DWTException; 
    1818import dwt.internal.ole.win32.COM; 
     19import dwt.internal.ole.win32.extras; 
     20import dwt.internal.ole.win32.OBJIDL; 
     21import dwt.internal.ole.win32.OLEIDL; 
     22import dwt.internal.ole.win32.ifs; 
    1923import dwt.internal.win32.OS; 
    2024import dwt.widgets.Control; 
     
    2428import dwt.widgets.Tree; 
    2529import dwt.widgets.Widget; 
     30 
     31import dwt.dnd.Transfer; 
     32import dwt.dnd.DropTargetEffect; 
     33import dwt.dnd.TransferData; 
     34import dwt.dnd.DropTargetListener; 
     35import dwt.dnd.DNDListener; 
     36import dwt.dnd.DNDEvent; 
     37import dwt.dnd.DND; 
    2638 
    2739/** 
     
    8092    Control control; 
    8193    Listener controlListener; 
    82     Transfer[] transferAgents = new Transfer[0]
     94    Transfer[] transferAgents
    8395    DropTargetEffect dropEffect; 
    8496 
     
    96108 
    97109    // interfaces 
    98     COMObject iDropTarget; 
     110    _IDropTargetImpl iDropTarget; 
    99111    int refCount; 
    100112 
    101     static final String DEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$ 
    102     static final String DROPTARGETID = "DropTarget"; //$NON-NLS-1$ 
     113    static final char[] DEFAULT_DROP_TARGET_EFFECT = "DEFAULT_DROP_TARGET_EFFECT"; //$NON-NLS-1$ 
     114    static final char[] DROPTARGETID = "DropTarget"; //$NON-NLS-1$ 
    103115 
    104116/** 
     
    148160        DND.error(DND.ERROR_CANNOT_INIT_DROP); 
    149161 
    150     controlListener = new Listener ()
     162    controlListener = new class() Listener
    151163        public void handleEvent (Event event) { 
    152             if (!DropTarget.this.isDisposed()){ 
    153                 DropTarget.this.dispose(); 
     164            if (!this.outer.isDisposed()){ 
     165                this.outer.dispose(); 
    154166            } 
    155167        } 
     
    157169    control.addListener (DWT.Dispose, controlListener); 
    158170 
    159     this.addListener(DWT.Dispose, new Listener ()
     171    this.addListener(DWT.Dispose, new class() Listener
    160172        public void handleEvent (Event event) { 
    161173            onDispose(); 
     
    164176 
    165177    Object effect = control.getData(DEFAULT_DROP_TARGET_EFFECT); 
    166     if (effect instanceof DropTargetEffect) { 
    167         dropEffect = (DropTargetEffect) effect
    168     } else if (control instanceof Table) { 
    169         dropEffect = new TableDropTargetEffect((Table) control); 
    170     } else if (control instanceof Tree) { 
    171         dropEffect = new TreeDropTargetEffect((Tree) control); 
     178    if ( auto dte = cast(DropTargetEffect) effect ) { 
     179        dropEffect = dte
     180    } else if ( auto table = cast(Table)control ) { 
     181        dropEffect = new TableDropTargetEffect(table); 
     182    } else if ( auto tree = cast(Tree)control ) { 
     183        dropEffect = new TreeDropTargetEffect(tree); 
    172184    } 
    173185} 
     
    228240 
    229241protected void checkSubclass () { 
    230     String name = getClass().getName ()
    231     String validName = DropTarget.class.getName()
    232     if (!validName.equals(name)) { 
     242    char[] name = this.classinfo.name
     243    char[] validName = DropTarget.classinfo.name
     244    if (validName!=/*eq*/name) { 
    233245        DND.error (DWT.ERROR_INVALID_SUBCLASS); 
    234246    } 
     
    237249void createCOMInterfaces() { 
    238250    // register each of the interfaces that this object implements 
    239     iDropTarget = new COMObject(new int[]{2, 0, 0, 5, 4, 0, 5}){ 
    240         public int method0(int[] args) {return QueryInterface(args[0], args[1]);} 
    241         public int method1(int[] args) {return AddRef();} 
    242         public int method2(int[] args) {return Release();} 
    243         public int method3(int[] args) {return DragEnter(args[0], args[1], args[2], args[3], args[4]);} 
    244         public int method4(int[] args) {return DragOver(args[0], args[1], args[2], args[3]);} 
    245         public int method5(int[] args) {return DragLeave();} 
    246         public int method6(int[] args) {return Drop(args[0], args[1], args[2], args[3], args[4]);} 
    247     }; 
    248  
     251    iDropTarget = new _IDropTargetImpl(this); 
    249252} 
    250253 
    251254void disposeCOMInterfaces() { 
    252     if (iDropTarget !is null) 
    253         iDropTarget.dispose(); 
    254255    iDropTarget = null; 
    255256} 
     
    263264    DNDEvent event = new DNDEvent(); 
    264265    if (!setEventData(event, pDataObject, grfKeyState, pt_x, pt_y, pdwEffect)) { 
    265         OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4)
     266        *pdwEffect = COM.DROPEFFECT_NONE
    266267        return COM.S_FALSE; 
    267268    } 
     
    293294    } 
    294295 
    295     OS.MoveMemory(pdwEffect, new int[] {opToOs(selectedOperation)}, 4); 
     296    *pdwEffect = opToOs(selectedOperation); 
    296297    return COM.S_OK; 
    297298} 
     
    321322    if (!setEventData(event, iDataObject.getAddress(), grfKeyState, pt_x, pt_y, pdwEffect)) { 
    322323        keyOperation = -1; 
    323         OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4)
     324        *pdwEffect = COM.DROPEFFECT_NONE
    324325        return COM.S_FALSE; 
    325326    } 
     
    356357    } 
    357358 
    358     OS.MoveMemory(pdwEffect, new int[] {opToOs(selectedOperation)}, 4); 
     359    *pdwEffect = opToOs(selectedOperation); 
    359360    return COM.S_OK; 
    360361} 
     
    374375    if (!setEventData(event, pDataObject, grfKeyState, pt_x, pt_y, pdwEffect)) { 
    375376        keyOperation = -1; 
    376         OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4)
     377        *pdwEffect = COM.DROPEFFECT_NONE
    377378        return COM.S_FALSE; 
    378379    } 
     
    399400 
    400401    if (selectedOperation is DND.DROP_NONE){ 
    401         OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4)
     402        *pdwEffect = COM.DROPEFFECT_NONE
    402403        return COM.S_OK; 
    403404    } 
     
    431432    } 
    432433    //notify source of action taken 
    433     OS.MoveMemory(pdwEffect, new int[] {opToOs(selectedOperation)}, 4); 
     434    *pdwEffect = opToOs(selectedOperation); 
    434435    return COM.S_OK; 
    435436} 
     
    534535int QueryInterface(int riid, int ppvObject) { 
    535536 
    536     if (riid is 0 || ppvObject is 0
     537    if (riid is null || ppvObject is null
    537538        return COM.E_INVALIDARG; 
    538     GUID guid = new GUID(); 
    539     COM.MoveMemory(guid, riid, GUID.sizeof); 
    540     if (COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIDropTarget)) { 
    541         OS.MoveMemory(ppvObject, new int[] {iDropTarget.getAddress()}, 4); 
     539    if (COM.IsEqualGUID(riid, &COM.IIDIUnknown) || COM.IsEqualGUID(riid, &COM.IIDIDropTarget)) { 
     540        *ppvObject = cast(void*)cast(IUnknown) iDropTarget.getAddress(); 
    542541        AddRef(); 
    543542        return COM.S_OK; 
    544543    } 
    545544 
    546     OS.MoveMemory(ppvObject, new int[] {0}, 4)
     545    *ppvObject = null
    547546    return COM.E_NOINTERFACE; 
    548547} 
     
    562561    if (control is null || control.isDisposed()) return; 
    563562    int handle = control.handle; 
    564     RECT lpRect = new RECT()
    565     if (OS.GetUpdateRect(handle, lpRect, false)) { 
     563    RECT lpRect
     564    if (OS.GetUpdateRect(handle, &lpRect, false)) { 
    566565        OS.ImageList_DragShowNolock(false); 
    567         OS.RedrawWindow(handle, lpRect, 0, OS.RDW_UPDATENOW | OS.RDW_INVALIDATE); 
     566        OS.RedrawWindow(handle, *lpRect, 0, OS.RDW_UPDATENOW | OS.RDW_INVALIDATE); 
    568567        OS.ImageList_DragShowNolock(true); 
    569568    } 
     
    615614    // get allowed operations 
    616615    int style = getStyle(); 
    617     int[] operations = new int[1]
    618     OS.MoveMemory(operations, pdwEffect, 4); 
     616    int[1] operations
     617    OS.MoveMemory(operations.ptr, pdwEffect, 4); 
    619618    operations[0] = osToOp(operations[0]) & style; 
    620619    if (operations[0] is DND.DROP_NONE) return false; 
     
    636635    dataObject.AddRef(); 
    637636    try { 
    638         int[] address = new int[1]
    639         if (dataObject.EnumFormatEtc(COM.DATADIR_GET, address) !is COM.S_OK) { 
     637        int[1] address
     638        if (dataObject.EnumFormatEtc(COM.DATADIR_GET, address.ptr) !is COM.S_OK) { 
    640639            return false; 
    641640        } 
     
    708707} 
    709708} 
     709 
     710class _IDropTargetImpl : IDropTarget { 
     711 
     712    DropTarget  parent; 
     713    this(DropTarget p) { parent = p; } 
     714extern (Windows): 
     715    // interface of IUnknown 
     716    HRESULT QueryInterface(REFIID riid, void ** ppvObject) { return parent.QueryInterface(riid, ppvObject); } 
     717    ULONG AddRef()  { return parent.AddRef(); } 
     718    ULONG Release() { return parent.Release(); } 
     719 
     720    HRESULT DragEnter( IDataObject pDataObj, DWORD grfKeyState, POINT pt, DWORD *pdwEffect ) { 
     721        return parent.DragEnter(pDataObj, grfKeyState, pt, pdwEffect); 
     722    } 
     723    HRESULT DragOver( DWORD grfKeyState, POINT pt, DWORD *pdwEffect ) { 
     724        return parent.DragOver(grfKeyState, pt, pdwEffect); 
     725    } 
     726    HRESULT DragLeave(){ return parent.DragLeave(); } 
     727    HRESULT Drop(IDataObject pDataObj,DWORD grfKeyState,POINT pt,DWORD *pdwEffect){ 
     728        return parent.Drop(pDataObj, grfKeyState, pt, pdwEffect); 
     729    } 
     730} 
     731 
     732 
  • dwt/dnd/TableDragSourceEffect.d

    r135 r136  
    2020import dwt.widgets.Table; 
    2121import dwt.widgets.TableItem; 
     22 
     23import dwt.dnd.DragSourceEffect; 
     24import dwt.dnd.DragSourceEvent; 
    2225 
    2326/** 
     
    8386        if (dragSourceImage !is null) dragSourceImage.dispose(); 
    8487        dragSourceImage = null; 
    85         Table table = (Table) control; 
     88        Table table = cast(Table) control; 
    8689        TableItem[] selection = table.getSelection(); 
    8790        if (selection.length is 0) return null; 
     
    9194            Rectangle bounds = selection[0].getBounds(0); 
    9295            for (int i = 1; i < count; i++) { 
    93                 bounds = bounds.union(selection[i].getBounds(0)); 
     96                bounds = bounds.union_(selection[i].getBounds(0)); 
    9497            } 
    95             int hDC = OS.GetDC(0); 
    96             int hDC1 = OS.CreateCompatibleDC(hDC); 
    97             int bitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height); 
    98             int hOldBitmap = OS.SelectObject(hDC1, bitmap); 
     98            auto hDC = OS.GetDC(null); 
     99            auto hDC1 = OS.CreateCompatibleDC(hDC); 
     100            auto bitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height); 
     101            auto hOldBitmap = OS.SelectObject(hDC1, bitmap); 
    99102            RECT rect = new RECT(); 
    100103            rect.right = bounds.width; 
     
    112115            OS.SelectObject(hDC1, hOldBitmap); 
    113116            OS.DeleteDC (hDC1); 
    114             OS.ReleaseDC (0, hDC); 
     117            OS.ReleaseDC (null, hDC); 
    115118            Display display = table.getDisplay(); 
    116119            dragSourceImage = Image.win32_new(display, DWT.BITMAP, bitmap); 
  • dwt/dnd/Transfer.d

    r135 r136  
    138138    // If name is not in registry, add it and return assigned value. 
    139139    // If name already exists in registry, return its assigned value 
    140     TCHAR chFormatName = new TCHAR(0, formatName, true); 
     140    TCHAR* chFormatName = StrToTCHARz(0, formatName); 
    141141    return OS.RegisterClipboardFormat(chFormatName); 
    142142} 
  • dwt/dnd/TreeDragSourceEffect.d

    r135 r136  
    2020import dwt.widgets.Tree; 
    2121import dwt.widgets.TreeItem; 
     22 
     23import dwt.dnd.DragSourceEffect; 
     24import dwt.dnd.DragSourceEvent; 
    2225 
    2326/** 
     
    8285        if (dragSourceImage !is null) dragSourceImage.dispose(); 
    8386        dragSourceImage = null; 
    84         Tree tree = (Tree) control; 
     87        Tree tree = cast(Tree) control; 
    8588        TreeItem[] selection = tree.getSelection(); 
    8689        if (selection.length is 0) return null; 
     
    9093            Rectangle bounds = selection[0].getBounds(0); 
    9194            for (int i = 1; i < count; i++) { 
    92                 bounds = bounds.union(selection[i].getBounds(0)); 
     95                bounds = bounds.union_(selection[i].getBounds(0)); 
    9396            } 
    9497            int hDC = OS.GetDC(0); 
     
    9699            int bitmap = OS.CreateCompatibleBitmap(hDC, bounds.width, bounds.height); 
    97100            int hOldBitmap = OS.SelectObject(hDC1, bitmap); 
    98             RECT rect = new RECT()
     101            RECT rect
    99102            rect.right = bounds.width; 
    100103            rect.bottom = bounds.height; 
    101104            int hBrush = OS.GetStockObject(OS.WHITE_BRUSH); 
    102             OS.FillRect(hDC1, rect, hBrush); 
     105            OS.FillRect(hDC1, &rect, hBrush); 
    103106            for (int i = 0; i < count; i++) { 
    104107                TreeItem selected = selection[i]; 
  • dwt/internal/win32/OS.d

    r128 r136  
    46544654alias WINAPI.ImageList_Add ImageList_Add; 
    46554655alias WINAPI.ImageList_AddMasked ImageList_AddMasked; 
     4656alias WINAPI.ImageList_BeginDrag ImageList_BeginDrag; 
    46564657alias WINAPI.ImageList_Create ImageList_Create; 
    46574658alias WINAPI.ImageList_Destroy ImageList_Destroy; 
     4659alias WINAPI.ImageList_DragEnter ImageList_DragEnter; 
     4660alias WINAPI.ImageList_DragLeave ImageList_DragLeave; 
     4661alias WINAPI.ImageList_DragMove ImageList_DragMove; 
     4662alias WINAPI.ImageList_EndDrag ImageList_EndDrag; 
    46584663alias WINAPI.ImageList_GetIcon ImageList_GetIcon; 
    46594664alias WINAPI.ImageList_GetIconSize ImageList_GetIconSize; 
  • dwt/internal/win32/WINAPI.d

    r128 r136  
    16001600//     WINBOOL ImageList_Remove(HIMAGELIST, int); 
    16011601//     HICON ImageList_GetIcon(HIMAGELIST, int, UINT); 
    1602 //     WINBOOL ImageList_BeginDrag(HIMAGELIST, int, int, int); 
    1603 //     void ImageList_EndDrag(); 
    1604 //     WINBOOL ImageList_DragEnter(HWND, int, int); 
    1605 //     WINBOOL ImageList_DragLeave(HWND); 
    1606 //     WINBOOL ImageList_DragMove(int, int); 
     1602    WINBOOL ImageList_BeginDrag(HIMAGELIST, int, int, int); 
     1603    void ImageList_EndDrag(); 
     1604    WINBOOL ImageList_DragEnter(HWND, int, int); 
     1605    WINBOOL ImageList_DragLeave(HWND); 
     1606    WINBOOL ImageList_DragMove(int, int); 
    16071607//     WINBOOL ImageList_SetDragCursorImage(HIMAGELIST, int, int, int); 
    16081608//     WINBOOL ImageList_DragShowNolock(WINBOOL);