changeset 56:dcb2e04003ac

Menu
author Frank Benoit <benoit@tionex.de>
date Mon, 04 Feb 2008 12:34:19 +0100
parents 1bc7c2131617
children 41dbc4d9faab
files dwt/internal/win32/OS.d dwt/internal/win32/WINTYPES.d dwt/widgets/Menu.d dwt/widgets/MenuItem.d tango_sys_win32/Types.di
diffstat 5 files changed, 250 insertions(+), 214 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/win32/OS.d	Mon Feb 04 11:08:30 2008 +0100
+++ b/dwt/internal/win32/OS.d	Mon Feb 04 12:34:19 2008 +0100
@@ -67,12 +67,13 @@
 
     version(WinCE){
         public const static BOOL IsWinCE = true;
+        public static const BOOL IsHPC = false; //todo
     }else{
         public const static BOOL IsWinCE = false;
+        public static const BOOL IsHPC = false;
     }
 
     public static const BOOL IsPPC_ = false;
-    public static const BOOL IsHPC = false;
 
     // PORTING_FIXME, is it Windows WFSP?
     public static const BOOL IsSP_ = false;
@@ -770,7 +771,7 @@
     public static const int GW_HWNDNEXT = 0x2;
     public static const int GW_HWNDPREV = 0x3;
     public static const int GW_OWNER = 0x4;
-    public static const int HBMMENU_CALLBACK = 0xffffffff;
+    public static const HBITMAP HBMMENU_CALLBACK = cast(HBITMAP) 0xffffffff;
     public static const int HCBT_CREATEWND = 3;
     public static const int HCF_HIGHCONTRASTON = 0x1;
     public static const int HDF_BITMAP = 0x2000;
--- a/dwt/internal/win32/WINTYPES.d	Mon Feb 04 11:08:30 2008 +0100
+++ b/dwt/internal/win32/WINTYPES.d	Mon Feb 04 12:34:19 2008 +0100
@@ -946,37 +946,37 @@
 * calls fail when the struct size is too large.  The fix is to ensure
 * that the correct struct size is used for the Windows platform.
 */
-struct MENUITEMINFOA
-{
-    UINT    cbSize;
-    UINT    fMask;
-    UINT    fType;          // used if MIIM_TYPE
-    UINT    fState;         // used if MIIM_STATE
-    UINT    wID;            // used if MIIM_ID
-    HMENU   hSubMenu;       // used if MIIM_SUBMENU
-    HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS
-    HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS
-    DWORD   dwItemData;     // used if MIIM_DATA
-    LPSTR   dwTypeData;     // used if MIIM_TYPE
-    UINT    cch;            // used if MIIM_TYPE
-    HBITMAP hbmpItem;
-}
-alias MENUITEMINFOA* PMENUITEMINFOA, LPMENUITEMINFOA;
-struct MENUITEMINFOW
-{
-    UINT    cbSize;
-    UINT    fMask;
-    UINT    fType;          // used if MIIM_TYPE
-    UINT    fState;         // used if MIIM_STATE
-    UINT    wID;            // used if MIIM_ID
-    HMENU   hSubMenu;       // used if MIIM_SUBMENU
-    HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS
-    HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS
-    DWORD   dwItemData;     // used if MIIM_DATA
-    LPWSTR  dwTypeData;     // used if MIIM_TYPE
-    UINT    cch;            // used if MIIM_TYPE
-    HBITMAP hbmpItem;
-}   alias MENUITEMINFOW* PMENUITEMINFOW, LPMENUITEMINFOW;
+// struct MENUITEMINFOA
+// {
+//     UINT    cbSize;
+//     UINT    fMask;
+//     UINT    fType;          // used if MIIM_TYPE
+//     UINT    fState;         // used if MIIM_STATE
+//     UINT    wID;            // used if MIIM_ID
+//     HMENU   hSubMenu;       // used if MIIM_SUBMENU
+//     HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS
+//     HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS
+//     DWORD   dwItemData;     // used if MIIM_DATA
+//     LPSTR   dwTypeData;     // used if MIIM_TYPE
+//     UINT    cch;            // used if MIIM_TYPE
+//     HBITMAP hbmpItem;
+// }
+// alias MENUITEMINFOA* PMENUITEMINFOA, LPMENUITEMINFOA;
+// struct MENUITEMINFOW
+// {
+//     UINT    cbSize;
+//     UINT    fMask;
+//     UINT    fType;          // used if MIIM_TYPE
+//     UINT    fState;         // used if MIIM_STATE
+//     UINT    wID;            // used if MIIM_ID
+//     HMENU   hSubMenu;       // used if MIIM_SUBMENU
+//     HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS
+//     HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS
+//     DWORD   dwItemData;     // used if MIIM_DATA
+//     LPWSTR  dwTypeData;     // used if MIIM_TYPE
+//     UINT    cch;            // used if MIIM_TYPE
+//     HBITMAP hbmpItem;
+// }   alias MENUITEMINFOW* PMENUITEMINFOW, LPMENUITEMINFOW;
 //version(ANSI){
 //    alias MENUITEMINFOA MENUITEMINFO;
 //}else{
@@ -1810,8 +1810,8 @@
 }
 alias SHITEMID* LPCSHITEMID;
 
-version(WinCE)
-{
+//version(WinCE)
+//{
     struct SHMENUBARINFO {
         int cbSize;
         HWND hwndParent;
@@ -1838,7 +1838,7 @@
         DWORD dwImDataSize;
         VOID *pvImData;
     }
-} // end of version WinCE
+//} // end of version WinCE
 
 //struct SIZE {
 //  LONG cx;
--- a/dwt/widgets/Menu.d	Mon Feb 04 11:08:30 2008 +0100
+++ b/dwt/widgets/Menu.d	Mon Feb 04 12:34:19 2008 +0100
@@ -12,31 +12,6 @@
  *******************************************************************************/
 module dwt.widgets.Menu;
 
-import dwt.widgets.Widget;
-import dwt.widgets.Decorations;
-import dwt.widgets.MenuItem;
-import dwt.internal.win32.OS;
-
-class Menu : Widget {
-    int x, y;
-    HBRUSH hBrush;
-    HWND hwndCB;
-    int id0, id1;
-    MenuItem cascade;
-    Decorations parent;
-    HMENU handle;
-    this( Widget, int );
-public void setLocation (int x, int y) ;
-public void setVisible (bool visible) ;
-void update ();
-void _setVisible (bool visible) ;
-public Menu getParentMenu () ;
-public MenuItem [] getItems () ;
-void fixMenus (Decorations newParent) ;
-public bool isEnabled () ;
-public bool getEnabled () ;
-}
-/++
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.events.HelpListener;
@@ -46,15 +21,16 @@
 import dwt.graphics.Point;
 import dwt.graphics.Rectangle;
 import dwt.internal.ImageList;
-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.SHMENUBARINFO;
-import dwt.internal.win32.TBBUTTON;
-import dwt.internal.win32.TBBUTTONINFO;
-import dwt.internal.win32.TCHAR;
+
+import dwt.widgets.Widget;
+import dwt.widgets.Decorations;
+import dwt.widgets.MenuItem;
+import dwt.widgets.Control;
+import dwt.widgets.Shell;
+import dwt.widgets.TypedListener;
+
+import dwt.dwthelper.utils;
 
 /**
  * Instances of this class are user interface objects that contain
@@ -74,7 +50,7 @@
  * </p>
  */
 
-public class Menu extends Widget {
+public class Menu : Widget {
     /**
      * the handle to the OS resource
      * (Warning: This field is platform dependent)
@@ -85,9 +61,12 @@
      * platforms and should never be accessed from application code.
      * </p>
      */
-    public int handle;
+    public HMENU handle;
 
-    int x, y, hBrush, hwndCB, id0, id1;
+    int x, y;
+    HBRUSH hBrush;
+    HWND hwndCB;
+    int id0, id1;
     int foreground = -1, background = -1;
     Image backgroundImage;
     bool hasLocation;
@@ -96,15 +75,15 @@
     ImageList imageList;
 
     /* Resource ID for SHMENUBARINFO */
-    static final int ID_PPC = 100;
+    static const int ID_PPC = 100;
 
     /* SmartPhone SoftKeyBar resource ids */
-    static final int ID_SPMM = 102;
-    static final int ID_SPBM = 103;
-    static final int ID_SPMB = 104;
-    static final int ID_SPBB = 105;
-    static final int ID_SPSOFTKEY0 = 106;
-    static final int ID_SPSOFTKEY1 = 107;
+    static const int ID_SPMM = 102;
+    static const int ID_SPBM = 103;
+    static const int ID_SPMB = 104;
+    static const int ID_SPBB = 105;
+    static const int ID_SPSOFTKEY0 = 106;
+    static const int ID_SPSOFTKEY1 = 107;
 
 /**
  * Constructs a new instance of this class given its parent,
@@ -125,7 +104,7 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Menu (Control parent) {
+public this (Control parent) {
     this (checkNull (parent).menuShell (), DWT.POP_UP);
 }
 
@@ -160,8 +139,8 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Menu (Decorations parent, int style) {
-    this (parent, checkStyle (style), 0);
+public this (Decorations parent, int style) {
+    this (parent, checkStyle (style), null);
 }
 
 /**
@@ -184,7 +163,7 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Menu (Menu parentMenu) {
+public this (Menu parentMenu) {
     this (checkNull (parentMenu).parent, DWT.DROP_DOWN);
 }
 
@@ -208,11 +187,11 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Menu (MenuItem parentItem) {
+public this (MenuItem parentItem) {
     this (checkNull (parentItem).parent);
 }
 
-Menu (Decorations parent, int style, int handle) {
+this (Decorations parent, int style, HWND handle) {
     super (parent, checkStyle (style));
     this.parent = parent;
     this.handle = handle;
@@ -236,7 +215,7 @@
 
 void _setVisible (bool visible) {
     if ((style & (DWT.BAR | DWT.DROP_DOWN)) !is 0) return;
-    int hwndParent = parent.handle;
+    auto hwndParent = parent.handle;
     if (visible) {
         int flags = OS.TPM_LEFTBUTTON;
         if (OS.GetKeyState (OS.VK_LBUTTON) >= 0) flags |= OS.TPM_RIGHTBUTTON;
@@ -248,8 +227,8 @@
         int nX = x, nY = y;
         if (!hasLocation) {
             int pos = OS.GetMessagePos ();
-            nX = (short) (pos & 0xFFFF);
-            nY = (short) (pos >> 16);
+            nX = cast(short) (pos & 0xFFFF);
+            nY = cast(short) (pos >> 16);
         }
         /*
         * Feature in Windows.  It is legal use TrackPopupMenu()
@@ -264,7 +243,7 @@
         * case when TrackPopupMenu() fails and the number of items in
         * the menu is zero and issue a fake WM_MENUSELECT.
         */
-        bool success = OS.TrackPopupMenu (handle, flags, nX, nY, 0, hwndParent, null);
+        bool success = cast(bool) OS.TrackPopupMenu (handle, flags, nX, nY, 0, hwndParent, null);
         if (!success && GetMenuItemCount (handle) is 0) {
             OS.SendMessage (hwndParent, OS.WM_MENUSELECT, 0xFFFF0000, 0);
         }
@@ -346,17 +325,17 @@
 }
 
 void createHandle () {
-    if (handle !is 0) return;
+    if (handle !is null) return;
     if ((style & DWT.BAR) !is 0) {
-        if (OS.IsPPC) {
-            int hwndShell = parent.handle;
-            SHMENUBARINFO mbi = new SHMENUBARINFO ();
+        static if( OS.IsWinCE ) if (OS.IsPPC) {
+            auto hwndShell = parent.handle;
+            SHMENUBARINFO mbi;
             mbi.cbSize = SHMENUBARINFO.sizeof;
             mbi.hwndParent = hwndShell;
             mbi.dwFlags = OS.SHCMBF_HIDDEN;
             mbi.nToolBarId = ID_PPC;
             mbi.hInstRes = OS.GetLibraryHandle ();
-            bool success = OS.SHCreateMenuBar (mbi);
+            bool success = cast(bool) OS.SHCreateMenuBar (&mbi);
             hwndCB = mbi.hwndMB;
             if (!success) error (DWT.ERROR_NO_HANDLES);
             /* Remove the item from the resource file */
@@ -372,7 +351,7 @@
         * DWT.BAR | DWT.BUTTON1 | DWT.BUTTON2: creates a SoftBar with
         *    2 buttons
         */
-        if (OS.IsSP) {
+        static if (OS.IsSP_) {
             /* Determine type of menubar */
             int nToolBarId;
             if ((style & DWT.BUTTON1) !is 0) {
@@ -382,13 +361,13 @@
             }
 
             /* Create SHMENUBAR */
-            SHMENUBARINFO mbi = new SHMENUBARINFO ();
+            SHMENUBARINFO mbi;
             mbi.cbSize = SHMENUBARINFO.sizeof;
             mbi.hwndParent = parent.handle;
             mbi.dwFlags = OS.SHCMBF_HIDDEN;
             mbi.nToolBarId = nToolBarId; /* as defined in .rc file */
             mbi.hInstRes = OS.GetLibraryHandle ();
-            if (!OS.SHCreateMenuBar (mbi)) error (DWT.ERROR_NO_HANDLES);
+            if (!OS.SHCreateMenuBar (&mbi)) error (DWT.ERROR_NO_HANDLES);
             hwndCB = mbi.hwndMB;
 
             /*
@@ -440,11 +419,11 @@
             return;
         }
         handle = OS.CreateMenu ();
-        if (handle is 0) error (DWT.ERROR_NO_HANDLES);
-        if (OS.IsHPC) {
-            int hwndShell = parent.handle;
+        if (handle is null) error (DWT.ERROR_NO_HANDLES);
+        static if (OS.IsHPC) {
+            auto hwndShell = parent.handle;
             hwndCB = OS.CommandBar_Create (OS.GetModuleHandle (null), hwndShell, 1);
-            if (hwndCB is 0) error (DWT.ERROR_NO_HANDLES);
+            if (hwndCB is null) error (DWT.ERROR_NO_HANDLES);
             OS.CommandBar_Show (hwndCB, false);
             OS.CommandBar_InsertMenubarEx (hwndCB, 0, handle, 0);
             /*
@@ -457,7 +436,7 @@
         }
     } else {
         handle = OS.CreatePopupMenu ();
-        if (handle is 0) error (DWT.ERROR_NO_HANDLES);
+        if (handle is null) error (DWT.ERROR_NO_HANDLES);
     }
 }
 
@@ -466,18 +445,18 @@
     if (!(0 <= index && index <= count)) error (DWT.ERROR_INVALID_RANGE);
     display.addMenuItem (item);
     bool success = false;
-    if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) {
-        if (OS.IsSP) return;
-        TBBUTTON lpButton = new TBBUTTON ();
+    if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) {
+        if (OS.IsSP_) return;
+        TBBUTTON lpButton;
         lpButton.idCommand = item.id;
-        lpButton.fsStyle = (byte) OS.TBSTYLE_AUTOSIZE;
+        lpButton.fsStyle = cast(byte) OS.TBSTYLE_AUTOSIZE;
         if ((item.style & DWT.CASCADE) !is 0) lpButton.fsStyle |= OS.TBSTYLE_DROPDOWN | 0x80;
-        if ((item.style & DWT.SEPARATOR) !is 0) lpButton.fsStyle = (byte) OS.BTNS_SEP;
-        lpButton.fsState = (byte) OS.TBSTATE_ENABLED;
+        if ((item.style & DWT.SEPARATOR) !is 0) lpButton.fsStyle = cast(byte) OS.BTNS_SEP;
+        lpButton.fsState = cast(byte) OS.TBSTATE_ENABLED;
         lpButton.iBitmap = OS.I_IMAGENONE;
-        success = OS.SendMessage (hwndCB, OS.TB_INSERTBUTTON, index, lpButton) !is 0;
+        success = OS.SendMessage (hwndCB, OS.TB_INSERTBUTTON, index, &lpButton) !is 0;
     } else {
-        if (OS.IsWinCE) {
+        static if (OS.IsWinCE) {
             int uFlags = OS.MF_BYPOSITION;
             TCHAR lpNewItem = null;
             if ((item.style & DWT.SEPARATOR) !is 0) {
@@ -506,19 +485,19 @@
             * becomes unexpectedly disabled.  The fix is to insert a
             * space.
             */
-            int hHeap = OS.GetProcessHeap ();
-            TCHAR buffer = new TCHAR (0, " ", true);
-            int byteCount = buffer.length () * TCHAR.sizeof;
-            int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-            OS.MoveMemory (pszText, buffer, byteCount);
-            MENUITEMINFO info = new MENUITEMINFO ();
+            auto hHeap = OS.GetProcessHeap ();
+            TCHAR[] buffer = StrToTCHARs (0, " \0");
+            int byteCount = (buffer.length-1) * TCHAR.sizeof;
+            auto pszText = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+            OS.MoveMemory (pszText, buffer.ptr, byteCount);
+            MENUITEMINFO info;
             info.cbSize = MENUITEMINFO.sizeof;
             info.fMask = OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_DATA;
             info.wID = info.dwItemData = item.id;
             info.fType = item.widgetStyle ();
             info.dwTypeData = pszText;
-            success = OS.InsertMenuItem (handle, index, true, info);
-            if (pszText !is 0) OS.HeapFree (hHeap, 0, pszText);
+            success = cast(bool) OS.InsertMenuItem (handle, index, true, &info);
+            if (pszText !is null) OS.HeapFree (hHeap, 0, pszText);
         }
     }
     if (!success) {
@@ -562,8 +541,8 @@
 
 void destroyItem (MenuItem item) {
     if (OS.IsWinCE) {
-        if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) {
-            if (OS.IsSP) {
+        if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) {
+            if (OS.IsSP_) {
                 redraw();
                 return;
             }
@@ -581,10 +560,10 @@
             }
         } else {
             int index = 0;
-            MENUITEMINFO info = new MENUITEMINFO ();
+            MENUITEMINFO info;
             info.cbSize = MENUITEMINFO.sizeof;
             info.fMask = OS.MIIM_DATA;
-            while (OS.GetMenuItemInfo (handle, index, true, info)) {
+            while (OS.GetMenuItemInfo (handle, index, true, &info)) {
                 if (info.dwItemData is item.id) break;
                 index++;
             }
@@ -604,12 +583,15 @@
 }
 
 override void destroyWidget () {
-    int hMenu = handle, hCB = hwndCB;
+    HMENU hMenu = handle;
+    HWND hCB = hwndCB;
     releaseHandle ();
-    if (OS.IsWinCE && hCB !is 0) {
-        OS.CommandBar_Destroy (hCB);
+    if (OS.IsWinCE && hCB !is null) {
+        static if( OS.IsWinCE ){
+            OS.CommandBar_Destroy (hCB);
+        }
     } else {
-        if (hMenu !is 0) OS.DestroyMenu (hMenu);
+        if (hMenu !is null) OS.DestroyMenu (hMenu);
     }
 }
 
@@ -684,21 +666,21 @@
         if (parent.menuBar !is this) {
             return new Rectangle (0, 0, 0, 0);
         }
-        int hwndShell = parent.handle;
-        MENUBARINFO info = new MENUBARINFO ();
+        auto hwndShell = parent.handle;
+        MENUBARINFO info;
         info.cbSize = MENUBARINFO.sizeof;
-        if (OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 0, info)) {
-            int width = info.right - info.left;
-            int height = info.bottom - info.top;
-            return new Rectangle (info.left, info.top, width, height);
+        if (OS.GetMenuBarInfo (hwndShell, OS.OBJID_MENU, 0, &info)) {
+            int width = info.rcBar.right - info.rcBar.left;
+            int height = info.rcBar.bottom - info.rcBar.top;
+            return new Rectangle (info.rcBar.left, info.rcBar.top, width, height);
         }
     } else {
         int count = GetMenuItemCount (handle);
         if (count !is 0) {
-            RECT rect1 = new RECT ();
-            if (OS.GetMenuItemRect (0, handle, 0, rect1)) {
-                RECT rect2 = new RECT ();
-                if (OS.GetMenuItemRect (0, handle, count - 1, rect2)) {
+            RECT rect1;
+            if (OS.GetMenuItemRect (null, handle, 0, &rect1)) {
+                RECT rect2;
+                if (OS.GetMenuItemRect (null, handle, count - 1, &rect2)) {
                     int x = rect1.left - 2, y = rect1.top - 2;
                     int width = (rect2.right - rect2.left) + 4;
                     int height = (rect2.bottom - rect1.top) + 4;
@@ -727,10 +709,10 @@
     if (OS.IsWinCE) return null;
     int id = OS.GetMenuDefaultItem (handle, OS.MF_BYCOMMAND, OS.GMDI_USEDISABLED);
     if (id is -1) return null;
-    MENUITEMINFO info = new MENUITEMINFO ();
+    MENUITEMINFO info;
     info.cbSize = MENUITEMINFO.sizeof;
     info.fMask = OS.MIIM_ID;
-    if (OS.GetMenuItemInfo (handle, id, false, info)) {
+    if (OS.GetMenuItemInfo (handle, id, false, &info)) {
         return display.getMenuItem (info.wID);
     }
     return null;
@@ -789,22 +771,22 @@
 public MenuItem getItem (int index) {
     checkWidget ();
     int id = 0;
-    if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) {
-        if (OS.IsPPC) {
-            TBBUTTON lpButton = new TBBUTTON ();
-            int result = OS.SendMessage (hwndCB, OS.TB_GETBUTTON, index, lpButton);
+    if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) {
+        static if (OS.IsPPC_) {
+            TBBUTTON lpButton;
+            int result = OS.SendMessage (hwndCB, OS.TB_GETBUTTON, index, &lpButton);
             if (result is 0) error (DWT.ERROR_CANNOT_GET_ITEM);
             id = lpButton.idCommand;
         }
-        if (OS.IsSP) {
+        if (OS.IsSP_) {
             if (!(0 <= index && index <= 1)) error (DWT.ERROR_CANNOT_GET_ITEM);
             id = index is 0 ? id0 : id1;
         }
     } else {
-        MENUITEMINFO info = new MENUITEMINFO ();
+        MENUITEMINFO info;
         info.cbSize = MENUITEMINFO.sizeof;
         info.fMask = OS.MIIM_DATA;
-        if (!OS.GetMenuItemInfo (handle, index, true, info)) {
+        if (!OS.GetMenuItemInfo (handle, index, true, &info)) {
             error (DWT.ERROR_INVALID_RANGE);
         }
         id = info.dwItemData;
@@ -845,18 +827,18 @@
  */
 public MenuItem [] getItems () {
     checkWidget ();
-    if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) {
-        if (OS.IsSP) {
+    if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) {
+        if (OS.IsSP_) {
             MenuItem [] result = new MenuItem [2];
             result[0] = display.getMenuItem (id0);
             result[1] = display.getMenuItem (id1);
             return result;
         }
         int count = OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0);
-        TBBUTTON lpButton = new TBBUTTON ();
+        TBBUTTON lpButton;
         MenuItem [] result = new MenuItem [count];
         for (int i=0; i<count; i++) {
-            OS.SendMessage (hwndCB, OS.TB_GETBUTTON, i, lpButton);
+            OS.SendMessage (hwndCB, OS.TB_GETBUTTON, i, &lpButton);
             result [i] = display.getMenuItem (lpButton.idCommand);
         }
         return result;
@@ -864,10 +846,10 @@
     int index = 0, count = 0;
     int length = OS.IsWinCE ? 4 : OS.GetMenuItemCount (handle);
     MenuItem [] items = new MenuItem [length];
-    MENUITEMINFO info = new MENUITEMINFO ();
+    MENUITEMINFO info;
     info.cbSize = MENUITEMINFO.sizeof;
     info.fMask = OS.MIIM_DATA;
-    while (OS.GetMenuItemInfo (handle, index, true, info)) {
+    while (OS.GetMenuItemInfo (handle, index, true, &info)) {
         if (count is items.length) {
             MenuItem [] newItems = new MenuItem [count + 4];
             System.arraycopy (items, 0, newItems, 0, count);
@@ -883,29 +865,29 @@
     return result;
 }
 
-int GetMenuItemCount (int handle) {
+int GetMenuItemCount (HANDLE handle) {
     if (OS.IsWinCE) {
-        if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) {
-            return OS.IsSP ? 2 : OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0);
+        if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) {
+            return OS.IsSP_ ? 2 : OS.SendMessage (hwndCB, OS.TB_BUTTONCOUNT, 0, 0);
         }
         int count = 0;
-        MENUITEMINFO info = new MENUITEMINFO ();
+        MENUITEMINFO info;
         info.cbSize = MENUITEMINFO.sizeof;
-        while (OS.GetMenuItemInfo (handle, count, true, info)) count++;
+        while (OS.GetMenuItemInfo (handle, count, true, &info)) count++;
         return count;
     }
     return OS.GetMenuItemCount (handle);
 }
 
-override String getNameText () {
-    String result = "";
+override char[] getNameText () {
+    char[] result = "";
     MenuItem [] items = getItems ();
-    int length = items.length;
-    if (length > 0) {
-        for (int i=0; i<length-1; i++) {
-            result = result + items [i].getNameText() + ", ";
+    int length_ = items.length;
+    if (length_ > 0) {
+        for (int i=0; i<length_-1; i++) {
+            result = result ~ items [i].getNameText() ~ ", ";
         }
-        result = result + items [length-1].getNameText ();
+        result = result ~ items [length_-1].getNameText ();
     }
     return result;
 }
@@ -1018,12 +1000,12 @@
 }
 
 int imageIndex (Image image) {
-    if (hwndCB is 0 || image is null) return OS.I_IMAGENONE;
+    if (hwndCB is null || image is null) return OS.I_IMAGENONE;
     if (imageList is null) {
         Rectangle bounds = image.getBounds ();
         imageList = display.getImageList (style & DWT.RIGHT_TO_LEFT, bounds.width, bounds.height);
         int index = imageList.add (image);
-        int hImageList = imageList.getHandle ();
+        HANDLE hImageList = imageList.getHandle ();
         OS.SendMessage (hwndCB, OS.TB_SETIMAGELIST, 0, hImageList);
         return index;
     }
@@ -1058,21 +1040,21 @@
     if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
     if (item.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
     if (item.parent !is this) return -1;
-    if ((OS.IsPPC || OS.IsSP) && hwndCB !is 0) {
-        if (OS.IsPPC) {
+    if ((OS.IsPPC_ || OS.IsSP_) && hwndCB !is null) {
+        if (OS.IsPPC_) {
             return OS.SendMessage (hwndCB, OS.TB_COMMANDTOINDEX, item.id, 0);
         }
-        if (OS.IsSP) {
+        if (OS.IsSP_) {
             if (item.id is id0) return 0;
             if (item.id is id1) return 1;
             return -1;
         }
     }
     int index = 0;
-    MENUITEMINFO info = new MENUITEMINFO ();
+    MENUITEMINFO info;
     info.cbSize = MENUITEMINFO.sizeof;
     info.fMask = OS.MIIM_DATA;
-    while (OS.GetMenuItemInfo (handle, index, true, info)) {
+    while (OS.GetMenuItemInfo (handle, index, true, &info)) {
         if (info.dwItemData is item.id) return index;
         index++;
     }
@@ -1133,7 +1115,8 @@
 
 override void releaseHandle () {
     super.releaseHandle ();
-    handle = hwndCB = 0;
+    handle = null;
+    hwndCB = null;
 }
 
 override void releaseChildren (bool destroy) {
@@ -1141,7 +1124,7 @@
     for (int i=0; i<items.length; i++) {
         MenuItem item = items [i];
         if (item !is null && !item.isDisposed ()) {
-            if (OS.IsPPC && hwndCB !is 0) {
+            if (OS.IsPPC_ && hwndCB !is null) {
                 item.dispose ();
             } else {
                 item.release (false);
@@ -1169,9 +1152,9 @@
 override void releaseWidget () {
     super.releaseWidget ();
     backgroundImage = null;
-    if (hBrush is 0) OS.DeleteObject (hBrush);
-    hBrush = 0;
-    if (OS.IsPPC && hwndCB !is 0) {
+    if (hBrush is null) OS.DeleteObject (hBrush);
+    hBrush = null;
+    if (OS.IsPPC_ && hwndCB !is null) {
         if (imageList !is null) {
             OS.SendMessage (hwndCB, OS.TB_SETIMAGELIST, 0, 0);
             display.releaseToolImageList (imageList);
@@ -1454,8 +1437,8 @@
 }
 
 void update () {
-    if (OS.IsPPC || OS.IsSP) return;
-    if (OS.IsHPC) {
+    if (OS.IsPPC_ || OS.IsSP_) return;
+    static if (OS.IsHPC) {
         /*
         * Each time a menu has been modified, the command menu bar
         * must be redrawn or it won't update properly.  For example,
@@ -1487,10 +1470,12 @@
     for (int i=0; i<items.length; i++) {
         MenuItem item = items [i];
         if (item.image !is null) {
-            if ((hasImage = true) && hasCheck) break;
+            hasImage = true;
+            if (hasCheck) break;
         }
         if ((item.style & (DWT.CHECK | DWT.RADIO)) !is 0) {
-            if ((hasCheck = true) && hasImage) break;
+            hasCheck = true;
+            if ( hasImage) break;
         }
     }
 
@@ -1515,15 +1500,15 @@
     */
     if (!OS.IsWin95) {
         if (OS.WIN32_VERSION < OS.VERSION (6, 0)) {
-            MENUITEMINFO info = new MENUITEMINFO ();
+            MENUITEMINFO info;
             info.cbSize = MENUITEMINFO.sizeof;
             info.fMask = OS.MIIM_BITMAP;
             for (int i=0; i<items.length; i++) {
                 MenuItem item = items [i];
                 if ((style & DWT.SEPARATOR) is 0) {
                     if (item.image is null || foreground !is -1) {
-                        info.hbmpItem = hasImage || foreground !is -1 ? OS.HBMMENU_CALLBACK : 0;
-                        OS.SetMenuItemInfo (handle, item.id, false, info);
+                        info.hbmpItem = hasImage || foreground !is -1 ? OS.HBMMENU_CALLBACK : null;
+                        OS.SetMenuItemInfo (handle, item.id, false, &info);
                     }
                 }
             }
@@ -1531,45 +1516,45 @@
     }
 
     /* Update the menu to hide or show the space for bitmaps */
-    MENUINFO lpcmi = new MENUINFO ();
+    MENUINFO lpcmi;
     lpcmi.cbSize = MENUINFO.sizeof;
     lpcmi.fMask = OS.MIM_STYLE;
-    OS.GetMenuInfo (handle, lpcmi);
+    OS.GetMenuInfo (handle, &lpcmi);
     if (hasImage && !hasCheck) {
         lpcmi.dwStyle |= OS.MNS_CHECKORBMP;
     } else {
         lpcmi.dwStyle &= ~OS.MNS_CHECKORBMP;
     }
-    OS.SetMenuInfo (handle, lpcmi);
+    OS.SetMenuInfo (handle, &lpcmi);
 }
 
 void updateBackground () {
-    if (hBrush is 0) OS.DeleteObject (hBrush);
-    hBrush = 0;
+    if (hBrush is null) OS.DeleteObject (hBrush);
+    hBrush = null;
     if (backgroundImage !is null) {
         hBrush = OS.CreatePatternBrush (backgroundImage.handle);
     } else {
         if (background !is -1) hBrush = OS.CreateSolidBrush (background);
     }
-    MENUINFO lpcmi = new MENUINFO ();
+    MENUINFO lpcmi;
     lpcmi.cbSize = MENUINFO.sizeof;
     lpcmi.fMask = OS.MIM_BACKGROUND;
     lpcmi.hbrBack = hBrush;
-    OS.SetMenuInfo (handle, lpcmi);
+    OS.SetMenuInfo (handle, &lpcmi);
 }
 
 void updateForeground () {
     if (OS.WIN32_VERSION < OS.VERSION (4, 10)) return;
-    MENUITEMINFO info = new MENUITEMINFO ();
+    MENUITEMINFO info;
     info.cbSize = MENUITEMINFO.sizeof;
     int index = 0;
-    while (OS.GetMenuItemInfo (handle, index, true, info)) {
+    while (OS.GetMenuItemInfo (handle, index, true, &info)) {
         info.fMask = OS.MIIM_BITMAP;
         info.hbmpItem = OS.HBMMENU_CALLBACK;
-        OS.SetMenuItemInfo (handle, index, true, info);
+        OS.SetMenuItemInfo (handle, index, true, &info);
         index++;
     }
     redraw ();
 }
 }
-++/
+
--- a/dwt/widgets/MenuItem.d	Mon Feb 04 11:08:30 2008 +0100
+++ b/dwt/widgets/MenuItem.d	Mon Feb 04 12:34:19 2008 +0100
@@ -15,6 +15,7 @@
 import dwt.widgets.Item;
 import dwt.widgets.Widget;
 import dwt.widgets.Menu;
+import dwt.widgets.Decorations;
 import dwt.internal.win32.OS;
 
 class MenuItem : Item {
@@ -31,6 +32,9 @@
 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;
--- a/tango_sys_win32/Types.di	Mon Feb 04 11:08:30 2008 +0100
+++ b/tango_sys_win32/Types.di	Mon Feb 04 12:34:19 2008 +0100
@@ -10213,27 +10213,73 @@
 alias MENUEX_TEMPLATE_ITEM TMENUEXTEMPLATEITEM;
 alias MENUEX_TEMPLATE_ITEM* PMENUEXTEMPLATEITEM;
 
-struct MENUITEMINFO
-{
-	UINT cbSize;
-	UINT fMask;
-	UINT fType;
-	UINT fState;
-	UINT wID;
-	HMENU hSubMenu;
-	HBITMAP hbmpChecked;
-	HBITMAP hbmpUnchecked;
-	DWORD dwItemData;
-	LPTSTR dwTypeData;
-	UINT cch;
-}
-
-alias MENUITEMINFO* LPMENUITEMINFO;
-alias MENUITEMINFO* LPCMENUITEMINFO;
-alias MENUITEMINFO TAGMENUITEMINFO;
-alias MENUITEMINFO TMENUITEMINFO;
-alias MENUITEMINFO TMENUITEMINFOA;
-alias MENUITEMINFO* PMENUITEMINFO;
+/*
+* Feature in Windows.  The hbmpItem field requires Windows 4.10
+* or greater.  On Windows NT 4.0, passing in a larger struct size
+* in the cbSize field does nothing.  On Windows 95, the MENUITEMINFO
+* calls fail when the struct size is too large.  The fix is to ensure
+* that the correct struct size is used for the Windows platform.
+*/
+struct MENUITEMINFOA
+{
+    UINT    cbSize;
+    UINT    fMask;
+    UINT    fType;          // used if MIIM_TYPE
+    UINT    fState;         // used if MIIM_STATE
+    UINT    wID;            // used if MIIM_ID
+    HMENU   hSubMenu;       // used if MIIM_SUBMENU
+    HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS
+    HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS
+    DWORD   dwItemData;     // used if MIIM_DATA
+    LPSTR   dwTypeData;     // used if MIIM_TYPE
+    UINT    cch;            // used if MIIM_TYPE
+    HBITMAP hbmpItem;
+}
+alias MENUITEMINFOA* PMENUITEMINFOA, LPMENUITEMINFOA;
+struct MENUITEMINFOW
+{
+    UINT    cbSize;
+    UINT    fMask;
+    UINT    fType;          // used if MIIM_TYPE
+    UINT    fState;         // used if MIIM_STATE
+    UINT    wID;            // used if MIIM_ID
+    HMENU   hSubMenu;       // used if MIIM_SUBMENU
+    HBITMAP hbmpChecked;    // used if MIIM_CHECKMARKS
+    HBITMAP hbmpUnchecked;  // used if MIIM_CHECKMARKS
+    DWORD   dwItemData;     // used if MIIM_DATA
+    LPWSTR  dwTypeData;     // used if MIIM_TYPE
+    UINT    cch;            // used if MIIM_TYPE
+    HBITMAP hbmpItem;
+}   alias MENUITEMINFOW* PMENUITEMINFOW, LPMENUITEMINFOW;
+version(ANSI){
+    alias MENUITEMINFOA MENUITEMINFO;
+}else{
+    alias MENUITEMINFOW MENUITEMINFO;
+}
+alias MENUITEMINFO * LPMENUITEMINFO;
+alias MENUITEMINFO * LPCMENUITEMINFO;
+
+// struct MENUITEMINFO
+// {
+// 	UINT cbSize;
+// 	UINT fMask;
+// 	UINT fType;
+// 	UINT fState;
+// 	UINT wID;
+// 	HMENU hSubMenu;
+// 	HBITMAP hbmpChecked;
+// 	HBITMAP hbmpUnchecked;
+// 	DWORD dwItemData;
+// 	LPTSTR dwTypeData;
+// 	UINT cch;
+// }
+//
+// alias MENUITEMINFO* LPMENUITEMINFO;
+// alias MENUITEMINFO* LPCMENUITEMINFO;
+// alias MENUITEMINFO TAGMENUITEMINFO;
+// alias MENUITEMINFO TMENUITEMINFO;
+// alias MENUITEMINFO TMENUITEMINFOA;
+// alias MENUITEMINFO* PMENUITEMINFO;
 
 struct MENUITEMTEMPLATE
 {