Changeset 59:dc7db4338dbe

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

MenuItem?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/DWTError.d

    r57 r59  
    144144public void printStackTrace () { 
    145145    Stderr.formatln( "stacktrace follows (if feature compiled in)" ); 
    146     foreach( msg; this ){ 
     146    foreach( msg; info ){ 
    147147        Stderr.formatln( "{}", msg ); 
    148148    } 
    149149    if ( throwable !is null) { 
    150150        Stderr.formatln ("*** Stack trace of contained error ***"); //$NON-NLS-1$ 
    151         foreach( msg; throwable ){ 
     151        foreach( msg; throwable.info ){ 
    152152            Stderr.formatln( "{}", msg ); 
    153153        } 
  • dwt/DWTException.d

    r57 r59  
    135135public void printStackTrace () { 
    136136    Stderr.formatln( "stacktrace follows (if feature compiled in)" ); 
    137     foreach( msg; this ){ 
     137    foreach( msg; info ){ 
    138138        Stderr.formatln( "{}", msg ); 
    139139    } 
    140140    if ( throwable !is null) { 
    141141        Stderr.formatln ("*** Stack trace of contained exception ***"); //$NON-NLS-1$ 
    142         foreach( msg; throwable ){ 
     142        foreach( msg; throwable.info ){ 
    143143            Stderr.formatln( "{}", msg ); 
    144144        } 
  • dwt/graphics/TextLayout.d

    r53 r59  
    201201void breakRun(StyleItem run) { 
    202202    if (run.psla !is null) return; 
    203     wchar[] chars = StrToWCHARs( segmentsText[ run.start .. run.start + run.length ] ); 
     203    wchar[] chars = StrToWCHARs( 0, segmentsText[ run.start .. run.start + run.length ] ); 
    204204    auto hHeap = OS.GetProcessHeap(); 
    205205    run.psla = cast(SCRIPT_LOGATTR*)OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, SCRIPT_LOGATTR.sizeof * chars.length); 
  • dwt/internal/win32/OS.d

    r56 r59  
    48044804} 
    48054805 
    4806 public wchar[] StrToWCHARs(uint codepage , char[] sc) { 
    4807     return StrToWCHARs( sc ); 
    4808 } 
    4809 public wchar[] StrToWCHARs(char[] sc) { 
     4806public wchar[] StrToWCHARs(uint codepage , char[] sc, bool terminated = false ) { 
     4807    return StrToWCHARs( sc, terminated ); 
     4808} 
     4809public wchar[] StrToWCHARs(char[] sc, bool terminated = false ) { 
    48104810    wchar[] ret; 
    48114811    try{ 
     
    48154815        ret = ""; 
    48164816    } 
    4817  
     4817    if( terminated ){ 
     4818        ret ~= \0; 
     4819    } 
    48184820    return ret; 
    48194821} 
     
    48244826 
    48254827public wchar* StrToWCHARz(char[] sc, uint* length = null ) { 
    4826     return toString16z( StrToWCHARs(sc))
     4828    return StrToWCHARs(sc, true ).ptr
    48274829} 
    48284830 
  • dwt/widgets/MenuItem.d

    r56 r59  
    1313module dwt.widgets.MenuItem; 
    1414 
    15 import dwt.widgets.Item; 
    16 import dwt.widgets.Widget; 
    17 import dwt.widgets.Menu; 
    18 import dwt.widgets.Decorations; 
    19 import dwt.internal.win32.OS; 
    20  
    21 class MenuItem : Item { 
    22     Menu parent, menu; 
    23     HBITMAP hBitmap; 
    24     int accelerator; 
    25     int id; 
    26     public this (Widget parent, int style) { 
    27         super (parent, style); 
    28     } 
    29 public bool getEnabled () ; 
    30 public bool isEnabled () ; 
    31 LRESULT wmCommandChild (int wParam, int lParam) ; 
    32 LRESULT wmDrawChild (int wParam, int lParam) ; 
    33 LRESULT wmMeasureChild (int wParam, int lParam) ; 
    34 void fillAccel (ACCEL* accel) ; 
    35 int widgetStyle () ; 
    36 void fixMenus (Decorations newParent) ; 
    37 void releaseMenu () ; 
    38 } 
    39 /++ 
    4015import dwt.DWT; 
    4116import dwt.DWTException; 
     
    4823import dwt.graphics.Image; 
    4924import dwt.graphics.Rectangle; 
    50 import dwt.internal.win32.ACCEL; 
    51 import dwt.internal.win32.DRAWITEMSTRUCT; 
    52 import dwt.internal.win32.LRESULT; 
    53 import dwt.internal.win32.MEASUREITEMSTRUCT; 
    54 import dwt.internal.win32.MENUBARINFO; 
    55 import dwt.internal.win32.MENUINFO; 
    56 import dwt.internal.win32.MENUITEMINFO; 
    5725import dwt.internal.win32.OS; 
    58 import dwt.internal.win32.RECT; 
    59 import dwt.internal.win32.TBBUTTONINFO; 
    60 import dwt.internal.win32.TCHAR; 
     26 
     27import dwt.widgets.Item; 
     28import dwt.widgets.Widget; 
     29import dwt.widgets.Menu; 
     30import dwt.widgets.Decorations; 
     31import dwt.widgets.TypedListener; 
     32import dwt.widgets.Display; 
     33import dwt.widgets.Event; 
     34 
     35import dwt.dwthelper.utils; 
    6136 
    6237/** 
     
    7752 */ 
    7853 
    79 public class MenuItem extends Item { 
     54public class MenuItem : Item { 
    8055    Menu parent, menu; 
    81     int hBitmap, id, accelerator; 
     56    HBITMAP hBitmap; 
     57    int id, accelerator; 
    8258    /* 
    8359    * Feature in Windows.  On Windows 98, it is necessary 
     
    8864    * everywhere but on Windows 98. 
    8965    */ 
    90     final static int MARGIN_WIDTH = OS.IsWin95 ? 2 : 1; 
    91     final static int MARGIN_HEIGHT = OS.IsWin95 ? 2 : 1; 
     66    const static int MARGIN_WIDTH; 
     67    const static int MARGIN_HEIGHT; 
     68    static this() { 
     69        MARGIN_WIDTH = OS.IsWin95 ? 2 : 1; 
     70        MARGIN_HEIGHT = OS.IsWin95 ? 2 : 1; 
     71    } 
    9272 
    9373/** 
     
    125105 * @see Widget#getStyle 
    126106 */ 
    127 public MenuItem (Menu parent, int style) { 
     107public this (Menu parent, int style) { 
    128108    super (parent, checkStyle (style)); 
    129109    this.parent = parent; 
     
    167147 * @see Widget#getStyle 
    168148 */ 
    169 public MenuItem (Menu parent, int style, int index) { 
     149public this (Menu parent, int style, int index) { 
    170150    super (parent, checkStyle (style)); 
    171151    this.parent = parent; 
     
    173153} 
    174154 
    175 MenuItem (Menu parent, Menu menu, int style, int index) { 
     155this (Menu parent, Menu menu, int style, int index) { 
    176156    super (parent, checkStyle (style)); 
    177157    this.parent = parent; 
     
    284264    int fVirt = OS.FVIRTKEY; 
    285265    int key = accelerator & DWT.KEY_MASK; 
    286     int vKey = Display.untranslateKey (key); 
     266    auto vKey = Display.untranslateKey (key); 
    287267    if (vKey !is 0) { 
    288268        key = vKey; 
     
    298278            case 127: key = OS.VK_DELETE; break; 
    299279            default: { 
    300                 key = Display.wcsToMbcs ((char) key); 
     280                key = Display.wcsToMbcs (cast(char) key); 
    301281                if (key is 0) return; 
    302                 if (OS.IsWinCE) { 
    303                     key = OS.CharUpper ((short) key); 
     282                static if (OS.IsWinCE) { 
     283                    key = cast(int) OS.CharUpper (cast(TCHAR*) key); 
    304284                } else { 
    305                     vKey = OS.VkKeyScan ((short) key) & 0xFF; 
     285                    vKey = OS.VkKeyScan (cast(TCHAR) key) & 0xFF; 
    306286                    if (vKey is -1) { 
    307287                        fVirt = 0; 
     
    313293        } 
    314294    } 
    315     accel.key = (short) key; 
    316     accel.cmd = (short) id; 
    317     accel.fVirt = (byte) fVirt; 
     295    accel.key = cast(short) key; 
     296    accel.cmd = cast(short) id; 
     297    accel.fVirt = cast(byte) fVirt; 
    318298    if ((accelerator & DWT.ALT) !is 0) accel.fVirt |= OS.FALT; 
    319299    if ((accelerator & DWT.SHIFT) !is 0) accel.fVirt |= OS.FSHIFT; 
     
    368348            return new Rectangle (0, 0, 0, 0); 
    369349        } 
    370         int hwndShell = shell.handle; 
    371         MENUBARINFO info1 = new MENUBARINFO ()
     350        auto hwndShell = shell.handle; 
     351        MENUBARINFO info1
    372352        info1.cbSize = MENUBARINFO.sizeof; 
    373         if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 1, info1)) { 
     353        if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 1, &info1)) { 
    374354            return new Rectangle (0, 0, 0, 0); 
    375355        } 
    376         MENUBARINFO info2 = new MENUBARINFO ()
     356        MENUBARINFO info2
    377357        info2.cbSize = MENUBARINFO.sizeof; 
    378         if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, index + 1, info2)) { 
     358        if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, index + 1, &info2)) { 
    379359            return new Rectangle (0, 0, 0, 0); 
    380360        } 
    381         int x = info2.left - info1.left; 
    382         int y = info2.top - info1.top; 
    383         int width = info2.right - info2.left; 
    384         int height = info2.bottom - info2.top; 
     361        int x = info2.rcBar.left - info1.rcBar.left; 
     362        int y = info2.rcBar.top - info1.rcBar.top; 
     363        int width = info2.rcBar.right - info2.rcBar.left; 
     364        int height = info2.rcBar.bottom - info2.rcBar.top; 
    385365        return new Rectangle (x, y, width, height); 
    386366    } else { 
    387         int hMenu = parent.handle; 
    388         RECT rect1 = new RECT ()
    389         if (!OS.GetMenuItemRect (0, hMenu, 0, rect1)) { 
     367        auto hMenu = parent.handle; 
     368        RECT rect1
     369        if (!OS.GetMenuItemRect (null, hMenu, 0, &rect1)) { 
    390370            return new Rectangle (0, 0, 0, 0); 
    391371        } 
    392         RECT rect2 = new RECT ()
    393         if (!OS.GetMenuItemRect (0, hMenu, index, rect2)) { 
     372        RECT rect2
     373        if (!OS.GetMenuItemRect (null, hMenu, index, &rect2)) { 
    394374            return new Rectangle (0, 0, 0, 0); 
    395375        } 
     
    419399public bool getEnabled () { 
    420400    checkWidget (); 
    421     if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) { 
    422         int hwndCB = parent.hwndCB; 
    423         TBBUTTONINFO info = new TBBUTTONINFO ()
     401    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) { 
     402        auto hwndCB = parent.hwndCB; 
     403        TBBUTTONINFO info
    424404        info.cbSize = TBBUTTONINFO.sizeof; 
    425405        info.dwMask = OS.TBIF_STATE; 
    426         OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, info); 
     406        OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, &info); 
    427407        return (info.fsState & OS.TBSTATE_ENABLED) !is 0; 
    428408    } 
    429     int hMenu = parent.handle; 
    430     MENUITEMINFO info = new MENUITEMINFO ()
     409    auto hMenu = parent.handle; 
     410    MENUITEMINFO info
    431411    info.cbSize = MENUITEMINFO.sizeof; 
    432412    info.fMask = OS.MIIM_STATE; 
     
    435415        int index = parent.indexOf (this); 
    436416        if (index is -1) error (DWT.ERROR_CANNOT_GET_ENABLED); 
    437         success = OS.GetMenuItemInfo (hMenu, index, true, info); 
     417        success = cast(bool) OS.GetMenuItemInfo (hMenu, index, true, &info); 
    438418    } else { 
    439         success = OS.GetMenuItemInfo (hMenu, id, false, info); 
     419        success = cast(bool) OS.GetMenuItemInfo (hMenu, id, false, &info); 
    440420    } 
    441421    if (!success) error (DWT.ERROR_CANNOT_GET_ENABLED); 
     
    462442} 
    463443 
    464 override String getNameText () { 
     444override char[] getNameText () { 
    465445    if ((style & DWT.SEPARATOR) !is 0) return "|"; 
    466446    return super.getNameText (); 
     
    499479    checkWidget (); 
    500480    if ((style & (DWT.CHECK | DWT.RADIO)) is 0) return false; 
    501     if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) return false; 
    502     int hMenu = parent.handle; 
    503     MENUITEMINFO info = new MENUITEMINFO ()
     481    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) return false; 
     482    auto hMenu = parent.handle; 
     483    MENUITEMINFO info
    504484    info.cbSize = MENUITEMINFO.sizeof; 
    505485    info.fMask = OS.MIIM_STATE; 
    506     bool success = OS.GetMenuItemInfo (hMenu, id, false, info); 
     486    bool success = cast(bool) OS.GetMenuItemInfo (hMenu, id, false, &info); 
    507487    if (!success) error (DWT.ERROR_CANNOT_GET_SELECTION); 
    508     return (info.fState & OS.MFS_CHECKED) !is0; 
     488    return (info.fState & OS.MFS_CHECKED) !is 0; 
    509489} 
    510490 
     
    543523 
    544524void releaseMenu () { 
    545     if (!OS.IsSP) setMenu (null); 
     525    if (!OS.IsSP_) setMenu (null); 
    546526    menu = null; 
    547527} 
     
    555535override void releaseWidget () { 
    556536    super.releaseWidget (); 
    557     if (hBitmap !is 0) OS.DeleteObject (hBitmap); 
    558     hBitmap = 0
     537    if (hBitmap !is null) OS.DeleteObject (hBitmap); 
     538    hBitmap = null
    559539    if (accelerator !is 0) { 
    560540        parent.destroyAccelerators (); 
     
    684664public void setEnabled (bool enabled) { 
    685665    checkWidget (); 
    686     if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) { 
    687         int hwndCB = parent.hwndCB; 
    688         TBBUTTONINFO info = new TBBUTTONINFO ()
     666    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) { 
     667        auto hwndCB = parent.hwndCB; 
     668        TBBUTTONINFO info
    689669        info.cbSize = TBBUTTONINFO.sizeof; 
    690670        info.dwMask = OS.TBIF_STATE; 
    691         OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, info); 
     671        OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, &info); 
    692672        info.fsState &= ~OS.TBSTATE_ENABLED; 
    693673        if (enabled) info.fsState |= OS.TBSTATE_ENABLED; 
    694         OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, info); 
     674        OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, &info); 
    695675    } else { 
    696         int hMenu = parent.handle; 
    697         if (OS.IsWinCE) { 
     676        auto hMenu = parent.handle; 
     677        static if (OS.IsWinCE) { 
    698678            int index = parent.indexOf (this); 
    699679            if (index is -1) return; 
     
    701681            OS.EnableMenuItem (hMenu, index, uEnable); 
    702682        } else { 
    703             MENUITEMINFO info = new MENUITEMINFO ()
     683            MENUITEMINFO info
    704684            info.cbSize = MENUITEMINFO.sizeof; 
    705685            info.fMask = OS.MIIM_STATE; 
    706             bool success = OS.GetMenuItemInfo (hMenu, id, false, info); 
     686            bool success = cast(bool) OS.GetMenuItemInfo (hMenu, id, false, &info); 
    707687            if (!success) error (DWT.ERROR_CANNOT_SET_ENABLED); 
    708688            int bits = OS.MFS_DISABLED | OS.MFS_GRAYED; 
     
    714694                info.fState |= bits; 
    715695            } 
    716             success = OS.SetMenuItemInfo (hMenu, id, false, info); 
     696            success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info); 
    717697            if (!success) { 
    718698                /* 
     
    753733    if ((style & DWT.SEPARATOR) !is 0) return; 
    754734    super.setImage (image); 
    755     if (OS.IsWinCE) { 
    756         if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) { 
     735    static if (OS.IsWinCE) { 
     736        if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) { 
    757737            int hwndCB = parent.hwndCB; 
    758             TBBUTTONINFO info = new TBBUTTONINFO ()
     738            TBBUTTONINFO info
    759739            info.cbSize = TBBUTTONINFO.sizeof; 
    760740            info.dwMask = OS.TBIF_IMAGE; 
    761741            info.iImage = parent.imageIndex (image); 
    762             OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, info); 
     742            OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, &info); 
    763743        } 
    764744        return; 
    765745    } 
    766746    if (OS.WIN32_VERSION < OS.VERSION (4, 10)) return; 
    767     MENUITEMINFO info = new MENUITEMINFO ()
     747    MENUITEMINFO info
    768748    info.cbSize = MENUITEMINFO.sizeof; 
    769749    info.fMask = OS.MIIM_BITMAP; 
     
    772752    } else { 
    773753        if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) { 
    774             if (hBitmap !is 0) OS.DeleteObject (hBitmap); 
    775             info.hbmpItem = hBitmap = image !is null ? Display.create32bitDIB (image) : 0
     754            if (hBitmap !is null) OS.DeleteObject (hBitmap); 
     755            info.hbmpItem = hBitmap = image !is null ? Display.create32bitDIB (image) : null
    776756        } else { 
    777757            info.hbmpItem = OS.HBMMENU_CALLBACK; 
    778758        } 
    779759    } 
    780     int hMenu = parent.handle; 
    781     OS.SetMenuItemInfo (hMenu, id, false, info); 
     760    auto hMenu = parent.handle; 
     761    OS.SetMenuItemInfo (hMenu, id, false, &info); 
    782762    parent.redraw (); 
    783763} 
     
    832812 
    833813    /* Assign the new menu in the OS */ 
    834     if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) { 
    835         if (OS.IsPPC) { 
    836             int hwndCB = parent.hwndCB; 
    837             int hMenu = menu is null ? 0 : menu.handle; 
     814    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) { 
     815        if (OS.IsPPC_) { 
     816            HWND hwndCB = parent.hwndCB; 
     817            HMENU hMenu = menu is null ? null : menu.handle; 
    838818            OS.SendMessage (hwndCB, OS.SHCMBM_SETSUBMENU, id, hMenu); 
    839819        } 
    840         if (OS.IsSP) error (DWT.ERROR_CANNOT_SET_MENU); 
     820        if (OS.IsSP_) error (DWT.ERROR_CANNOT_SET_MENU); 
    841821    } else { 
    842822        /* 
     
    848828        * the submenu and then insert the item with InsertMenuItem (). 
    849829        */ 
    850         int hMenu = parent.handle; 
    851         MENUITEMINFO info = new MENUITEMINFO ()
     830        HMENU hMenu = parent.handle; 
     831        MENUITEMINFO info
    852832        info.cbSize = MENUITEMINFO.sizeof; 
    853833        info.fMask = OS.MIIM_DATA; 
    854834        int index = 0; 
    855         while (OS.GetMenuItemInfo (hMenu, index, true, info)) { 
     835        while (OS.GetMenuItemInfo (hMenu, index, true, &info)) { 
    856836            if (info.dwItemData is id) break; 
    857837            index++; 
     
    870850        if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) { 
    871851            info.fMask = OS.MIIM_BITMAP; 
    872             OS.GetMenuItemInfo (hMenu, index, true, info); 
    873             restoreBitmap = info.hbmpItem !is 0 || parent.foreground !is -1; 
     852            OS.GetMenuItemInfo (hMenu, index, true, &info); 
     853            restoreBitmap = info.hbmpItem !is null || parent.foreground !is -1; 
    874854            if (restoreBitmap) { 
    875                 info.hbmpItem = 0
    876                 success = OS.SetMenuItemInfo (hMenu, id, false, info); 
     855                info.hbmpItem = null
     856                success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info); 
    877857            } 
    878858        } 
    879859 
    880860        int cch = 128; 
    881         int hHeap = OS.GetProcessHeap (); 
     861        auto hHeap = OS.GetProcessHeap (); 
    882862        int byteCount = cch * TCHAR.sizeof; 
    883         int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
     863        auto pszText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
    884864        info.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA; 
    885865        info.dwTypeData = pszText; 
    886866        info.cch = cch; 
    887         success = OS.GetMenuItemInfo (hMenu, index, true, info); 
     867        success = cast(bool) OS.GetMenuItemInfo (hMenu, index, true, &info); 
    888868        if (menu !is null) { 
    889869            menu.cascade = this; 
     
    892872        } 
    893873        OS.RemoveMenu (hMenu, index, OS.MF_BYPOSITION); 
    894         if (OS.IsWinCE) { 
     874        static if (OS.IsWinCE) { 
    895875            /* 
    896876            * On WinCE, InsertMenuItem() is not available.  The fix is to 
     
    919899            } 
    920900        } else { 
    921             success = OS.InsertMenuItem (hMenu, index, true, info); 
     901            success = cast(bool) OS.InsertMenuItem (hMenu, index, true, &info); 
    922902            /* 
    923903            * Restore the bitmap that was removed to work around a problem 
     
    937917                        } 
    938918                    } 
    939                     success = OS.SetMenuItemInfo (hMenu, id, false, info); 
     919                    success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info); 
    940920                } 
    941921            } 
    942922        } 
    943         if (pszText !is 0) OS.HeapFree (hHeap, 0, pszText); 
     923        if (pszText !is null ) OS.HeapFree (hHeap, 0, pszText); 
    944924        if (!success) error (DWT.ERROR_CANNOT_SET_MENU); 
    945925    } 
     
    972952    checkWidget (); 
    973953    if ((style & (DWT.CHECK | DWT.RADIO)) is 0) return; 
    974     if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) return; 
    975     int hMenu = parent.handle; 
     954    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) return; 
     955    auto hMenu = parent.handle; 
    976956    if (OS.IsWinCE) { 
    977957        int index = parent.indexOf (this); 
     
    980960        OS.CheckMenuItem (hMenu, index, uCheck); 
    981961    } else { 
    982         MENUITEMINFO info = new MENUITEMINFO ()
     962        MENUITEMINFO info
    983963        info.cbSize = MENUITEMINFO.sizeof; 
    984964        info.fMask = OS.MIIM_STATE; 
    985         bool success = OS.GetMenuItemInfo (hMenu, id, false, info); 
     965        bool success = cast(bool) OS.GetMenuItemInfo (hMenu, id, false, &info); 
    986966        if (!success) error (DWT.ERROR_CANNOT_SET_SELECTION); 
    987967        info.fState &= ~OS.MFS_CHECKED; 
    988968        if (selected) info.fState |= OS.MFS_CHECKED; 
    989         success = OS.SetMenuItemInfo (hMenu, id, false, info); 
     969        success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info); 
    990970        if (!success) { 
    991971            /* 
     
    10421022 * @see #setAccelerator 
    10431023 */ 
    1044 override public void setText (String string) { 
     1024override public void setText (char[] string) { 
    10451025    checkWidget (); 
    10461026    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
    10471027    if ((style & DWT.SEPARATOR) !is 0) return; 
    1048     if (text.equals (string)) return; 
     1028    if (text==/*eq*/string ) return; 
    10491029    super.setText (string); 
    1050     int hHeap = OS.GetProcessHeap (); 
    1051     int pszText = 0
     1030    auto hHeap = OS.GetProcessHeap (); 
     1031    TCHAR* pszText
    10521032    bool success = false; 
    1053     if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) { 
     1033    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) { 
    10541034        /* 
    10551035        * Bug in WinCE PPC.  Tool items on the menubar don't resize 
     
    10591039        */ 
    10601040        if (string.indexOf ('&') !is -1) { 
    1061             int length = string.length ()
    1062             char[] text = new char [length]; 
    1063             string.getChars( 0, length, text, 0); 
     1041            int length_ = string.length
     1042            char[] text = new char [length_]; 
     1043            string.getChars( 0, length_, text, 0); 
    10641044            int i = 0, j = 0; 
    1065             for (i=0; i<length; i++) { 
     1045            for (i=0; i<length_; i++) { 
    10661046                if (text[i] !is '&') text [j++] = text [i]; 
    10671047            } 
    1068             if (j < i) string = new String (text, 0, j)
     1048            if (j < i) string = text[ 0 .. j ].dup
    10691049        } 
    10701050        /* Use the character encoding for the default locale */ 
    1071         TCHAR buffer = new TCHAR (0, string, true); 
    1072         int byteCount = buffer.length () * TCHAR.sizeof; 
    1073         pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
    1074         OS.MoveMemory (pszText, buffer, byteCount); 
    1075         int hwndCB = parent.hwndCB; 
    1076         TBBUTTONINFO info2 = new TBBUTTONINFO ()
     1051        TCHAR[] buffer = StrToTCHARs (0, string, true); 
     1052        int byteCount = buffer.length * TCHAR.sizeof; 
     1053        pszText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
     1054        OS.MoveMemory (pszText, buffer.ptr, byteCount); 
     1055        auto hwndCB = parent.hwndCB; 
     1056        TBBUTTONINFO info2
    10771057        info2.cbSize = TBBUTTONINFO.sizeof; 
    10781058        info2.dwMask = OS.TBIF_TEXT; 
    10791059        info2.pszText = pszText; 
    1080         success = OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, info2) !is 0; 
     1060        success = OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, &info2) !is 0; 
    10811061    } else { 
    1082         MENUITEMINFO info = new MENUITEMINFO ()
     1062        MENUITEMINFO info
    10831063        info.cbSize = MENUITEMINFO.sizeof; 
    1084         int hMenu = parent.handle; 
     1064        auto hMenu = parent.handle; 
    10851065 
    10861066        /* 
     
    10931073        if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) { 
    10941074            info.fMask = OS.MIIM_BITMAP; 
    1095             OS.GetMenuItemInfo (hMenu, id, false, info); 
    1096             restoreBitmap = info.hbmpItem !is 0 || parent.foreground !is -1; 
     1075            OS.GetMenuItemInfo (hMenu, id, false, &info); 
     1076            restoreBitmap = info.hbmpItem !is null || parent.foreground !is -1; 
    10971077        } 
    10981078 
    10991079        /* Use the character encoding for the default locale */ 
    1100         TCHAR buffer = new TCHAR (0, string, true); 
    1101         int byteCount = buffer.length () * TCHAR.sizeof; 
    1102         pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
    1103         OS.MoveMemory (pszText, buffer, byteCount); 
     1080        TCHAR[] buffer = StrToTCHARs (0, string, true); 
     1081        int byteCount = buffer.length * TCHAR.sizeof; 
     1082        pszText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
     1083        OS.MoveMemory (pszText, buffer.ptr, byteCount); 
    11041084        info.fMask = OS.MIIM_TYPE; 
    11051085        info.fType = widgetStyle (); 
    11061086        info.dwTypeData = pszText; 
    1107         success = OS.SetMenuItemInfo (hMenu, id, false, info); 
     1087        success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info); 
    11081088 
    11091089        /* 
     
    11241104                    } 
    11251105                } 
    1126                 success = OS.SetMenuItemInfo (hMenu, id, false, info); 
     1106                success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info); 
    11271107            } 
    11281108        } 
    11291109    } 
    1130     if (pszText !is 0) OS.HeapFree (hHeap, 0, pszText); 
     1110    if (pszText !is null) OS.HeapFree (hHeap, 0, pszText); 
    11311111    if (!success) error (DWT.ERROR_CANNOT_SET_TEXT); 
    11321112    parent.redraw (); 
     
    11651145    setInputState (event, DWT.Selection); 
    11661146    postEvent (DWT.Selection, event); 
    1167     return null
     1147    return LRESULT.NULL
    11681148} 
    11691149 
    11701150LRESULT wmDrawChild (int wParam, int lParam) { 
    1171     DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ()
    1172     OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof); 
     1151    DRAWITEMSTRUCT* struct_ = cast(DRAWITEMSTRUCT*)lParam
     1152    //OS.MoveMemory (struct_, lParam, DRAWITEMSTRUCT.sizeof); 
    11731153    if (image !is null) { 
    11741154        GCData data = new GCData(); 
    11751155        data.device = display; 
    1176         GC gc = GC.win32_new (struct.hDC, data); 
     1156        GC gc = GC.win32_new (struct_.hDC, data); 
    11771157        /* 
    11781158        * Bug in Windows.  When a bitmap is included in the 
     
    11811161        * the item is in a menu bar. 
    11821162        */ 
    1183         int x = (parent.style & DWT.BAR) !is 0 ? MARGIN_WIDTH * 2 : struct.left; 
     1163        int x = (parent.style & DWT.BAR) !is 0 ? MARGIN_WIDTH * 2 : struct_.rcItem.left; 
    11841164        Image image = getEnabled () ? this.image : new Image (display, this.image, DWT.IMAGE_DISABLE); 
    1185         gc.drawImage (image, x, struct.top + MARGIN_HEIGHT); 
     1165        gc.drawImage (image, x, struct_.rcItem.top + MARGIN_HEIGHT); 
    11861166        if (this.image !is image) image.dispose (); 
    11871167        gc.dispose (); 
    11881168    } 
    1189     if (parent.foreground !is -1) OS.SetTextColor (struct.hDC, parent.foreground); 
    1190     return null
     1169    if (parent.foreground !is -1) OS.SetTextColor (struct_.hDC, parent.foreground); 
     1170    return LRESULT.NULL
    11911171} 
    11921172 
    11931173LRESULT wmMeasureChild (int wParam, int lParam) { 
    1194     MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT ()
    1195     OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof); 
     1174    MEASUREITEMSTRUCT* struct_ = cast(MEASUREITEMSTRUCT*)lParam
     1175    //OS.MoveMemory (struct_, lParam, MEASUREITEMSTRUCT.sizeof); 
    11961176    int width = 0, height = 0; 
    11971177    if (image !is null) { 
     
    12101190        * the width of the widest bitmap in WM_MEASURECHILD. 
    12111191        */ 
    1212         MENUINFO lpcmi = new MENUINFO ()
     1192        MENUINFO lpcmi
    12131193        lpcmi.cbSize = MENUINFO.sizeof; 
    12141194        lpcmi.fMask = OS.MIM_STYLE; 
    1215         int hMenu = parent.handle; 
    1216         OS.GetMenuInfo (hMenu, lpcmi); 
     1195        auto hMenu = parent.handle; 
     1196        OS.GetMenuInfo (hMenu, &lpcmi); 
    12171197        if ((lpcmi.dwStyle & OS.MNS_CHECKORBMP) is 0) { 
    12181198            MenuItem [] items = parent.getItems (); 
     
    12271207    } 
    12281208    if (width !is 0 || height !is 0) { 
    1229         struct.itemWidth = width + MARGIN_WIDTH * 2; 
    1230         struct.itemHeight = height + MARGIN_HEIGHT * 2; 
    1231         OS.MoveMemory (lParam, struct, MEASUREITEMSTRUCT.sizeof); 
    1232     } 
    1233     return null
    1234 } 
    1235  
    1236 } 
    1237 ++/ 
     1209        struct_.itemWidth = width + MARGIN_WIDTH * 2; 
     1210        struct_.itemHeight = height + MARGIN_HEIGHT * 2; 
     1211        //OS.MoveMemory (lParam, struct_, MEASUREITEMSTRUCT.sizeof); 
     1212    } 
     1213    return LRESULT.NULL
     1214} 
     1215 
     1216} 
     1217