Changeset 134:fa7d7d66b9ed

Show
Ignore:
Timestamp:
02/12/08 21:22:44 (10 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Accessible

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/accessibility/Accessible.d

    r77 r134  
    1313module dwt.accessibility.Accessible; 
    1414 
    15 import dwt.widgets.Control; 
    16 //PORTING_TYPE 
    17 import dwt.accessibility.Accessible; 
    18 import dwt.accessibility.AccessibleControlListener; 
    19 import dwt.accessibility.AccessibleListener; 
    20 import dwt.accessibility.AccessibleTextListener; 
    21 import dwt.widgets.Control; 
    22 class  Accessible { 
    23     public static Accessible internal_new_Accessible(Control control) { 
    24         return new Accessible; 
    25     } 
    26 //     int AddRef(); 
    27 //     int Release(); 
    28 //     int QueryInterface(int, int); 
    29 //     void checkWidget(); 
    30 //     void setFocus(int); 
    31     void internal_dispose_Accessible(){ 
    32     } 
    33     int internal_WM_GETOBJECT(int, int){ 
    34         assert(false); 
    35         return 0; 
    36     } 
    37 //     bool isValidThread(); 
    38 //     int Next(int, int, int); 
    39 //     int Skip(int); 
    40     void addAccessibleListener(AccessibleListener){ 
    41     } 
    42     void addAccessibleControlListener(AccessibleControlListener){ 
    43     } 
    44 //     void addAccessibleTextListener(AccessibleTextListener); 
    45 //     void removeAccessibleListener(AccessibleListener); 
    46 //     void removeAccessibleControlListener(AccessibleControlListener); 
    47 //     void removeAccessibleTextListener(AccessibleTextListener); 
    48 //     int childIDToOs(int); 
    49 //     void textCaretMoved(int); 
    50 //     void textChanged(int, int, int); 
    51 //     void textSelectionChanged(); 
    52 //     int accDoDefaultAction(int); 
    53 //     int accHitTest(int, int, int); 
    54 //     int accLocation(int, int, int, int, int); 
    55 //     int osToChildID(int); 
    56 //     int accNavigate(int, int, int); 
    57 //     int accSelect(int, int); 
    58 //     int get_accChild(int, int); 
    59 //     int get_accChildCount(int); 
    60 //     int get_accDefaultAction(int, int); 
    61 //     int get_accDescription(int, int); 
    62 //     int get_accFocus(int); 
    63 //     int get_accHelp(int, int); 
    64 //     int get_accHelpTopic(int, int, int); 
    65 //     int get_accKeyboardShortcut(int, int); 
    66 //     int get_accName(int, int); 
    67 //     int get_accParent(int); 
    68 //     int get_accRole(int, int); 
    69 //     int osToRole(int); 
    70 //     int roleToOs(int); 
    71 //     int get_accSelection(int); 
    72 //     int get_accState(int, int); 
    73 //     int osToState(int); 
    74 //     int stateToOs(int); 
    75 //     int get_accValue(int, int); 
    76 //     int put_accName(int, int); 
    77 //     int put_accValue(int, int); 
    78 //     int Clone(int); 
    79 //     Control getControl(); 
    80 //     void selectionChanged(); 
    81 //     int Reset(); 
    82     //int refCount; 
    83     //int enumIndex; 
    84     //COMObject objIAccessible; 
    85     //COMObject objIEnumVARIANT; 
    86     //IAccessible iaccessible; 
    87     //Vector accessibleListeners; 
    88     //Vector accessibleControlListeners; 
    89     //Vector textListeners; 
    90     //Object[] variants; 
    91     //Control control; 
    92 } 
    93  
    94  
    95 /++ 
    9615import dwt.DWT; 
    9716import dwt.DWTException; 
    9817import dwt.internal.ole.win32.COM; 
    99 import dwt.internal.ole.win32.COMObject; 
    100 import dwt.internal.ole.win32.GUID; 
    101 import dwt.internal.ole.win32.IAccessible; 
    102 import dwt.internal.ole.win32.IEnumVARIANT; 
    103 import dwt.internal.ole.win32.VARIANT; 
     18import dwt.internal.ole.win32.OAIDL; 
     19import dwt.internal.ole.win32.ifs; 
     20import dwt.internal.ole.win32.extras; 
    10421import dwt.internal.win32.OS; 
    105 import dwt.internal.win32.TVITEM
     22import dwt.internal.DWTEventListener
    10623import dwt.ole.win32.OLE; 
     24import dwt.ole.win32.Variant; 
    10725import dwt.widgets.Control; 
    10826import dwt.widgets.Table; 
     
    11129import dwt.widgets.TreeItem; 
    11230import dwt.widgets.Widget; 
     31 
     32import dwt.accessibility.ACC; 
     33import dwt.accessibility.AccessibleControlListener; 
     34import dwt.accessibility.AccessibleListener; 
     35import dwt.accessibility.AccessibleTextListener; 
     36import dwt.accessibility.AccessibleControlEvent; 
     37import dwt.accessibility.AccessibleEvent; 
     38 
     39import dwt.dwthelper.utils; 
     40import tango.core.Array; 
     41import tango.core.Thread; 
    11342 
    11443/** 
     
    13564public class Accessible { 
    13665    int refCount = 0, enumIndex = 0; 
    137     COMObject objIAccessible, objIEnumVARIANT; 
     66    _IAccessibleImpl objIAccessible; 
     67    _IEnumVARIANTImpl objIEnumVARIANT; 
    13868    IAccessible iaccessible; 
    139     Vector accessibleListeners = new Vector()
    140     Vector accessibleControlListeners = new Vector()
    141     Vector textListeners = new Vector ()
     69    DWTEventListener[] accessibleListeners
     70    DWTEventListener[] accessibleControlListeners
     71    DWTEventListener[] textListeners
    14272    Object[] variants; 
    14373    Control control; 
    14474 
    145     Accessible(Control control) { 
     75    this(Control control) { 
    14676        this.control = control; 
    14777        int /*long*/[] ppvObject = new int /*long*/[1]; 
     
    14979         * AddRef has already been called on ppvObject by the callee and must be released by the caller. 
    15080         */ 
    151         int result = (int)/*64*/COM.CreateStdAccessibleObject(control.handle, COM.OBJID_CLIENT, COM.IIDIAccessible, ppvObject); 
     81        HRESULT result = COM.CreateStdAccessibleObject(control.handle, COM.OBJID_CLIENT, &COM.IIDIAccessible, cast(void**)&iaccessible); 
    15282        /* The object needs to be checked, because if the CreateStdAccessibleObject() 
    15383         * symbol is not found, the return value is S_OK. 
    15484         */ 
    155         if (ppvObject[0] is 0) return; 
     85        if (iaccessible is null) return; 
    15686        if (result !is COM.S_OK) OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result); 
    157         iaccessible = new IAccessible(ppvObject[0]); 
    158  
    159         objIAccessible = new COMObject(new int[] {2,0,0,1,3,5,8,1,1,2,2,2,2,2,2,2,3,2,1,1,2,2,5,3,3,1,2,2}) { 
    160             public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);} 
    161             public int /*long*/ method1(int /*long*/[] args) {return AddRef();} 
    162             public int /*long*/ method2(int /*long*/[] args) {return Release();} 
    163             // method3 GetTypeInfoCount - not implemented 
    164             // method4 GetTypeInfo - not implemented 
    165             // method5 GetIDsOfNames - not implemented 
    166             // method6 Invoke - not implemented 
    167             public int /*long*/ method7(int /*long*/[] args) {return get_accParent(args[0]);} 
    168             public int /*long*/ method8(int /*long*/[] args) {return get_accChildCount(args[0]);} 
    169             public int /*long*/ method9(int /*long*/[] args) {return get_accChild(args[0], args[1]);} 
    170             public int /*long*/ method10(int /*long*/[] args) {return get_accName(args[0], args[1]);} 
    171             public int /*long*/ method11(int /*long*/[] args) {return get_accValue(args[0], args[1]);} 
    172             public int /*long*/ method12(int /*long*/[] args) {return get_accDescription(args[0], args[1]);} 
    173             public int /*long*/ method13(int /*long*/[] args) {return get_accRole(args[0], args[1]);} 
    174             public int /*long*/ method14(int /*long*/[] args) {return get_accState(args[0], args[1]);} 
    175             public int /*long*/ method15(int /*long*/[] args) {return get_accHelp(args[0], args[1]);} 
    176             public int /*long*/ method16(int /*long*/[] args) {return get_accHelpTopic(args[0], args[1], args[2]);} 
    177             public int /*long*/ method17(int /*long*/[] args) {return get_accKeyboardShortcut(args[0], args[1]);} 
    178             public int /*long*/ method18(int /*long*/[] args) {return get_accFocus(args[0]);} 
    179             public int /*long*/ method19(int /*long*/[] args) {return get_accSelection(args[0]);} 
    180             public int /*long*/ method20(int /*long*/[] args) {return get_accDefaultAction(args[0], args[1]);} 
    181             public int /*long*/ method21(int /*long*/[] args) {return accSelect((int)/*64*/args[0], args[1]);} 
    182             public int /*long*/ method22(int /*long*/[] args) {return accLocation(args[0], args[1], args[2], args[3], args[4]);} 
    183             public int /*long*/ method23(int /*long*/[] args) {return accNavigate((int)/*64*/args[0], args[1], args[2]);} 
    184             public int /*long*/ method24(int /*long*/[] args) {return accHitTest((int)/*64*/args[0], (int)/*64*/args[1], args[2]);} 
    185             public int /*long*/ method25(int /*long*/[] args) {return accDoDefaultAction(args[0]);} 
    186             public int /*long*/ method26(int /*long*/[] args) {return put_accName(args[0], args[1]);} 
    187             public int /*long*/ method27(int /*long*/[] args) {return put_accValue(args[0], args[1]);} 
    188         }; 
    189  
     87 
     88        objIAccessible = new _IAccessibleImpl(this); 
     89 
     90//PORTING_FIXME: i don't understand this... 
     91/+ 
    19092        int /*long*/ ppVtable = objIAccessible.ppVtable; 
    19193        int /*long*/[] pVtable = new int /*long*/[1]; 
     
    210112        funcs[27] = COM.put_accValue_CALLBACK(funcs[27]); 
    211113        COM.MoveMemory(pVtable[0], funcs, OS.PTR_SIZEOF * funcs.length); 
    212  
    213         objIEnumVARIANT = new COMObject(new int[] {2,0,0,3,1,0,1}) { 
    214             public int /*long*/ method0(int /*long*/[] args) {return QueryInterface(args[0], args[1]);} 
    215             public int /*long*/ method1(int /*long*/[] args) {return AddRef();} 
    216             public int /*long*/ method2(int /*long*/[] args) {return Release();} 
    217             public int /*long*/ method3(int /*long*/[] args) {return Next((int)args[0], args[1], args[2]);} 
    218             public int /*long*/ method4(int /*long*/[] args) {return Skip((int)args[0]);} 
    219             public int /*long*/ method5(int /*long*/[] args) {return Reset();} 
    220             public int /*long*/ method6(int /*long*/[] args) {return Clone(args[0]);} 
    221         }; 
     114+/ 
     115 
     116        objIEnumVARIANT = new _IEnumVARIANTImpl(this) ; 
    222117        AddRef(); 
    223118    } 
     
    263158    public void addAccessibleListener(AccessibleListener listener) { 
    264159        checkWidget(); 
    265         if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 
    266         accessibleListeners.addElement(listener)
     160        if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); 
     161        accessibleListeners ~= listener
    267162    } 
    268163 
     
    290185    public void addAccessibleControlListener(AccessibleControlListener listener) { 
    291186        checkWidget(); 
    292         if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 
    293         accessibleControlListeners.addElement(listener)
     187        if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); 
     188        accessibleControlListeners ~= listener
    294189    } 
    295190 
     
    320215        checkWidget (); 
    321216        if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 
    322         textListeners.addElement (listener)
     217        textListeners ~= listener
    323218    } 
    324219 
     
    363258    public int /*long*/ internal_WM_GETOBJECT (int /*long*/ wParam, int /*long*/ lParam) { 
    364259        if (objIAccessible is null) return 0; 
    365         if ((int)/*64*/lParam is COM.OBJID_CLIENT) { 
     260        if (cast(int)/*64*/lParam is COM.OBJID_CLIENT) { 
    366261            /* LresultFromObject([in] riid, [in] wParam, [in] pAcc) 
    367262             * The argument pAcc is owned by the caller so reference count does not 
    368263             * need to be incremented. 
    369264             */ 
    370             return COM.LresultFromObject(COM.IIDIAccessible, wParam, objIAccessible.getAddress()); 
     265            return COM.LresultFromObject(&COM.IIDIAccessible, wParam, cast(IAccessible)objIAccessible); 
    371266        } 
    372267        return 0; 
     
    394289    public void removeAccessibleListener(AccessibleListener listener) { 
    395290        checkWidget(); 
    396         if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 
    397         accessibleListeners.removeElement(listener); 
     291        if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); 
     292        accessibleListeners.remove(listener); 
    398293    } 
    399294 
     
    419314    public void removeAccessibleControlListener(AccessibleControlListener listener) { 
    420315        checkWidget(); 
    421         if (listener is null) DWT.error(DWT.ERROR_NULL_ARGUMENT); 
    422         accessibleControlListeners.removeElement(listener); 
     316        if (listener is null) DWT.error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); 
     317        accessibleControlListeners.remove(listener); 
    423318    } 
    424319 
     
    447342        checkWidget (); 
    448343        if (listener is null) DWT.error (DWT.ERROR_NULL_ARGUMENT); 
    449         textListeners.removeElement (listener); 
     344        textListeners.remove (listener); 
    450345    } 
    451346 
     
    544439     * must be incremented before returning.  Caller is responsible for releasing ppvObject. 
    545440     */ 
    546     int QueryInterface(int /*long*/ iid, int /*long*/ ppvObject) { 
    547         if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    548         GUID guid = new GUID(); 
    549         COM.MoveMemory(guid, iid, GUID.sizeof); 
    550  
    551         if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) { 
    552             COM.MoveMemory(ppvObject, new int /*long*/[] { objIAccessible.getAddress()}, OS.PTR_SIZEOF); 
     441    HRESULT QueryInterface(REFIID riid, void** ppvObject) { 
     442        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
     443 
     444        if (COM.IsEqualGUID(riid, &COM.IIDIUnknown)) { 
     445            *ppvObject = cast(void*)cast(IUnknown)  objIAccessible; 
    553446            AddRef(); 
    554447            return COM.S_OK; 
    555448        } 
    556449 
    557         if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) { 
    558             COM.MoveMemory(ppvObject, new int /*long*/[] { objIAccessible.getAddress()}, OS.PTR_SIZEOF)
     450        if (COM.IsEqualGUID(riid, &COM.IIDIDispatch)) { 
     451            *ppvObject = cast(void*)cast(IDispatch) objIAccessible
    559452            AddRef(); 
    560453            return COM.S_OK; 
    561454        } 
    562455 
    563         if (COM.IsEqualGUID(guid, COM.IIDIAccessible)) { 
    564             COM.MoveMemory(ppvObject, new int /*long*/[] { objIAccessible.getAddress()}, OS.PTR_SIZEOF)
     456        if (COM.IsEqualGUID(riid, &COM.IIDIAccessible)) { 
     457            *ppvObject = cast(void*)cast(IAccessible) objIAccessible
    565458            AddRef(); 
    566459            return COM.S_OK; 
    567460        } 
    568461 
    569         if (COM.IsEqualGUID(guid, COM.IIDIEnumVARIANT)) { 
    570             COM.MoveMemory(ppvObject, new int /*long*/[] { objIEnumVARIANT.getAddress()}, OS.PTR_SIZEOF)
     462        if (COM.IsEqualGUID(riid, &COM.IIDIEnumVARIANT)) { 
     463            *ppvObject = cast(void*)cast(IEnumVARIANT) objIEnumVARIANT
    571464            AddRef(); 
    572465            enumIndex = 0; 
     
    574467        } 
    575468 
    576         int /*long*/[] ppv = new int /*long*/[1]; 
    577         int result = iaccessible.QueryInterface(guid, ppv); 
    578         COM.MoveMemory(ppvObject, ppv, OS.PTR_SIZEOF); 
     469        HRESULT result = iaccessible.QueryInterface(riid, ppvObject); 
    579470        return result; 
    580471    } 
    581472 
    582     int AddRef() { 
     473    ULONG AddRef() { 
    583474        refCount++; 
    584475        return refCount; 
    585476    } 
    586477 
    587     int Release() { 
     478    ULONG Release() { 
    588479        refCount--; 
    589480 
    590481        if (refCount is 0) { 
    591             if (objIAccessible !is null) 
    592                 objIAccessible.dispose(); 
    593482            objIAccessible = null; 
    594  
    595             if (objIEnumVARIANT !is null) 
    596                 objIEnumVARIANT.dispose(); 
    597483            objIEnumVARIANT = null; 
    598484        } 
     
    600486    } 
    601487 
    602     int accDoDefaultAction(int /*long*/ variant) { 
     488    HRESULT accDoDefaultAction(VARIANT variant) { 
    603489        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    604490        // Currently, we don't let the application override this. Forward to the proxy. 
     
    608494    } 
    609495 
    610     int accHitTest(int xLeft, int yTop, int /*long*/ pvarChild) { 
    611         if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    612         if (accessibleControlListeners.size() is 0) { 
     496    HRESULT accHitTest(LONG xLeft, LONG yTop, VARIANT* pvarChild) { 
     497        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
     498        if (accessibleControlListeners.length is 0) { 
    613499            return iaccessible.accHitTest(xLeft, yTop, pvarChild); 
    614500        } 
     
    618504        event.x = xLeft; 
    619505        event.y = yTop; 
    620         for (int i = 0; i < accessibleControlListeners.size(); i++) { 
    621             AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i)
     506        for (int i = 0; i < accessibleControlListeners.length; i++) { 
     507            AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]
    622508            listener.getChildAtPoint(event); 
    623509        } 
     
    626512            return iaccessible.accHitTest(xLeft, yTop, pvarChild); 
    627513        } 
    628         COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2)
    629         COM.MoveMemory(pvarChild + 8, new int[] { childIDToOs(childID) }, 4); 
    630         return COM.S_OK; 
    631     } 
    632  
    633     int accLocation(int /*long*/ pxLeft, int /*long*/ pyTop, int /*long*/ pcxWidth, int /*long*/ pcyHeight, int /*long*/ variant) { 
    634         if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    635         VARIANT v = new VARIANT()
    636         COM.MoveMemory(v, variant, VARIANT.sizeof); 
     514        pvarChild.vt = COM.VT_I4
     515        pvarChild.lVal = childIDToOs(childID); 
     516        return COM.S_OK; 
     517    } 
     518 
     519    HRESULT accLocation(LONG* pxLeft, LONG* pyTop, LONG* pcxWidth, LONG* pcyHeight, VARIANT variant) { 
     520        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
     521        VARIANT* v = &variant
     522        //COM.MoveMemory(v, variant, VARIANT.sizeof); 
    637523        if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 
    638524 
     
    641527        int code = iaccessible.accLocation(pxLeft, pyTop, pcxWidth, pcyHeight, variant); 
    642528        if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 
    643         if (accessibleControlListeners.size() is 0) return code; 
     529        if (accessibleControlListeners.length is 0) return code; 
    644530        if (code is COM.S_OK) { 
    645             int[] pLeft = new int[1], pTop = new int[1], pWidth = new int[1], pHeight = new int[1]
    646             COM.MoveMemory(pLeft, pxLeft, 4); 
    647             COM.MoveMemory(pTop, pyTop, 4); 
    648             COM.MoveMemory(pWidth, pcxWidth, 4); 
    649             COM.MoveMemory(pHeight, pcyHeight, 4); 
     531            int[1] pLeft, pTop, pWidth, pHeight
     532            COM.MoveMemory(pLeft.ptr, pxLeft, 4); 
     533            COM.MoveMemory(pTop.ptr, pyTop, 4); 
     534            COM.MoveMemory(pWidth.ptr, pcxWidth, 4); 
     535            COM.MoveMemory(pHeight.ptr, pcyHeight, 4); 
    650536            osLeft = pLeft[0]; osTop = pTop[0]; osWidth = pWidth[0]; osHeight = pHeight[0]; 
    651537        } 
    652538 
    653539        AccessibleControlEvent event = new AccessibleControlEvent(this); 
    654         event.childID = osToChildID((int)/*64*/v.lVal); 
     540        event.childID = osToChildID(cast(int)/*64*/v.lVal); 
    655541        event.x = osLeft; 
    656542        event.y = osTop; 
    657543        event.width = osWidth; 
    658544        event.height = osHeight; 
    659         for (int i = 0; i < accessibleControlListeners.size(); i++) { 
    660             AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i)
     545        for (int i = 0; i < accessibleControlListeners.length; i++) { 
     546            AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]
    661547            listener.getLocation(event); 
    662548        } 
    663         OS.MoveMemory(pxLeft, new int[] { event.x }, 4); 
    664         OS.MoveMemory(pyTop, new int[] { event.y }, 4); 
    665         OS.MoveMemory(pcxWidth, new int[] { event.width }, 4); 
    666         OS.MoveMemory(pcyHeight, new int[] { event.height }, 4); 
    667         return COM.S_OK; 
    668     } 
    669  
    670     int accNavigate(int navDir, int /*long*/ variant, int /*long*/ pvarEndUpAt) { 
     549        OS.MoveMemory(pxLeft, &event.x, 4); 
     550        OS.MoveMemory(pyTop, &event.y, 4); 
     551        OS.MoveMemory(pcxWidth, &event.width, 4); 
     552        OS.MoveMemory(pcyHeight, &event.height, 4); 
     553        return COM.S_OK; 
     554    } 
     555 
     556    HRESULT accNavigate(LONG navDir, VARIANT variant, VARIANT* pvarEndUpAt) { 
    671557        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    672558        // Currently, we don't let the application override this. Forward to the proxy. 
     
    676562    } 
    677563 
    678     int accSelect(int flagsSelect, int /*long*/ variant) { 
     564    HRESULT accSelect(LONG flagsSelect, VARIANT variant) { 
    679565        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    680566        // Currently, we don't let the application override this. Forward to the proxy. 
     
    688574     * must be incremented before returning.  The caller is responsible for releasing ppdispChild. 
    689575     */ 
    690     int get_accChild(int /*long*/ variant, int /*long*/ ppdispChild) { 
    691         if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    692         VARIANT v = new VARIANT()
    693         COM.MoveMemory(v, variant, VARIANT.sizeof); 
     576    HRESULT get_accChild(VARIANT variant, LPDISPATCH* ppdispChild) { 
     577        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
     578        VARIANT* v = &variant
     579        //COM.MoveMemory(v, variant, VARIANT.sizeof); 
    694580        if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 
    695         if (accessibleControlListeners.size() is 0) { 
     581        if (accessibleControlListeners.length is 0) { 
    696582            int code = iaccessible.get_accChild(variant, ppdispChild); 
    697583            if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 
     
    700586 
    701587        AccessibleControlEvent event = new AccessibleControlEvent(this); 
    702         event.childID = osToChildID((int)/*64*/v.lVal); 
    703         for (int i = 0; i < accessibleControlListeners.size(); i++) { 
    704             AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i)
     588        event.childID = osToChildID(cast(int)/*64*/v.lVal); 
     589        for (int i = 0; i < accessibleControlListeners.length; i++) { 
     590            AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]
    705591            listener.getChild(event); 
    706592        } 
     
    708594        if (accessible !is null) { 
    709595            accessible.AddRef(); 
    710             COM.MoveMemory(ppdispChild, new int /*long*/[] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF)
     596            *ppdispChild = accessible.objIAccessible
    711597            return COM.S_OK; 
    712598        } 
     
    714600    } 
    715601 
    716     int get_accChildCount(int /*long*/ pcountChildren) { 
     602    HRESULT get_accChildCount(LONG* pcountChildren) { 
    717603        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    718604 
     
    720606        int osChildCount = 0; 
    721607        int code = iaccessible.get_accChildCount(pcountChildren); 
    722         if (accessibleControlListeners.size() is 0) return code; 
     608        if (accessibleControlListeners.length is 0) return code; 
    723609        if (code is COM.S_OK) { 
    724             int[] pChildCount = new int[1]
    725             COM.MoveMemory(pChildCount, pcountChildren, 4); 
     610            int[1] pChildCount
     611            COM.MoveMemory(pChildCount.ptr, pcountChildren, 4); 
    726612            osChildCount = pChildCount[0]; 
    727613        } 
     
    730616        event.childID = ACC.CHILDID_SELF; 
    731617        event.detail = osChildCount; 
    732         for (int i = 0; i < accessibleControlListeners.size(); i++) { 
    733             AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i)
     618        for (int i = 0; i < accessibleControlListeners.length; i++) { 
     619            AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]
    734620            listener.getChildCount(event); 
    735621        } 
    736622 
    737         COM.MoveMemory(pcountChildren, new int[] { event.detail }, 4)
    738         return COM.S_OK; 
    739     } 
    740  
    741     int get_accDefaultAction(int /*long*/ variant, int /*long*/ pszDefaultAction) { 
    742         if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    743         VARIANT v = new VARIANT()
    744         COM.MoveMemory(v, variant, VARIANT.sizeof); 
     623        *pcountChildren = event.detail
     624        return COM.S_OK; 
     625    } 
     626 
     627    HRESULT get_accDefaultAction(VARIANT variant, BSTR* pszDefaultAction) { 
     628        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
     629        VARIANT* v = &variant
     630        //COM.MoveMemory(v, variant, VARIANT.sizeof); 
    745631        if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 
    746632 
    747633        /* Get the default defaultAction from the OS. */ 
    748         String osDefaultAction = null; 
     634        char[] osDefaultAction = null; 
    749635        int code = iaccessible.get_accDefaultAction(variant, pszDefaultAction); 
    750636        if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 
    751         if (accessibleControlListeners.size() is 0) return code; 
     637        if (accessibleControlListeners.length is 0) return code; 
    752638        if (code is COM.S_OK) { 
    753             int /*long*/[] pDefaultAction = new int /*long*/[1]; 
    754             COM.MoveMemory(pDefaultAction, pszDefaultAction, OS.PTR_SIZEOF); 
    755             int size = COM.SysStringByteLen(pDefaultAction[0]); 
    756             if (size > 0) { 
    757                 char[] buffer = new char[(size + 1) /2]; 
    758                 COM.MoveMemory(buffer, pDefaultAction[0], size); 
    759                 osDefaultAction = new String(buffer); 
    760             } 
     639            osDefaultAction = BSTRToStr( *pszDefaultAction, true ); 
    761640        } 
    762641 
    763642        AccessibleControlEvent event = new AccessibleControlEvent(this); 
    764         event.childID = osToChildID((int)/*64*/v.lVal); 
     643        event.childID = osToChildID(cast(int)/*64*/v.lVal); 
    765644        event.result = osDefaultAction; 
    766         for (int i = 0; i < accessibleControlListeners.size(); i++) { 
    767             AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i)
     645        for (int i = 0; i < accessibleControlListeners.length; i++) { 
     646            AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]
    768647            listener.getDefaultAction(event); 
    769648        } 
    770649        if (event.result is null) return code; 
    771         char[] data = (event.result + "\0").toCharArray(); 
    772         int /*long*/ ptr = COM.SysAllocString(data); 
    773         COM.MoveMemory(pszDefaultAction, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 
    774         return COM.S_OK; 
    775     } 
    776  
    777     int get_accDescription(int /*long*/ variant, int /*long*/ pszDescription) { 
    778         if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    779         VARIANT v = new VARIANT(); 
    780         COM.MoveMemory(v, variant, VARIANT.sizeof); 
     650        auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); 
     651        *pszDefaultAction = ptr; 
     652        return COM.S_OK; 
     653    } 
     654 
     655    HRESULT get_accDescription(VARIANT variant, BSTR* pszDescription) { 
     656        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
     657        VARIANT* v = &variant; 
     658        //COM.MoveMemory(v, variant, VARIANT.sizeof); 
    781659        if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 
    782660 
    783661        /* Get the default description from the OS. */ 
    784         String osDescription = null; 
     662        char[] osDescription = null; 
    785663        int code = iaccessible.get_accDescription(variant, pszDescription); 
    786664        if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 
    787665        // TEMPORARY CODE - process tree even if there are no apps listening 
    788         if (accessibleListeners.size() is 0 && !(control instanceof Tree)) return code; 
     666        if (accessibleListeners.length is 0 && !( null is cast(Tree)control )) return code; 
    789667        if (code is COM.S_OK) { 
    790             int /*long*/[] pDescription = new int /*long*/[1]; 
    791             COM.MoveMemory(pDescription, pszDescription, OS.PTR_SIZEOF); 
    792             int size = COM.SysStringByteLen(pDescription[0]); 
     668            int size = COM.SysStringByteLen(*pszDescription); 
    793669            if (size > 0) { 
    794                 char[] buffer = new char[(size + 1) /2]; 
    795                 COM.MoveMemory(buffer, pDescription[0], size); 
    796                 osDescription = new String(buffer); 
     670                size = (size + 1) /2; 
     671                osDescription = WCHARzToStr(*pszDescription, size); 
    797672            } 
    798673        } 
    799674 
    800675        AccessibleEvent event = new AccessibleEvent(this); 
    801         event.childID = osToChildID((int)/*64*/v.lVal); 
     676        event.childID = osToChildID(cast(int)/*64*/v.lVal); 
    802677        event.result = osDescription; 
    803678 
     
    807682         * header text and tree item text. */ 
    808683        if (v.lVal !is COM.CHILDID_SELF) { 
    809             if (control instanceof Tree) { 
    810                 Tree tree = (Tree) control; 
     684            if (auto tree = cast(Tree)control ) { 
    811685                int columnCount = tree.getColumnCount (); 
    812686                if (columnCount > 1) { 
    813                     int /*long*/ hwnd = control.handle, hItem = 0; 
     687                    HWND hwnd = control.handle; 
     688                    int hItem; 
    814689                    if (OS.COMCTL32_MAJOR >= 6) { 
    815690                        hItem = OS.SendMessage (hwnd, OS.TVM_MAPACCIDTOHTREEITEM, v.lVal, 0); 
     
    819694                    Widget widget = tree.getDisplay ().findWidget (hwnd, hItem); 
    820695                    event.result = ""; 
    821                     if (widget !is null && widget instanceof TreeItem) { 
    822                         TreeItem item = (TreeItem) widget; 
     696                    if (widget !is null ) if( auto item = cast(TreeItem) widget ) { 
    823697                        for (int i = 1; i < columnCount; i++) { 
    824                             event.result += tree.getColumn(i).getText() + ": " + item.getText(i); 
    825                             if (i + 1 < columnCount) event.result += ", "; 
     698                            event.result ~= tree.getColumn(i).getText() ~ ": " ~ item.getText(i); 
     699                            if (i + 1 < columnCount) event.result ~= ", "; 
    826700                        } 
    827701                    } 
     
    829703            } 
    830704        } 
    831         for (int i = 0; i < accessibleListeners.size(); i++) { 
    832             AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i)
     705        for (int i = 0; i < accessibleListeners.length; i++) { 
     706            AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]
    833707            listener.getDescription(event); 
    834708        } 
    835709        if (event.result is null) return code; 
    836         char[] data = (event.result + "\0").toCharArray(); 
    837         int /*long*/ ptr = COM.SysAllocString(data); 
    838         COM.MoveMemory(pszDescription, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 
     710        auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); 
     711        *pszDescription = ptr; 
    839712        return COM.S_OK; 
    840713    } 
     
    844717     * must be incremented before returning.  The caller is responsible for releasing pvarChild. 
    845718     */ 
    846     int get_accFocus(int /*long*/ pvarChild) { 
     719    HRESULT get_accFocus(VARIANT* pvarChild) { 
    847720        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    848721 
     
    850723        int osChild = ACC.CHILDID_NONE; 
    851724        int code = iaccessible.get_accFocus(pvarChild); 
    852         if (accessibleControlListeners.size() is 0) return code; 
     725        if (accessibleControlListeners.length is 0) return code; 
    853726        if (code is COM.S_OK) { 
    854             short[] pvt = new short[1]
    855             COM.MoveMemory(pvt, pvarChild, 2); 
     727            short[1] pvt
     728            COM.MoveMemory(pvt.ptr, pvarChild, 2); 
    856729            if (pvt[0] is COM.VT_I4) { 
    857                 int[] pChild = new int[1]
    858                 COM.MoveMemory(pChild, pvarChild + 8, 4); 
     730                int[1] pChild
     731                COM.MoveMemory(pChild.ptr, pvarChild + 8, 4); 
    859732                osChild = osToChildID(pChild[0]); 
    860733            } 
     
    863736        AccessibleControlEvent event = new AccessibleControlEvent(this); 
    864737        event.childID = osChild; 
    865         for (int i = 0; i < accessibleControlListeners.size(); i++) { 
    866             AccessibleControlListener listener = (AccessibleControlListener) accessibleControlListeners.elementAt(i)
     738        for (int i = 0; i < accessibleControlListeners.length; i++) { 
     739            AccessibleControlListener listener = cast(AccessibleControlListener) accessibleControlListeners[i]
    867740            listener.getFocus(event); 
    868741        } 
     
    870743        if (accessible !is null) { 
    871744            accessible.AddRef(); 
    872             COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2)
    873             COM.MoveMemory(pvarChild + 8, new int /*long*/[] { accessible.objIAccessible.getAddress() }, OS.PTR_SIZEOF)
     745            pvarChild.vt = COM.VT_DISPATCH
     746            pvarChild.byRef = cast(void*)cast(IDispatch)accessible.objIAccessible
    874747            return COM.S_OK; 
    875748        } 
    876749        int childID = event.childID; 
    877750        if (childID is ACC.CHILDID_NONE) { 
    878             COM.MoveMemory(pvarChild, new short[] { COM.VT_EMPTY }, 2)
     751            pvarChild.vt = COM.VT_EMPTY
    879752            return COM.S_FALSE; 
    880753        } 
    881754        if (childID is ACC.CHILDID_SELF) { 
    882755            AddRef(); 
    883             COM.MoveMemory(pvarChild, new short[] { COM.VT_DISPATCH }, 2)
    884             COM.MoveMemory(pvarChild + 8, new int /*long*/[] { objIAccessible.getAddress() }, OS.PTR_SIZEOF)
     756            pvarChild.vt = COM.VT_DISPATCH
     757            pvarChild.byRef = cast(void*)cast(IDispatch)objIAccessible
    885758            return COM.S_OK; 
    886759        } 
    887         COM.MoveMemory(pvarChild, new short[] { COM.VT_I4 }, 2)
    888         COM.MoveMemory(pvarChild + 8, new int[] { childIDToOs(childID) }, 4); 
    889         return COM.S_OK; 
    890     } 
    891  
    892     int get_accHelp(int /*long*/ variant, int /*long*/ pszHelp) { 
    893         if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    894         VARIANT v = new VARIANT()
    895         COM.MoveMemory(v, variant, VARIANT.sizeof); 
     760        pvarChild.vt = COM.VT_I4
     761        pvarChild.lVal = childIDToOs(childID); 
     762        return COM.S_OK; 
     763    } 
     764 
     765    HRESULT get_accHelp(VARIANT variant, BSTR* pszHelp) { 
     766        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
     767        VARIANT* v = &variant
     768        //COM.MoveMemory(v, variant, VARIANT.sizeof); 
    896769        if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 
    897770 
    898771        /* Get the default help string from the OS. */ 
    899         String osHelp = null; 
     772        char[] osHelp = null; 
    900773        int code = iaccessible.get_accHelp(variant, pszHelp); 
    901774        if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 
    902         if (accessibleListeners.size() is 0) return code; 
     775        if (accessibleListeners.length is 0) return code; 
    903776        if (code is COM.S_OK) { 
    904             int /*long*/[] pHelp = new int /*long*/[1]; 
    905             COM.MoveMemory(pHelp, pszHelp, OS.PTR_SIZEOF); 
    906             int size = COM.SysStringByteLen(pHelp[0]); 
    907             if (size > 0) { 
    908                 char[] buffer = new char[(size + 1) /2]; 
    909                 COM.MoveMemory(buffer, pHelp[0], size); 
    910                 osHelp = new String(buffer); 
    911             } 
     777            // the original SysString is clearuped and bstr set to null 
     778            osHelp = BSTRToStr(*pszHelp, true); 
    912779        } 
    913780 
    914781        AccessibleEvent event = new AccessibleEvent(this); 
    915         event.childID = osToChildID((int)/*64*/v.lVal); 
     782        event.childID = osToChildID(cast(int)/*64*/v.lVal); 
    916783        event.result = osHelp; 
    917         for (int i = 0; i < accessibleListeners.size(); i++) { 
    918             AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i)
     784        for (int i = 0; i < accessibleListeners.length; i++) { 
     785            AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]
    919786            listener.getHelp(event); 
    920787        } 
    921788        if (event.result is null) return code; 
    922         char[] data = (event.result + "\0").toCharArray(); 
    923         int /*long*/ ptr = COM.SysAllocString(data); 
    924         COM.MoveMemory(pszHelp, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 
    925         return COM.S_OK; 
    926     } 
    927  
    928     int get_accHelpTopic(int /*long*/ pszHelpFile, int /*long*/ variant, int /*long*/ pidTopic) { 
     789        auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); 
     790        *pszHelp = ptr; 
     791        return COM.S_OK; 
     792    } 
     793 
     794    HRESULT get_accHelpTopic(BSTR* pszHelpFile, VARIANT variant, LONG* pidTopic) { 
    929795        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    930796        // Currently, we don't let the application override this. Forward to the proxy. 
     
    934800    } 
    935801 
    936     int get_accKeyboardShortcut(int /*long*/ variant, int /*long*/ pszKeyboardShortcut) { 
    937         if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    938         VARIANT v = new VARIANT()
    939         COM.MoveMemory(v, variant, VARIANT.sizeof); 
     802    HRESULT get_accKeyboardShortcut(VARIANT variant, BSTR* pszKeyboardShortcut) { 
     803        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
     804        VARIANT* v = &variant
     805        //COM.MoveMemory(v, variant, VARIANT.sizeof); 
    940806        if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 
    941807 
    942808        /* Get the default keyboard shortcut from the OS. */ 
    943         String osKeyboardShortcut = null; 
     809        char[] osKeyboardShortcut = null; 
    944810        int code = iaccessible.get_accKeyboardShortcut(variant, pszKeyboardShortcut); 
    945811        if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 
    946         if (accessibleListeners.size() is 0) return code; 
     812        if (accessibleListeners.length is 0) return code; 
    947813        if (code is COM.S_OK) { 
    948             int /*long*/[] pKeyboardShortcut = new int /*long*/[1]; 
    949             COM.MoveMemory(pKeyboardShortcut, pszKeyboardShortcut, OS.PTR_SIZEOF); 
    950             int size = COM.SysStringByteLen(pKeyboardShortcut[0]); 
    951             if (size > 0) { 
    952                 char[] buffer = new char[(size + 1) /2]; 
    953                 COM.MoveMemory(buffer, pKeyboardShortcut[0], size); 
    954                 osKeyboardShortcut = new String(buffer); 
    955             } 
     814            // the original SysString is clearuped and bstr set to null 
     815            osKeyboardShortcut = BSTRToStr(*pszKeyboardShortcut, true); 
    956816        } 
    957817 
    958818        AccessibleEvent event = new AccessibleEvent(this); 
    959         event.childID = osToChildID((int)/*64*/v.lVal); 
     819        event.childID = osToChildID(cast(int)/*64*/v.lVal); 
    960820        event.result = osKeyboardShortcut; 
    961         for (int i = 0; i < accessibleListeners.size(); i++) { 
    962             AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i)
     821        for (int i = 0; i < accessibleListeners.length; i++) { 
     822            AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]
    963823            listener.getKeyboardShortcut(event); 
    964824        } 
    965825        if (event.result is null) return code; 
    966         char[] data = (event.result + "\0").toCharArray(); 
    967         int /*long*/ ptr = COM.SysAllocString(data); 
    968         COM.MoveMemory(pszKeyboardShortcut, new int /*long*/[] { ptr }, OS.PTR_SIZEOF); 
    969         return COM.S_OK; 
    970     } 
    971  
    972     int get_accName(int /*long*/ variant, int /*long*/ pszName) { 
    973         if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
    974         VARIANT v = new VARIANT(); 
    975         COM.MoveMemory(v, variant, VARIANT.sizeof); 
     826        auto ptr = COM.SysAllocString(StrToWCHARz(event.result)); 
     827        *pszKeyboardShortcut = ptr; 
     828        return COM.S_OK; 
     829    } 
     830 
     831    HRESULT get_accName(VARIANT variant, BSTR* pszName) { 
     832        if (iaccessible is null) return COM.CO_E_OBJNOTCONNECTED; 
     833        VARIANT* v = &variant; 
     834        //COM.MoveMemory(v, variant, VARIANT.sizeof); 
    976835        if ((v.vt & 0xFFFF) !is COM.VT_I4) return COM.E_INVALIDARG; 
    977836 
    978837        /* Get the default name from the OS. */ 
    979         String osName = null; 
     838        char[] osName = null; 
    980839        int code = iaccessible.get_accName(variant, pszName); 
    981840        if (code is COM.E_INVALIDARG) code = COM.S_FALSE; // proxy doesn't know about app childID 
    982         if (accessibleListeners.size() is 0) return code; 
     841        if (accessibleListeners.length is 0) return code; 
    983842        if (code is COM.S_OK) { 
    984             int /*long*/[] pName = new int /*long*/[1]; 
    985             COM.MoveMemory(pName, pszName, OS.PTR_SIZEOF); 
    986             int size = COM.SysStringByteLen(pName[0]); 
    987             if (size > 0) { 
    988                 char[] buffer = new char[(size + 1) /2]; 
    989                 COM.MoveMemory(buffer, pName[0], size); 
    990                 osName = new String(buffer); 
    991             } 
     843            // the original SysString is clearuped and bstr set to null 
     844            osName = BSTRToStr(*pszName, true); 
    992845        } 
    993846 
    994847        AccessibleEvent event = new AccessibleEvent(this); 
    995         event.childID = osToChildID((int)/*64*/v.lVal); 
     848        event.childID = osToChildID(cast(int)/*64*/v.lVal); 
    996849        event.result = osName; 
    997         for (int i = 0; i < accessibleListeners.size(); i++) { 
    998             AccessibleListener listener = (AccessibleListener) accessibleListeners.elementAt(i)
     850        for (int i = 0; i < accessibleListeners.length; i++) { 
     851            AccessibleListener listener = cast(AccessibleListener) accessibleListeners[i]
    999852            listener.getName(event); 
    1000853        } 
    1001854        if (event.result is nu