changeset 59:dc7db4338dbe

MenuItem
author Frank Benoit <benoit@tionex.de>
date Mon, 04 Feb 2008 13:39:10 +0100
parents 0aa35c03aced
children 6423053f6d3e
files dwt/DWTError.d dwt/DWTException.d dwt/graphics/TextLayout.d dwt/internal/win32/OS.d dwt/widgets/MenuItem.d
diffstat 5 files changed, 162 insertions(+), 180 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/DWTError.d	Mon Feb 04 12:57:51 2008 +0100
+++ b/dwt/DWTError.d	Mon Feb 04 13:39:10 2008 +0100
@@ -143,12 +143,12 @@
  */
 public void printStackTrace () {
     Stderr.formatln( "stacktrace follows (if feature compiled in)" );
-    foreach( msg; this ){
+    foreach( msg; info ){
         Stderr.formatln( "{}", msg );
     }
     if ( throwable !is null) {
         Stderr.formatln ("*** Stack trace of contained error ***"); //$NON-NLS-1$
-        foreach( msg; throwable ){
+        foreach( msg; throwable.info ){
             Stderr.formatln( "{}", msg );
         }
     }
--- a/dwt/DWTException.d	Mon Feb 04 12:57:51 2008 +0100
+++ b/dwt/DWTException.d	Mon Feb 04 13:39:10 2008 +0100
@@ -134,12 +134,12 @@
  */
 public void printStackTrace () {
     Stderr.formatln( "stacktrace follows (if feature compiled in)" );
-    foreach( msg; this ){
+    foreach( msg; info ){
         Stderr.formatln( "{}", msg );
     }
     if ( throwable !is null) {
         Stderr.formatln ("*** Stack trace of contained exception ***"); //$NON-NLS-1$
-        foreach( msg; throwable ){
+        foreach( msg; throwable.info ){
             Stderr.formatln( "{}", msg );
         }
     }
--- a/dwt/graphics/TextLayout.d	Mon Feb 04 12:57:51 2008 +0100
+++ b/dwt/graphics/TextLayout.d	Mon Feb 04 13:39:10 2008 +0100
@@ -200,7 +200,7 @@
 
 void breakRun(StyleItem run) {
     if (run.psla !is null) return;
-    wchar[] chars = StrToWCHARs( segmentsText[ run.start .. run.start + run.length ] );
+    wchar[] chars = StrToWCHARs( 0, segmentsText[ run.start .. run.start + run.length ] );
     auto hHeap = OS.GetProcessHeap();
     run.psla = cast(SCRIPT_LOGATTR*)OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, SCRIPT_LOGATTR.sizeof * chars.length);
     if (run.psla is null) DWT.error(DWT.ERROR_NO_HANDLES);
--- a/dwt/internal/win32/OS.d	Mon Feb 04 12:57:51 2008 +0100
+++ b/dwt/internal/win32/OS.d	Mon Feb 04 13:39:10 2008 +0100
@@ -4803,10 +4803,10 @@
     return ret;
 }
 
-public wchar[] StrToWCHARs(uint codepage , char[] sc) {
-    return StrToWCHARs( sc );
+public wchar[] StrToWCHARs(uint codepage , char[] sc, bool terminated = false ) {
+    return StrToWCHARs( sc, terminated );
 }
-public wchar[] StrToWCHARs(char[] sc) {
+public wchar[] StrToWCHARs(char[] sc, bool terminated = false ) {
     wchar[] ret;
     try{
         ret = toString16(sc);
@@ -4814,7 +4814,9 @@
         // do nothing
         ret = "";
     }
-
+    if( terminated ){
+        ret ~= \0;
+    }
     return ret;
 }
 
@@ -4823,7 +4825,7 @@
 }
 
 public wchar* StrToWCHARz(char[] sc, uint* length = null ) {
-    return toString16z( StrToWCHARs(sc));
+    return StrToWCHARs(sc, true ).ptr;
 }
 
 public char[] MBCSsToStr(char[] string, uint codepage = 0){
--- a/dwt/widgets/MenuItem.d	Mon Feb 04 12:57:51 2008 +0100
+++ b/dwt/widgets/MenuItem.d	Mon Feb 04 13:39:10 2008 +0100
@@ -12,31 +12,6 @@
  *******************************************************************************/
 module dwt.widgets.MenuItem;
 
-import dwt.widgets.Item;
-import dwt.widgets.Widget;
-import dwt.widgets.Menu;
-import dwt.widgets.Decorations;
-import dwt.internal.win32.OS;
-
-class MenuItem : Item {
-    Menu parent, menu;
-    HBITMAP hBitmap;
-    int accelerator;
-    int id;
-    public this (Widget parent, int style) {
-        super (parent, style);
-    }
-public bool getEnabled () ;
-public bool isEnabled () ;
-LRESULT wmCommandChild (int wParam, int lParam) ;
-LRESULT wmDrawChild (int wParam, int lParam) ;
-LRESULT wmMeasureChild (int wParam, int lParam) ;
-void fillAccel (ACCEL* accel) ;
-int widgetStyle () ;
-void fixMenus (Decorations newParent) ;
-void releaseMenu () ;
-}
-/++
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.events.ArmListener;
@@ -47,17 +22,17 @@
 import dwt.graphics.GCData;
 import dwt.graphics.Image;
 import dwt.graphics.Rectangle;
-import dwt.internal.win32.ACCEL;
-import dwt.internal.win32.DRAWITEMSTRUCT;
-import dwt.internal.win32.LRESULT;
-import dwt.internal.win32.MEASUREITEMSTRUCT;
-import dwt.internal.win32.MENUBARINFO;
-import dwt.internal.win32.MENUINFO;
-import dwt.internal.win32.MENUITEMINFO;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.TBBUTTONINFO;
-import dwt.internal.win32.TCHAR;
+
+import dwt.widgets.Item;
+import dwt.widgets.Widget;
+import dwt.widgets.Menu;
+import dwt.widgets.Decorations;
+import dwt.widgets.TypedListener;
+import dwt.widgets.Display;
+import dwt.widgets.Event;
+
+import dwt.dwthelper.utils;
 
 /**
  * Instances of this class represent a selectable user interface object
@@ -76,9 +51,10 @@
  * </p>
  */
 
-public class MenuItem extends Item {
+public class MenuItem : Item {
     Menu parent, menu;
-    int hBitmap, id, accelerator;
+    HBITMAP hBitmap;
+    int id, accelerator;
     /*
     * Feature in Windows.  On Windows 98, it is necessary
     * to add 4 pixels to the width of the image or the image
@@ -87,8 +63,12 @@
     * accelerator text.  The fix is to use smaller margins
     * everywhere but on Windows 98.
     */
-    final static int MARGIN_WIDTH = OS.IsWin95 ? 2 : 1;
-    final static int MARGIN_HEIGHT = OS.IsWin95 ? 2 : 1;
+    const static int MARGIN_WIDTH;
+    const static int MARGIN_HEIGHT;
+    static this() {
+        MARGIN_WIDTH = OS.IsWin95 ? 2 : 1;
+        MARGIN_HEIGHT = OS.IsWin95 ? 2 : 1;
+    }
 
 /**
  * Constructs a new instance of this class given its parent
@@ -124,7 +104,7 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public MenuItem (Menu parent, int style) {
+public this (Menu parent, int style) {
     super (parent, checkStyle (style));
     this.parent = parent;
     parent.createItem (this, parent.getItemCount ());
@@ -166,13 +146,13 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public MenuItem (Menu parent, int style, int index) {
+public this (Menu parent, int style, int index) {
     super (parent, checkStyle (style));
     this.parent = parent;
     parent.createItem (this, index);
 }
 
-MenuItem (Menu parent, Menu menu, int style, int index) {
+this (Menu parent, Menu menu, int style, int index) {
     super (parent, checkStyle (style));
     this.parent = parent;
     this.menu = menu;
@@ -283,7 +263,7 @@
     if (accelerator is 0 || !getEnabled ()) return;
     int fVirt = OS.FVIRTKEY;
     int key = accelerator & DWT.KEY_MASK;
-    int vKey = Display.untranslateKey (key);
+    auto vKey = Display.untranslateKey (key);
     if (vKey !is 0) {
         key = vKey;
     } else {
@@ -297,12 +277,12 @@
             case 27: key = OS.VK_ESCAPE; break;
             case 127: key = OS.VK_DELETE; break;
             default: {
-                key = Display.wcsToMbcs ((char) key);
+                key = Display.wcsToMbcs (cast(char) key);
                 if (key is 0) return;
-                if (OS.IsWinCE) {
-                    key = OS.CharUpper ((short) key);
+                static if (OS.IsWinCE) {
+                    key = cast(int) OS.CharUpper (cast(TCHAR*) key);
                 } else {
-                    vKey = OS.VkKeyScan ((short) key) & 0xFF;
+                    vKey = OS.VkKeyScan (cast(TCHAR) key) & 0xFF;
                     if (vKey is -1) {
                         fVirt = 0;
                     } else {
@@ -312,9 +292,9 @@
             }
         }
     }
-    accel.key = (short) key;
-    accel.cmd = (short) id;
-    accel.fVirt = (byte) fVirt;
+    accel.key = cast(short) key;
+    accel.cmd = cast(short) id;
+    accel.fVirt = cast(byte) fVirt;
     if ((accelerator & DWT.ALT) !is 0) accel.fVirt |= OS.FALT;
     if ((accelerator & DWT.SHIFT) !is 0) accel.fVirt |= OS.FSHIFT;
     if ((accelerator & DWT.CONTROL) !is 0) accel.fVirt |= OS.FCONTROL;
@@ -367,30 +347,30 @@
         if (shell.menuBar !is parent) {
             return new Rectangle (0, 0, 0, 0);
         }
-        int hwndShell = shell.handle;
-        MENUBARINFO info1 = new MENUBARINFO ();
+        auto hwndShell = shell.handle;
+        MENUBARINFO info1;
         info1.cbSize = MENUBARINFO.sizeof;
-        if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 1, info1)) {
+        if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 1, &info1)) {
             return new Rectangle (0, 0, 0, 0);
         }
-        MENUBARINFO info2 = new MENUBARINFO ();
+        MENUBARINFO info2;
         info2.cbSize = MENUBARINFO.sizeof;
-        if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, index + 1, info2)) {
+        if (!OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, index + 1, &info2)) {
             return new Rectangle (0, 0, 0, 0);
         }
-        int x = info2.left - info1.left;
-        int y = info2.top - info1.top;
-        int width = info2.right - info2.left;
-        int height = info2.bottom - info2.top;
+        int x = info2.rcBar.left - info1.rcBar.left;
+        int y = info2.rcBar.top - info1.rcBar.top;
+        int width = info2.rcBar.right - info2.rcBar.left;
+        int height = info2.rcBar.bottom - info2.rcBar.top;
         return new Rectangle (x, y, width, height);
     } else {
-        int hMenu = parent.handle;
-        RECT rect1 = new RECT ();
-        if (!OS.GetMenuItemRect (0, hMenu, 0, rect1)) {
+        auto hMenu = parent.handle;
+        RECT rect1;
+        if (!OS.GetMenuItemRect (null, hMenu, 0, &rect1)) {
             return new Rectangle (0, 0, 0, 0);
         }
-        RECT rect2 = new RECT ();
-        if (!OS.GetMenuItemRect (0, hMenu, index, rect2)) {
+        RECT rect2;
+        if (!OS.GetMenuItemRect (null, hMenu, index, &rect2)) {
             return new Rectangle (0, 0, 0, 0);
         }
         int x = rect2.left - rect1.left + 2;
@@ -418,25 +398,25 @@
  */
 public bool getEnabled () {
     checkWidget ();
-    if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) {
-        int hwndCB = parent.hwndCB;
-        TBBUTTONINFO info = new TBBUTTONINFO ();
+    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) {
+        auto hwndCB = parent.hwndCB;
+        TBBUTTONINFO info;
         info.cbSize = TBBUTTONINFO.sizeof;
         info.dwMask = OS.TBIF_STATE;
-        OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, info);
+        OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, &info);
         return (info.fsState & OS.TBSTATE_ENABLED) !is 0;
     }
-    int hMenu = parent.handle;
-    MENUITEMINFO info = new MENUITEMINFO ();
+    auto hMenu = parent.handle;
+    MENUITEMINFO info;
     info.cbSize = MENUITEMINFO.sizeof;
     info.fMask = OS.MIIM_STATE;
     bool success;
     if (OS.IsWinCE) {
         int index = parent.indexOf (this);
         if (index is -1) error (DWT.ERROR_CANNOT_GET_ENABLED);
-        success = OS.GetMenuItemInfo (hMenu, index, true, info);
+        success = cast(bool) OS.GetMenuItemInfo (hMenu, index, true, &info);
     } else {
-        success = OS.GetMenuItemInfo (hMenu, id, false, info);
+        success = cast(bool) OS.GetMenuItemInfo (hMenu, id, false, &info);
     }
     if (!success) error (DWT.ERROR_CANNOT_GET_ENABLED);
     return (info.fState & (OS.MFS_DISABLED | OS.MFS_GRAYED)) is 0;
@@ -461,7 +441,7 @@
     return menu;
 }
 
-override String getNameText () {
+override char[] getNameText () {
     if ((style & DWT.SEPARATOR) !is 0) return "|";
     return super.getNameText ();
 }
@@ -498,14 +478,14 @@
 public bool getSelection () {
     checkWidget ();
     if ((style & (DWT.CHECK | DWT.RADIO)) is 0) return false;
-    if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) return false;
-    int hMenu = parent.handle;
-    MENUITEMINFO info = new MENUITEMINFO ();
+    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) return false;
+    auto hMenu = parent.handle;
+    MENUITEMINFO info;
     info.cbSize = MENUITEMINFO.sizeof;
     info.fMask = OS.MIIM_STATE;
-    bool success = OS.GetMenuItemInfo (hMenu, id, false, info);
+    bool success = cast(bool) OS.GetMenuItemInfo (hMenu, id, false, &info);
     if (!success) error (DWT.ERROR_CANNOT_GET_SELECTION);
-    return (info.fState & OS.MFS_CHECKED) !is0;
+    return (info.fState & OS.MFS_CHECKED) !is 0;
 }
 
 /**
@@ -542,7 +522,7 @@
 }
 
 void releaseMenu () {
-    if (!OS.IsSP) setMenu (null);
+    if (!OS.IsSP_) setMenu (null);
     menu = null;
 }
 
@@ -554,8 +534,8 @@
 
 override void releaseWidget () {
     super.releaseWidget ();
-    if (hBitmap !is 0) OS.DeleteObject (hBitmap);
-    hBitmap = 0;
+    if (hBitmap !is null) OS.DeleteObject (hBitmap);
+    hBitmap = null;
     if (accelerator !is 0) {
         parent.destroyAccelerators ();
     }
@@ -683,27 +663,27 @@
  */
 public void setEnabled (bool enabled) {
     checkWidget ();
-    if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) {
-        int hwndCB = parent.hwndCB;
-        TBBUTTONINFO info = new TBBUTTONINFO ();
+    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) {
+        auto hwndCB = parent.hwndCB;
+        TBBUTTONINFO info;
         info.cbSize = TBBUTTONINFO.sizeof;
         info.dwMask = OS.TBIF_STATE;
-        OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, info);
+        OS.SendMessage (hwndCB, OS.TB_GETBUTTONINFO, id, &info);
         info.fsState &= ~OS.TBSTATE_ENABLED;
         if (enabled) info.fsState |= OS.TBSTATE_ENABLED;
-        OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, info);
+        OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, &info);
     } else {
-        int hMenu = parent.handle;
-        if (OS.IsWinCE) {
+        auto hMenu = parent.handle;
+        static if (OS.IsWinCE) {
             int index = parent.indexOf (this);
             if (index is -1) return;
             int uEnable = OS.MF_BYPOSITION | (enabled ? OS.MF_ENABLED : OS.MF_GRAYED);
             OS.EnableMenuItem (hMenu, index, uEnable);
         } else {
-            MENUITEMINFO info = new MENUITEMINFO ();
+            MENUITEMINFO info;
             info.cbSize = MENUITEMINFO.sizeof;
             info.fMask = OS.MIIM_STATE;
-            bool success = OS.GetMenuItemInfo (hMenu, id, false, info);
+            bool success = cast(bool) OS.GetMenuItemInfo (hMenu, id, false, &info);
             if (!success) error (DWT.ERROR_CANNOT_SET_ENABLED);
             int bits = OS.MFS_DISABLED | OS.MFS_GRAYED;
             if (enabled) {
@@ -713,7 +693,7 @@
                 if ((info.fState & bits) is bits) return;
                 info.fState |= bits;
             }
-            success = OS.SetMenuItemInfo (hMenu, id, false, info);
+            success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info);
             if (!success) {
                 /*
                 * Bug in Windows.  For some reason SetMenuItemInfo(),
@@ -752,33 +732,33 @@
     checkWidget ();
     if ((style & DWT.SEPARATOR) !is 0) return;
     super.setImage (image);
-    if (OS.IsWinCE) {
-        if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) {
+    static if (OS.IsWinCE) {
+        if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) {
             int hwndCB = parent.hwndCB;
-            TBBUTTONINFO info = new TBBUTTONINFO ();
+            TBBUTTONINFO info;
             info.cbSize = TBBUTTONINFO.sizeof;
             info.dwMask = OS.TBIF_IMAGE;
             info.iImage = parent.imageIndex (image);
-            OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, info);
+            OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, &info);
         }
         return;
     }
     if (OS.WIN32_VERSION < OS.VERSION (4, 10)) return;
-    MENUITEMINFO info = new MENUITEMINFO ();
+    MENUITEMINFO info;
     info.cbSize = MENUITEMINFO.sizeof;
     info.fMask = OS.MIIM_BITMAP;
     if (parent.foreground !is -1) {
         info.hbmpItem = OS.HBMMENU_CALLBACK;
     } else {
         if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
-            if (hBitmap !is 0) OS.DeleteObject (hBitmap);
-            info.hbmpItem = hBitmap = image !is null ? Display.create32bitDIB (image) : 0;
+            if (hBitmap !is null) OS.DeleteObject (hBitmap);
+            info.hbmpItem = hBitmap = image !is null ? Display.create32bitDIB (image) : null;
         } else {
             info.hbmpItem = OS.HBMMENU_CALLBACK;
         }
     }
-    int hMenu = parent.handle;
-    OS.SetMenuItemInfo (hMenu, id, false, info);
+    auto hMenu = parent.handle;
+    OS.SetMenuItemInfo (hMenu, id, false, &info);
     parent.redraw ();
 }
 
@@ -831,13 +811,13 @@
     this.menu = menu;
 
     /* Assign the new menu in the OS */
-    if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) {
-        if (OS.IsPPC) {
-            int hwndCB = parent.hwndCB;
-            int hMenu = menu is null ? 0 : menu.handle;
+    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) {
+        if (OS.IsPPC_) {
+            HWND hwndCB = parent.hwndCB;
+            HMENU hMenu = menu is null ? null : menu.handle;
             OS.SendMessage (hwndCB, OS.SHCMBM_SETSUBMENU, id, hMenu);
         }
-        if (OS.IsSP) error (DWT.ERROR_CANNOT_SET_MENU);
+        if (OS.IsSP_) error (DWT.ERROR_CANNOT_SET_MENU);
     } else {
         /*
         * Feature in Windows.  When SetMenuItemInfo () is used to
@@ -847,12 +827,12 @@
         * remove the item with RemoveMenu () which does not destroy
         * the submenu and then insert the item with InsertMenuItem ().
         */
-        int hMenu = parent.handle;
-        MENUITEMINFO info = new MENUITEMINFO ();
+        HMENU hMenu = parent.handle;
+        MENUITEMINFO info;
         info.cbSize = MENUITEMINFO.sizeof;
         info.fMask = OS.MIIM_DATA;
         int index = 0;
-        while (OS.GetMenuItemInfo (hMenu, index, true, info)) {
+        while (OS.GetMenuItemInfo (hMenu, index, true, &info)) {
             if (info.dwItemData is id) break;
             index++;
         }
@@ -869,29 +849,29 @@
         */
         if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) {
             info.fMask = OS.MIIM_BITMAP;
-            OS.GetMenuItemInfo (hMenu, index, true, info);
-            restoreBitmap = info.hbmpItem !is 0 || parent.foreground !is -1;
+            OS.GetMenuItemInfo (hMenu, index, true, &info);
+            restoreBitmap = info.hbmpItem !is null || parent.foreground !is -1;
             if (restoreBitmap) {
-                info.hbmpItem = 0;
-                success = OS.SetMenuItemInfo (hMenu, id, false, info);
+                info.hbmpItem = null;
+                success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info);
             }
         }
 
         int cch = 128;
-        int hHeap = OS.GetProcessHeap ();
+        auto hHeap = OS.GetProcessHeap ();
         int byteCount = cch * TCHAR.sizeof;
-        int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+        auto pszText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
         info.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA;
         info.dwTypeData = pszText;
         info.cch = cch;
-        success = OS.GetMenuItemInfo (hMenu, index, true, info);
+        success = cast(bool) OS.GetMenuItemInfo (hMenu, index, true, &info);
         if (menu !is null) {
             menu.cascade = this;
             info.fMask |= OS.MIIM_SUBMENU;
             info.hSubMenu = menu.handle;
         }
         OS.RemoveMenu (hMenu, index, OS.MF_BYPOSITION);
-        if (OS.IsWinCE) {
+        static if (OS.IsWinCE) {
             /*
             * On WinCE, InsertMenuItem() is not available.  The fix is to
             * use SetMenuItemInfo() but this call does not set the menu item
@@ -918,7 +898,7 @@
                 }
             }
         } else {
-            success = OS.InsertMenuItem (hMenu, index, true, info);
+            success = cast(bool) OS.InsertMenuItem (hMenu, index, true, &info);
             /*
             * Restore the bitmap that was removed to work around a problem
             * in GetMenuItemInfo() and menu items that have bitmaps set with
@@ -936,11 +916,11 @@
                             info.hbmpItem = OS.HBMMENU_CALLBACK;
                         }
                     }
-                    success = OS.SetMenuItemInfo (hMenu, id, false, info);
+                    success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info);
                 }
             }
         }
-        if (pszText !is 0) OS.HeapFree (hHeap, 0, pszText);
+        if (pszText !is null ) OS.HeapFree (hHeap, 0, pszText);
         if (!success) error (DWT.ERROR_CANNOT_SET_MENU);
     }
     parent.destroyAccelerators ();
@@ -971,22 +951,22 @@
 public void setSelection (bool selected) {
     checkWidget ();
     if ((style & (DWT.CHECK | DWT.RADIO)) is 0) return;
-    if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) return;
-    int hMenu = parent.handle;
+    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) return;
+    auto hMenu = parent.handle;
     if (OS.IsWinCE) {
         int index = parent.indexOf (this);
         if (index is -1) return;
         int uCheck = OS.MF_BYPOSITION | (selected ? OS.MF_CHECKED : OS.MF_UNCHECKED);
         OS.CheckMenuItem (hMenu, index, uCheck);
     } else {
-        MENUITEMINFO info = new MENUITEMINFO ();
+        MENUITEMINFO info;
         info.cbSize = MENUITEMINFO.sizeof;
         info.fMask = OS.MIIM_STATE;
-        bool success = OS.GetMenuItemInfo (hMenu, id, false, info);
+        bool success = cast(bool) OS.GetMenuItemInfo (hMenu, id, false, &info);
         if (!success) error (DWT.ERROR_CANNOT_SET_SELECTION);
         info.fState &= ~OS.MFS_CHECKED;
         if (selected) info.fState |= OS.MFS_CHECKED;
-        success = OS.SetMenuItemInfo (hMenu, id, false, info);
+        success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info);
         if (!success) {
             /*
             * Bug in Windows.  For some reason SetMenuItemInfo(),
@@ -1041,16 +1021,16 @@
  *
  * @see #setAccelerator
  */
-override public void setText (String string) {
+override public void setText (char[] string) {
     checkWidget ();
     if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     if ((style & DWT.SEPARATOR) !is 0) return;
-    if (text.equals (string)) return;
+    if (text==/*eq*/string ) return;
     super.setText (string);
-    int hHeap = OS.GetProcessHeap ();
-    int pszText = 0;
+    auto hHeap = OS.GetProcessHeap ();
+    TCHAR* pszText;
     bool success = false;
-    if ((OS.IsPPC || OS.IsSP) && parent.hwndCB !is 0) {
+    if ((OS.IsPPC_ || OS.IsSP_) && parent.hwndCB !is null) {
         /*
         * Bug in WinCE PPC.  Tool items on the menubar don't resize
         * correctly when the character '&' is used (even when it
@@ -1058,30 +1038,30 @@
         * the string.
         */
         if (string.indexOf ('&') !is -1) {
-            int length = string.length ();
-            char[] text = new char [length];
-            string.getChars( 0, length, text, 0);
+            int length_ = string.length;
+            char[] text = new char [length_];
+            string.getChars( 0, length_, text, 0);
             int i = 0, j = 0;
-            for (i=0; i<length; i++) {
+            for (i=0; i<length_; i++) {
                 if (text[i] !is '&') text [j++] = text [i];
             }
-            if (j < i) string = new String (text, 0, j);
+            if (j < i) string = text[ 0 .. j ].dup;
         }
         /* Use the character encoding for the default locale */
-        TCHAR buffer = new TCHAR (0, string, true);
-        int byteCount = buffer.length () * TCHAR.sizeof;
-        pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-        OS.MoveMemory (pszText, buffer, byteCount);
-        int hwndCB = parent.hwndCB;
-        TBBUTTONINFO info2 = new TBBUTTONINFO ();
+        TCHAR[] buffer = StrToTCHARs (0, string, true);
+        int byteCount = buffer.length * TCHAR.sizeof;
+        pszText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+        OS.MoveMemory (pszText, buffer.ptr, byteCount);
+        auto hwndCB = parent.hwndCB;
+        TBBUTTONINFO info2;
         info2.cbSize = TBBUTTONINFO.sizeof;
         info2.dwMask = OS.TBIF_TEXT;
         info2.pszText = pszText;
-        success = OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, info2) !is 0;
+        success = OS.SendMessage (hwndCB, OS.TB_SETBUTTONINFO, id, &info2) !is 0;
     } else {
-        MENUITEMINFO info = new MENUITEMINFO ();
+        MENUITEMINFO info;
         info.cbSize = MENUITEMINFO.sizeof;
-        int hMenu = parent.handle;
+        auto hMenu = parent.handle;
 
         /*
         * Bug in Windows 2000.  For some reason, when MIIM_TYPE is set
@@ -1092,19 +1072,19 @@
         bool restoreBitmap = false;
         if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) {
             info.fMask = OS.MIIM_BITMAP;
-            OS.GetMenuItemInfo (hMenu, id, false, info);
-            restoreBitmap = info.hbmpItem !is 0 || parent.foreground !is -1;
+            OS.GetMenuItemInfo (hMenu, id, false, &info);
+            restoreBitmap = info.hbmpItem !is null || parent.foreground !is -1;
         }
 
         /* Use the character encoding for the default locale */
-        TCHAR buffer = new TCHAR (0, string, true);
-        int byteCount = buffer.length () * TCHAR.sizeof;
-        pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-        OS.MoveMemory (pszText, buffer, byteCount);
+        TCHAR[] buffer = StrToTCHARs (0, string, true);
+        int byteCount = buffer.length * TCHAR.sizeof;
+        pszText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+        OS.MoveMemory (pszText, buffer.ptr, byteCount);
         info.fMask = OS.MIIM_TYPE;
         info.fType = widgetStyle ();
         info.dwTypeData = pszText;
-        success = OS.SetMenuItemInfo (hMenu, id, false, info);
+        success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info);
 
         /*
         * Restore the bitmap that was removed to work around a problem
@@ -1123,11 +1103,11 @@
                         info.hbmpItem = OS.HBMMENU_CALLBACK;
                     }
                 }
-                success = OS.SetMenuItemInfo (hMenu, id, false, info);
+                success = cast(bool) OS.SetMenuItemInfo (hMenu, id, false, &info);
             }
         }
     }
-    if (pszText !is 0) OS.HeapFree (hHeap, 0, pszText);
+    if (pszText !is null) OS.HeapFree (hHeap, 0, pszText);
     if (!success) error (DWT.ERROR_CANNOT_SET_TEXT);
     parent.redraw ();
 }
@@ -1164,35 +1144,35 @@
     Event event = new Event ();
     setInputState (event, DWT.Selection);
     postEvent (DWT.Selection, event);
-    return null;
+    return LRESULT.NULL;
 }
 
 LRESULT wmDrawChild (int wParam, int lParam) {
-    DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
-    OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
+    DRAWITEMSTRUCT* struct_ = cast(DRAWITEMSTRUCT*)lParam;
+    //OS.MoveMemory (struct_, lParam, DRAWITEMSTRUCT.sizeof);
     if (image !is null) {
         GCData data = new GCData();
         data.device = display;
-        GC gc = GC.win32_new (struct.hDC, data);
+        GC gc = GC.win32_new (struct_.hDC, data);
         /*
         * Bug in Windows.  When a bitmap is included in the
         * menu bar, the HDC seems to already include the left
         * coordinate.  The fix is to ignore this value when
         * the item is in a menu bar.
         */
-        int x = (parent.style & DWT.BAR) !is 0 ? MARGIN_WIDTH * 2 : struct.left;
+        int x = (parent.style & DWT.BAR) !is 0 ? MARGIN_WIDTH * 2 : struct_.rcItem.left;
         Image image = getEnabled () ? this.image : new Image (display, this.image, DWT.IMAGE_DISABLE);
-        gc.drawImage (image, x, struct.top + MARGIN_HEIGHT);
+        gc.drawImage (image, x, struct_.rcItem.top + MARGIN_HEIGHT);
         if (this.image !is image) image.dispose ();
         gc.dispose ();
     }
-    if (parent.foreground !is -1) OS.SetTextColor (struct.hDC, parent.foreground);
-    return null;
+    if (parent.foreground !is -1) OS.SetTextColor (struct_.hDC, parent.foreground);
+    return LRESULT.NULL;
 }
 
 LRESULT wmMeasureChild (int wParam, int lParam) {
-    MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT ();
-    OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof);
+    MEASUREITEMSTRUCT* struct_ = cast(MEASUREITEMSTRUCT*)lParam;
+    //OS.MoveMemory (struct_, lParam, MEASUREITEMSTRUCT.sizeof);
     int width = 0, height = 0;
     if (image !is null) {
         Rectangle rect = image.getBounds ();
@@ -1209,11 +1189,11 @@
         * to indicate that all items have a bitmap and then include
         * the width of the widest bitmap in WM_MEASURECHILD.
         */
-        MENUINFO lpcmi = new MENUINFO ();
+        MENUINFO lpcmi;
         lpcmi.cbSize = MENUINFO.sizeof;
         lpcmi.fMask = OS.MIM_STYLE;
-        int hMenu = parent.handle;
-        OS.GetMenuInfo (hMenu, lpcmi);
+        auto hMenu = parent.handle;
+        OS.GetMenuInfo (hMenu, &lpcmi);
         if ((lpcmi.dwStyle & OS.MNS_CHECKORBMP) is 0) {
             MenuItem [] items = parent.getItems ();
             for (int i=0; i<items.length; i++) {
@@ -1226,12 +1206,12 @@
         }
     }
     if (width !is 0 || height !is 0) {
-        struct.itemWidth = width + MARGIN_WIDTH * 2;
-        struct.itemHeight = height + MARGIN_HEIGHT * 2;
-        OS.MoveMemory (lParam, struct, MEASUREITEMSTRUCT.sizeof);
+        struct_.itemWidth = width + MARGIN_WIDTH * 2;
+        struct_.itemHeight = height + MARGIN_HEIGHT * 2;
+        //OS.MoveMemory (lParam, struct_, MEASUREITEMSTRUCT.sizeof);
     }
-    return null;
+    return LRESULT.NULL;
 }
 
 }
-++/
+