changeset 41:f871c501e610

Button
author Frank Benoit <benoit@tionex.de>
date Fri, 01 Feb 2008 22:10:37 +0100
parents 3052439af4b5
children 6a40adae94d5
files dwt/internal/win32/OS.d dwt/internal/win32/WINTYPES.d dwt/widgets/Button.d
diffstat 3 files changed, 138 insertions(+), 145 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/win32/OS.d	Fri Feb 01 20:19:46 2008 +0100
+++ b/dwt/internal/win32/OS.d	Fri Feb 01 22:10:37 2008 +0100
@@ -1255,7 +1255,7 @@
     public static const int OBJ_BITMAP = 0x7;
     public static const int OBJ_FONT = 0x6;
     public static const int OBJ_PEN = 0x1;
-    public static const int OBM_CHECKBOXES = 0x7ff7;
+    public static const TCHAR* OBM_CHECKBOXES = cast(TCHAR*)0x7ff7;
     public static const int ODS_SELECTED = 0x1;
     public static const int ODT_MENU = 0x1;
     public static const int OFN_ALLOWMULTISELECT = 0x200;
--- a/dwt/internal/win32/WINTYPES.d	Fri Feb 01 20:19:46 2008 +0100
+++ b/dwt/internal/win32/WINTYPES.d	Fri Feb 01 22:10:37 2008 +0100
@@ -28,10 +28,16 @@
   DWORD dwReserved;
 }
 
+struct BUTTON_IMAGELIST {
+    HIMAGELIST himl;
+    RECT margin;
+    UINT uAlign;
+}
+
 alias HANDLE HTHEME;
 
 // ....
-
+//--------------------------------------------------------------------------------
 
 const int LF_FACESIZE = 32;
 const int LF_FULLFACESIZE = 64;
--- a/dwt/widgets/Button.d	Fri Feb 01 20:19:46 2008 +0100
+++ b/dwt/widgets/Button.d	Fri Feb 01 22:10:37 2008 +0100
@@ -12,14 +12,8 @@
  *******************************************************************************/
 module dwt.widgets.Button;
 
-import dwt.widgets.Control;
 
-class Button : Control{
-void setDefault (bool value) ;
-void click () ;
-}
 
-/++
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.events.SelectionEvent;
@@ -30,18 +24,13 @@
 import dwt.graphics.Point;
 import dwt.graphics.Rectangle;
 import dwt.internal.ImageList;
-import dwt.internal.win32.BITMAP;
-import dwt.internal.win32.BUTTON_IMAGELIST;
-import dwt.internal.win32.DRAWITEMSTRUCT;
-import dwt.internal.win32.LRESULT;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.SIZE;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.TEXTMETRIC;
-import dwt.internal.win32.TEXTMETRICA;
-import dwt.internal.win32.TEXTMETRICW;
-import dwt.internal.win32.WNDCLASS;
+
+import dwt.widgets.Control;
+import dwt.widgets.Composite;
+import dwt.widgets.TypedListener;
+
+import dwt.dwthelper.utils;
 
 /**
  * Instances of this class represent a selectable user interface object that
@@ -67,31 +56,32 @@
  * </p>
  */
 
-public class Button extends Control {
-    String text = "", message = "";
+public class Button : Control {
+    alias extern(Windows) int function( HWND, uint, uint, int ) TWindowProc;
+    char[] text = "", message = "";
     Image image, image2, disabledImage;
     ImageList imageList;
     bool ignoreMouse;
-    static final int MARGIN = 4;
-    static final int CHECK_WIDTH, CHECK_HEIGHT;
-    static final int ICON_WIDTH = 128, ICON_HEIGHT = 128;
-    static final bool COMMAND_LINK = false;
-    static final int ButtonProc;
-    static final TCHAR ButtonClass = new TCHAR (0, "BUTTON", true);
-    static {
-        int hBitmap = OS.LoadBitmap (0, OS.OBM_CHECKBOXES);
-        if (hBitmap is 0) {
+    static const int MARGIN = 4;
+    static const int CHECK_WIDTH, CHECK_HEIGHT;
+    static const int ICON_WIDTH = 128, ICON_HEIGHT = 128;
+    static const bool COMMAND_LINK = false;
+    static const TWindowProc ButtonProc;
+    static const TCHAR[] ButtonClass = "BUTTON\0";
+    static this() {
+        auto hBitmap = OS.LoadBitmap (null, OS.OBM_CHECKBOXES);
+        if (hBitmap is null) {
             CHECK_WIDTH = OS.GetSystemMetrics (OS.IsWinCE ? OS.SM_CXSMICON : OS.SM_CXVSCROLL);
             CHECK_HEIGHT = OS.GetSystemMetrics (OS.IsWinCE ? OS.SM_CYSMICON : OS.SM_CYVSCROLL);
         } else {
-            BITMAP bitmap = new BITMAP ();
-            OS.GetObject (hBitmap, BITMAP.sizeof, bitmap);
+            BITMAP bitmap;
+            OS.GetObject (hBitmap, BITMAP.sizeof, &bitmap);
             OS.DeleteObject (hBitmap);
             CHECK_WIDTH = bitmap.bmWidth / 4;
             CHECK_HEIGHT =  bitmap.bmHeight / 3;
         }
-        WNDCLASS lpWndClass = new WNDCLASS ();
-        OS.GetClassInfo (0, ButtonClass, lpWndClass);
+        WNDCLASS lpWndClass;
+        OS.GetClassInfo (null, ButtonClass.ptr, &lpWndClass);
         ButtonProc = lpWndClass.lpfnWndProc;
     }
 
@@ -131,7 +121,7 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Button (Composite parent, int style) {
+public this (Composite parent, int style) {
     super (parent, checkStyle (style));
 }
 
@@ -149,21 +139,21 @@
                 disabledImage = new Image (display, image, DWT.IMAGE_DISABLE);
                 imageList.add (disabledImage);
             }
-            BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ();
+            BUTTON_IMAGELIST buttonImageList;
             buttonImageList.himl = imageList.getHandle ();
             int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits;
             newBits &= ~(OS.BS_LEFT | OS.BS_CENTER | OS.BS_RIGHT);
             if ((style & DWT.LEFT) !is 0) newBits |= OS.BS_LEFT;
             if ((style & DWT.CENTER) !is 0) newBits |= OS.BS_CENTER;
             if ((style & DWT.RIGHT) !is 0) newBits |= OS.BS_RIGHT;
-            if (text.length () is 0) {
+            if (text.length is 0) {
                 if ((style & DWT.LEFT) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT;
                 if ((style & DWT.CENTER) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_CENTER;
                 if ((style & DWT.RIGHT) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_RIGHT;
             } else {
                 buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT;
-                buttonImageList.margin_left = computeLeftMargin ();
-                buttonImageList.margin_right = MARGIN;
+                buttonImageList.margin.left = computeLeftMargin ();
+                buttonImageList.margin.right = MARGIN;
                 newBits &= ~(OS.BS_CENTER | OS.BS_RIGHT);
                 newBits |= OS.BS_LEFT;
             }
@@ -171,7 +161,7 @@
                 OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
                 OS.InvalidateRect (handle, null, true);
             }
-            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList);
+            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, &buttonImageList);
         } else {
             OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, 0);
         }
@@ -184,7 +174,8 @@
     } else {
         if (image2 !is null) image2.dispose ();
         image2 = null;
-        int hImage = 0, imageBits = 0, fImageType = 0;
+        HBITMAP hImage;
+        int imageBits = 0, fImageType = 0;
         if (image !is null) {
             switch (image.type) {
                 case DWT.BITMAP: {
@@ -234,14 +225,14 @@
             if ((style & DWT.RIGHT_TO_LEFT) !is 0) {
                 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) {
                     Rectangle rect = image.getBounds ();
-                    int hDC = OS.GetDC (handle);
-                    int dstHdc = OS.CreateCompatibleDC (hDC);
-                    int hBitmap = OS.CreateCompatibleBitmap (hDC, rect.width, rect.height);
-                    int oldBitmap = OS.SelectObject (dstHdc, hBitmap);
+                    auto hDC = OS.GetDC (handle);
+                    auto dstHdc = OS.CreateCompatibleDC (hDC);
+                    auto hBitmap = OS.CreateCompatibleBitmap (hDC, rect.width, rect.height);
+                    auto oldBitmap = OS.SelectObject (dstHdc, hBitmap);
                     OS.SetLayout (dstHdc, OS.LAYOUT_RTL);
                     if (fImageType is OS.IMAGE_BITMAP) {
-                        int srcHdc = OS.CreateCompatibleDC (hDC);
-                        int oldSrcBitmap = OS.SelectObject (srcHdc, hImage);
+                        auto srcHdc = OS.CreateCompatibleDC (hDC);
+                        auto oldSrcBitmap = OS.SelectObject (srcHdc, hImage);
                         OS.SetLayout (dstHdc, 0);
                         OS.BitBlt (dstHdc, 0, 0, rect.width, rect.height, srcHdc, 0, 0, OS.SRCCOPY);
                         OS.SelectObject (srcHdc, oldSrcBitmap);
@@ -249,10 +240,10 @@
                     } else {
                         Control control = findBackgroundControl ();
                         if (control is null) control = this;
-                        int newBrush = OS.CreateSolidBrush (control.getBackgroundPixel ());
-                        int oldBrush = OS.SelectObject (dstHdc, newBrush);
+                        auto newBrush = OS.CreateSolidBrush (control.getBackgroundPixel ());
+                        auto oldBrush = OS.SelectObject (dstHdc, newBrush);
                         OS.PatBlt (dstHdc, 0, 0, rect.width, rect.height, OS.PATCOPY);
-                        OS.DrawIconEx (dstHdc, 0, 0, hImage, 0, 0, 0, 0, OS.DI_NORMAL);
+                        OS.DrawIconEx (dstHdc, 0, 0, hImage, 0, 0, 0, null, OS.DI_NORMAL);
                         OS.SelectObject (dstHdc, oldBrush);
                         OS.DeleteObject (newBrush);
                     }
@@ -275,7 +266,7 @@
     }
 }
 
-void _setText (String text) {
+void _setText (char[] text) {
     int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits;
     if (OS.COMCTL32_MAJOR >= 6) {
         newBits &= ~(OS.BS_LEFT | OS.BS_CENTER | OS.BS_RIGHT);
@@ -283,20 +274,20 @@
         if ((style & DWT.CENTER) !is 0) newBits |= OS.BS_CENTER;
         if ((style & DWT.RIGHT) !is 0) newBits |= OS.BS_RIGHT;
         if (imageList !is null) {
-            BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ();
+            BUTTON_IMAGELIST buttonImageList;
             buttonImageList.himl = imageList.getHandle ();
-            if (text.length () is 0) {
+            if (text.length is 0) {
                 if ((style & DWT.LEFT) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT;
                 if ((style & DWT.CENTER) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_CENTER;
                 if ((style & DWT.RIGHT) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_RIGHT;
             } else {
                 buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT;
-                buttonImageList.margin_left = computeLeftMargin ();
-                buttonImageList.margin_right = MARGIN;
+                buttonImageList.margin.left = computeLeftMargin ();
+                buttonImageList.margin.right = MARGIN;
                 newBits &= ~(OS.BS_CENTER | OS.BS_RIGHT);
                 newBits |= OS.BS_LEFT;
             }
-            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList);
+            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, &buttonImageList);
         }
     } else {
         newBits &= ~(OS.BS_BITMAP | OS.BS_ICON);
@@ -312,10 +303,10 @@
     */
     if ((style & DWT.RIGHT_TO_LEFT) !is 0) {
         if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) {
-            text = OS.IsWindowEnabled (handle) ? text : " " + text + " ";
+            text = OS.IsWindowEnabled (handle) ? text : " " ~ text ~ " ";
         }
     }
-    TCHAR buffer = new TCHAR (getCodePage (), text, true);
+    TCHAR* buffer = StrToTCHARz ( text );
     OS.SetWindowText (handle, buffer);
 }
 
@@ -351,9 +342,9 @@
     addListener (DWT.DefaultSelection,typedListener);
 }
 
-int callWindowProc (int hwnd, int msg, int wParam, int lParam) {
-    if (handle is 0) return 0;
-    return OS.CallWindowProc (ButtonProc, hwnd, msg, wParam, lParam);
+override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) {
+    if (handle is null) return LRESULT.ZERO;
+    return cast(LRESULT) ButtonProc( hwnd, msg, wParam, lParam);
 }
 
 static int checkStyle (int style) {
@@ -387,21 +378,21 @@
     if (OS.COMCTL32_MAJOR < 6) return MARGIN;
     if ((style & (DWT.PUSH | DWT.TOGGLE)) is 0) return MARGIN;
     int margin = 0;
-    if (image !is null && text.length () !is 0) {
+    if (image !is null && text.length !is 0) {
         Rectangle bounds = image.getBounds ();
         margin += bounds.width + MARGIN * 2;
-        int oldFont = 0;
-        int hDC = OS.GetDC (handle);
-        int newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
-        if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont);
-        TCHAR buffer = new TCHAR (getCodePage (), text, true);
-        RECT rect = new RECT ();
+        HFONT oldFont;
+        auto hDC = OS.GetDC (handle);
+        HFONT newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+        if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont);
+        TCHAR* buffer = StrToTCHARz(text);
+        RECT rect;
         int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE;
-        OS.DrawText (hDC, buffer, -1, rect, flags);
+        OS.DrawText (hDC, buffer, -1, &rect, flags);
         margin += rect.right - rect.left;
-        if (newFont !is 0) OS.SelectObject (hDC, oldFont);
+        if (newFont !is null) OS.SelectObject (hDC, oldFont);
         OS.ReleaseDC (handle, hDC);
-        OS.GetClientRect (handle, rect);
+        OS.GetClientRect (handle, &rect);
         margin = Math.max (MARGIN, (rect.right - rect.left - margin) / 2);
     }
     return margin;
@@ -420,21 +411,21 @@
         }
     } else {
         if ((style & DWT.COMMAND) !is 0) {
-            SIZE size = new SIZE ();
+            SIZE size;
             if (wHint !is DWT.DEFAULT) {
                 size.cx = wHint;
-                OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, size);
+                OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, &size);
                 width = size.cx;
                 height = size.cy;
             } else {
-                OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, size);
+                OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, &size);
                 width = size.cy;
                 height = size.cy;
                 size.cy = 0;
                 while (size.cy !is height) {
                     size.cx = width++;
                     size.cy = 0;
-                    OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, size);
+                    OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, &size);
                 }
             }
         } else {
@@ -451,7 +442,7 @@
                 if (image !is null) {
                     Rectangle rect = image.getBounds ();
                     width = rect.width;
-                    if (hasText && text.length () !is 0) {
+                    if (hasText && text.length !is 0) {
                         width += MARGIN * 2;
                     }
                     height = rect.height;
@@ -459,25 +450,25 @@
                 }
             }
             if (hasText) {
-                int oldFont = 0;
-                int hDC = OS.GetDC (handle);
-                int newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
-                if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont);
-                TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC) new TEXTMETRICW () : new TEXTMETRICA ();
-                OS.GetTextMetrics (hDC, lptm);
-                int length = text.length ();
-                if (length is 0) {
+                HFONT oldFont;
+                auto hDC = OS.GetDC (handle);
+                auto newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+                if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont);
+                TEXTMETRIC lptm;
+                OS.GetTextMetrics (hDC, &lptm);
+                int length_ = text.length;
+                if (length_ is 0) {
                     height = Math.max (height, lptm.tmHeight);
                 } else {
                     extra = Math.max (MARGIN * 2, lptm.tmAveCharWidth);
-                    TCHAR buffer = new TCHAR (getCodePage (), text, true);
-                    RECT rect = new RECT ();
+                    TCHAR* buffer = StrToTCHARz(text);
+                    RECT rect;
                     int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE;
-                    OS.DrawText (hDC, buffer, -1, rect, flags);
+                    OS.DrawText (hDC, buffer, -1, &rect, flags);
                     width += rect.right - rect.left;
                     height = Math.max (height, rect.bottom - rect.top);
                 }
-                if (newFont !is 0) OS.SelectObject (hDC, oldFont);
+                if (newFont !is null) OS.SelectObject (hDC, oldFont);
                 OS.ReleaseDC (handle, hDC);
             }
             if ((style & (DWT.CHECK | DWT.RADIO)) !is 0) {
@@ -539,8 +530,8 @@
             int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
             bool hasImage = (bits & (OS.BS_BITMAP | OS.BS_ICON)) !is 0;
             if (!hasImage) {
-                String string = enabled ? text : " " + text + " ";
-                TCHAR buffer = new TCHAR (getCodePage (), string, true);
+                char[] string = enabled ? text : " " ~ text ~ " ";
+                TCHAR* buffer = StrToTCHARz (string);
                 OS.SetWindowText (handle, buffer);
             }
         }
@@ -557,8 +548,8 @@
     */
     if (OS.COMCTL32_MAJOR >= 6) {
         if (imageList !is null) {
-            BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ();
-            OS.SendMessage (handle, OS.BCM_GETIMAGELIST, 0, buttonImageList);
+            BUTTON_IMAGELIST buttonImageList;
+            OS.SendMessage (handle, OS.BCM_GETIMAGELIST, 0, &buttonImageList);
             if (imageList !is null) imageList.dispose ();
             imageList = new ImageList (style & DWT.RIGHT_TO_LEFT);
             if (OS.IsWindowEnabled (handle)) {
@@ -569,7 +560,7 @@
                 imageList.add (disabledImage);
             }
             buttonImageList.himl = imageList.getHandle ();
-            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList);
+            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, &buttonImageList);
             /*
             * Bug in Windows.  Under certain cirumstances yet to be
             * isolated, BCM_SETIMAGELIST does not redraw the control
@@ -647,12 +638,12 @@
  *
  * @since 3.3
  */
-/*public*/ String getMessage () {
+/*public*/ char[] getMessage () {
     checkWidget ();
     return message;
 }
 
-String getNameText () {
+char[] getNameText () {
     return getText ();
 }
 
@@ -691,7 +682,7 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-public String getText () {
+public char[] getText () {
     checkWidget ();
     if ((style & DWT.ARROW) !is 0) return "";
     return text;
@@ -703,7 +694,7 @@
     return super.isTabItem ();
 }
 
-bool mnemonicHit (char ch) {
+bool mnemonicHit (wchar ch) {
     if (!setFocus ()) return false;
     /*
     * Feature in Windows.  When a radio button gets focus,
@@ -715,10 +706,10 @@
     return true;
 }
 
-bool mnemonicMatch (char key) {
-    char mnemonic = findMnemonic (getText ());
+bool mnemonicMatch (wchar key) {
+    wchar mnemonic = findMnemonic (getText ());
     if (mnemonic is '\0') return false;
-    return Character.toUpperCase (key) is Character.toUpperCase (mnemonic);
+    return CharacterToUpper (key) is CharacterToUpper (mnemonic);
 }
 
 void releaseWidget () {
@@ -818,20 +809,20 @@
     if ((style & DWT.RIGHT) !is 0) newBits |= OS.BS_RIGHT;
     if (OS.COMCTL32_MAJOR >= 6) {
         if (imageList !is null) {
-            BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ();
+            BUTTON_IMAGELIST buttonImageList;
             buttonImageList.himl = imageList.getHandle ();
-            if (text.length () is 0) {
+            if (text.length is 0) {
                 if ((style & DWT.LEFT) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT;
                 if ((style & DWT.CENTER) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_CENTER;
                 if ((style & DWT.RIGHT) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_RIGHT;
             } else {
                 buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT;
-                buttonImageList.margin_left = computeLeftMargin ();
-                buttonImageList.margin_right = MARGIN;
+                buttonImageList.margin.left = computeLeftMargin ();
+                buttonImageList.margin.right = MARGIN;
                 newBits &= ~(OS.BS_CENTER | OS.BS_RIGHT);
                 newBits |= OS.BS_LEFT;
             }
-            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList);
+            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, &buttonImageList);
         }
     }
     if (newBits !is oldBits) {
@@ -842,7 +833,7 @@
 
 void setDefault (bool value) {
     if ((style & DWT.PUSH) is 0) return;
-    int hwndShell = menuShell ().handle;
+    auto hwndShell = menuShell ().handle;
     int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
     if (value) {
         bits |= OS.BS_DEFPUSHBUTTON;
@@ -890,7 +881,7 @@
     this.image = image;
     /* This code is intentionally commented */
 //  if (OS.COMCTL32_MAJOR < 6) {
-//      if (image is null || text.length () !is 0) {
+//      if (image is null || text.length !is 0) {
 //          _setText (text);
 //          return;
 //      }
@@ -915,16 +906,13 @@
  *
  * @since 3.3
  */
-/*public*/ void setMessage (String message) {
+/*public*/ void setMessage (char[] message) {
     checkWidget ();
     if (message is null) error (DWT.ERROR_NULL_ARGUMENT);
     this.message = message;
     if (OS.COMCTL32_VERSION >= OS.VERSION (6, 1)) {
         if ((style & DWT.COMMAND) !is 0) {
-            int length = message.length ();
-            char [] chars = new char [length + 1];
-            message.getChars(0, length, chars, 0);
-            OS.SendMessage (handle, OS.BCM_SETNOTE, 0, chars);
+            OS.SendMessage (handle, OS.BCM_SETNOTE, 0, StrToTCHARz( message ));
         }
     }
 }
@@ -1019,14 +1007,14 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-public void setText (String string) {
+public void setText (char[] string) {
     checkWidget ();
     if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     if ((style & DWT.ARROW) !is 0) return;
     text = string;
     /* This code is intentionally commented */
 //  if (OS.COMCTL32_MAJOR < 6) {
-//      if (text.length () is 0 && image !is null) {
+//      if (text.length is 0 && image !is null) {
 //          _setImage (image);
 //          return;
 //      }
@@ -1049,18 +1037,18 @@
     return bits | OS.BS_PUSHBUTTON | OS.WS_TABSTOP;
 }
 
-TCHAR windowClass () {
-    return ButtonClass;
+char[] windowClass () {
+    return TCHARzToStr( ButtonClass.ptr );
 }
 
 int windowProc () {
-    return ButtonProc;
+    return cast(int) ButtonProc;
 }
 
 
 LRESULT WM_ERASEBKGND (int wParam, int lParam) {
     LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     /*
     * Bug in Windows.  For some reason, the HBRUSH that
     * is returned from WM_CTRLCOLOR is misaligned when
@@ -1072,7 +1060,7 @@
     if (OS.COMCTL32_MAJOR < 6) {
         if ((style & (DWT.RADIO | DWT.CHECK)) !is 0) {
             if (findImageControl () !is null) {
-                drawBackground (wParam);
+                drawBackground (cast(HWND)wParam);
                 return LRESULT.ONE;
             }
         }
@@ -1082,9 +1070,9 @@
 
 LRESULT WM_GETDLGCODE (int wParam, int lParam) {
     LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     if ((style & DWT.ARROW) !is 0) {
-        return new LRESULT (OS.DLGC_STATIC);
+        return cast( LRESULT )(OS.DLGC_STATIC);
     }
     return result;
 }
@@ -1098,12 +1086,12 @@
 }
 
 LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
-    if (ignoreMouse) return null;
+    if (ignoreMouse) return LRESULT.NULL;
     return super.WM_LBUTTONDOWN (wParam, lParam);
 }
 
 LRESULT WM_LBUTTONUP (int wParam, int lParam) {
-    if (ignoreMouse) return null;
+    if (ignoreMouse) return LRESULT.NULL;
     return super.WM_LBUTTONUP (wParam, lParam);
 }
 
@@ -1130,16 +1118,16 @@
 
 LRESULT WM_SIZE (int wParam, int lParam) {
     LRESULT result = super.WM_SIZE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     if (OS.COMCTL32_MAJOR >= 6) {
         if ((style & (DWT.PUSH | DWT.TOGGLE)) !is 0) {
-            if (imageList !is null && text.length () !is 0) {
-                BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ();
-                OS.SendMessage (handle, OS.BCM_GETIMAGELIST, 0, buttonImageList);
+            if (imageList !is null && text.length !is 0) {
+                BUTTON_IMAGELIST buttonImageList;
+                OS.SendMessage (handle, OS.BCM_GETIMAGELIST, 0, &buttonImageList);
                 buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT;
-                buttonImageList.margin_left = computeLeftMargin ();
-                buttonImageList.margin_right = MARGIN;
-                OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList);
+                buttonImageList.margin.left = computeLeftMargin ();
+                buttonImageList.margin.right = MARGIN;
+                OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, &buttonImageList);
             }
         }
     }
@@ -1148,14 +1136,14 @@
 
 LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
     LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     if (image2 !is null) _setImage (image);
     return result;
 }
 
 LRESULT WM_UPDATEUISTATE (int wParam, int lParam) {
     LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     /*
     * Feature in Windows.  When WM_UPDATEUISTATE is sent to
     * a button, it sends WM_CTLCOLORBTN to get the foreground
@@ -1181,7 +1169,7 @@
             if (redraw) {
                 OS.InvalidateRect (handle, null, false);
                 int code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam);
-                return new LRESULT (code);
+                return cast( LRESULT )(code);
             }
         }
     }
@@ -1222,8 +1210,8 @@
     if (OS.COMCTL32_MAJOR < 6) {
         if ((style & (DWT.RADIO | DWT.CHECK)) !is 0) {
             if (findImageControl () !is null) {
-                OS.SetBkMode (wParam, OS.TRANSPARENT);
-                return new LRESULT (OS.GetStockObject (OS.NULL_BRUSH));
+                OS.SetBkMode (cast(HANDLE)wParam, OS.TRANSPARENT);
+                return cast( LRESULT )(OS.GetStockObject (OS.NULL_BRUSH));
             }
         }
     }
@@ -1232,10 +1220,10 @@
 
 LRESULT wmDrawChild (int wParam, int lParam) {
     if ((style & DWT.ARROW) is 0) return super.wmDrawChild (wParam, lParam);
-    DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
-    OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
-    RECT rect = new RECT ();
-    OS.SetRect (rect, struct.left, struct.top, struct.right, struct.bottom);
+    auto struct_ = cast(DRAWITEMSTRUCT*)lParam;
+    //OS.MoveMemory (struct_, lParam, DRAWITEMSTRUCT.sizeof);
+    RECT rect;
+    OS.SetRect (&rect, struct_.rcItem.left, struct_.rcItem.top, struct_.rcItem.right, struct_.rcItem.bottom);
     if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
         int iStateId = OS.ABS_LEFTNORMAL;
         switch (style & (DWT.UP | DWT.DOWN | DWT.LEFT | DWT.RIGHT)) {
@@ -1250,8 +1238,8 @@
         * the direction states is invariant (always separated by 4).
         */
         if (!getEnabled ()) iStateId += OS.ABS_UPDISABLED - OS.ABS_UPNORMAL;
-        if ((struct.itemState & OS.ODS_SELECTED) !is 0) iStateId += OS.ABS_UPPRESSED - OS.ABS_UPNORMAL;
-        OS.DrawThemeBackground (display.hScrollBarTheme (), struct.hDC, OS.SBP_ARROWBTN, iStateId, rect, null);
+        if ((struct_.itemState & OS.ODS_SELECTED) !is 0) iStateId += OS.ABS_UPPRESSED - OS.ABS_UPNORMAL;
+        OS.DrawThemeBackground (display.hScrollBarTheme (), struct_.hDC, OS.SBP_ARROWBTN, iStateId, &rect, null);
     } else {
         int uState = OS.DFCS_SCROLLLEFT;
         switch (style & (DWT.UP | DWT.DOWN | DWT.LEFT | DWT.RIGHT)) {
@@ -1262,11 +1250,10 @@
         }
         if (!getEnabled ()) uState |= OS.DFCS_INACTIVE;
         if ((style & DWT.FLAT) is DWT.FLAT) uState |= OS.DFCS_FLAT;
-        if ((struct.itemState & OS.ODS_SELECTED) !is 0) uState |= OS.DFCS_PUSHED;
-        OS.DrawFrameControl (struct.hDC, rect, OS.DFC_SCROLL, uState);
+        if ((struct_.itemState & OS.ODS_SELECTED) !is 0) uState |= OS.DFCS_PUSHED;
+        OS.DrawFrameControl (struct_.hDC, &rect, OS.DFC_SCROLL, uState);
     }
-    return null;
+    return LRESULT.NULL;
 }
 
 }
-++/
\ No newline at end of file