Changeset 41:f871c501e610

Show
Ignore:
Timestamp:
02/01/08 16:10:37 (1 year ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Button

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/internal/win32/OS.d

    r40 r41  
    12561256    public static const int OBJ_FONT = 0x6; 
    12571257    public static const int OBJ_PEN = 0x1; 
    1258     public static const int OBM_CHECKBOXES = 0x7ff7; 
     1258    public static const TCHAR* OBM_CHECKBOXES = cast(TCHAR*)0x7ff7; 
    12591259    public static const int ODS_SELECTED = 0x1; 
    12601260    public static const int ODT_MENU = 0x1; 
  • dwt/internal/win32/WINTYPES.d

    r33 r41  
    2929} 
    3030 
     31struct BUTTON_IMAGELIST { 
     32    HIMAGELIST himl; 
     33    RECT margin; 
     34    UINT uAlign; 
     35} 
     36 
    3137alias HANDLE HTHEME; 
    3238 
    3339// .... 
    34  
     40//-------------------------------------------------------------------------------- 
    3541 
    3642const int LF_FACESIZE = 32; 
  • dwt/widgets/Button.d

    r39 r41  
    1313module dwt.widgets.Button; 
    1414 
    15 import dwt.widgets.Control; 
    16  
    17 class Button : Control{ 
    18 void setDefault (bool value) ; 
    19 void click () ; 
    20 
    21  
    22 /++ 
     15 
     16 
    2317import dwt.DWT; 
    2418import dwt.DWTException; 
     
    3125import dwt.graphics.Rectangle; 
    3226import dwt.internal.ImageList; 
    33 import dwt.internal.win32.BITMAP; 
    34 import dwt.internal.win32.BUTTON_IMAGELIST; 
    35 import dwt.internal.win32.DRAWITEMSTRUCT; 
    36 import dwt.internal.win32.LRESULT; 
    3727import dwt.internal.win32.OS; 
    38 import dwt.internal.win32.RECT; 
    39 import dwt.internal.win32.SIZE; 
    40 import dwt.internal.win32.TCHAR; 
    41 import dwt.internal.win32.TEXTMETRIC; 
    42 import dwt.internal.win32.TEXTMETRICA; 
    43 import dwt.internal.win32.TEXTMETRICW; 
    44 import dwt.internal.win32.WNDCLASS; 
     28 
     29import dwt.widgets.Control; 
     30import dwt.widgets.Composite; 
     31import dwt.widgets.TypedListener; 
     32 
     33import dwt.dwthelper.utils; 
    4534 
    4635/** 
     
    6857 */ 
    6958 
    70 public class Button extends Control { 
    71     String text = "", message = ""; 
     59public class Button : Control { 
     60    alias extern(Windows) int function( HWND, uint, uint, int ) TWindowProc; 
     61    char[] text = "", message = ""; 
    7262    Image image, image2, disabledImage; 
    7363    ImageList imageList; 
    7464    bool ignoreMouse; 
    75     static final int MARGIN = 4; 
    76     static final int CHECK_WIDTH, CHECK_HEIGHT; 
    77     static final int ICON_WIDTH = 128, ICON_HEIGHT = 128; 
    78     static final bool COMMAND_LINK = false; 
    79     static final int ButtonProc; 
    80     static final TCHAR ButtonClass = new TCHAR (0, "BUTTON", true)
    81     static
    82         int hBitmap = OS.LoadBitmap (0, OS.OBM_CHECKBOXES); 
    83         if (hBitmap is 0) { 
     65    static const int MARGIN = 4; 
     66    static const int CHECK_WIDTH, CHECK_HEIGHT; 
     67    static const int ICON_WIDTH = 128, ICON_HEIGHT = 128; 
     68    static const bool COMMAND_LINK = false; 
     69    static const TWindowProc ButtonProc; 
     70    static const TCHAR[] ButtonClass = "BUTTON\0"
     71    static this()
     72        auto hBitmap = OS.LoadBitmap (null, OS.OBM_CHECKBOXES); 
     73        if (hBitmap is null) { 
    8474            CHECK_WIDTH = OS.GetSystemMetrics (OS.IsWinCE ? OS.SM_CXSMICON : OS.SM_CXVSCROLL); 
    8575            CHECK_HEIGHT = OS.GetSystemMetrics (OS.IsWinCE ? OS.SM_CYSMICON : OS.SM_CYVSCROLL); 
    8676        } else { 
    87             BITMAP bitmap = new BITMAP ()
    88             OS.GetObject (hBitmap, BITMAP.sizeof, bitmap); 
     77            BITMAP bitmap
     78            OS.GetObject (hBitmap, BITMAP.sizeof, &bitmap); 
    8979            OS.DeleteObject (hBitmap); 
    9080            CHECK_WIDTH = bitmap.bmWidth / 4; 
    9181            CHECK_HEIGHT =  bitmap.bmHeight / 3; 
    9282        } 
    93         WNDCLASS lpWndClass = new WNDCLASS ()
    94         OS.GetClassInfo (0, ButtonClass, lpWndClass); 
     83        WNDCLASS lpWndClass
     84        OS.GetClassInfo (null, ButtonClass.ptr, &lpWndClass); 
    9585        ButtonProc = lpWndClass.lpfnWndProc; 
    9686    } 
     
    132122 * @see Widget#getStyle 
    133123 */ 
    134 public Button (Composite parent, int style) { 
     124public this (Composite parent, int style) { 
    135125    super (parent, checkStyle (style)); 
    136126} 
     
    150140                imageList.add (disabledImage); 
    151141            } 
    152             BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ()
     142            BUTTON_IMAGELIST buttonImageList
    153143            buttonImageList.himl = imageList.getHandle (); 
    154144            int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits; 
     
    157147            if ((style & DWT.CENTER) !is 0) newBits |= OS.BS_CENTER; 
    158148            if ((style & DWT.RIGHT) !is 0) newBits |= OS.BS_RIGHT; 
    159             if (text.length () is 0) { 
     149            if (text.length is 0) { 
    160150                if ((style & DWT.LEFT) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT; 
    161151                if ((style & DWT.CENTER) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_CENTER; 
     
    163153            } else { 
    164154                buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT; 
    165                 buttonImageList.margin_left = computeLeftMargin (); 
    166                 buttonImageList.margin_right = MARGIN; 
     155                buttonImageList.margin.left = computeLeftMargin (); 
     156                buttonImageList.margin.right = MARGIN; 
    167157                newBits &= ~(OS.BS_CENTER | OS.BS_RIGHT); 
    168158                newBits |= OS.BS_LEFT; 
     
    172162                OS.InvalidateRect (handle, null, true); 
    173163            } 
    174             OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList); 
     164            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, &buttonImageList); 
    175165        } else { 
    176166            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, 0); 
     
    185175        if (image2 !is null) image2.dispose (); 
    186176        image2 = null; 
    187         int hImage = 0, imageBits = 0, fImageType = 0; 
     177        HBITMAP hImage; 
     178        int imageBits = 0, fImageType = 0; 
    188179        if (image !is null) { 
    189180            switch (image.type) { 
     
    235226                if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) { 
    236227                    Rectangle rect = image.getBounds (); 
    237                     int hDC = OS.GetDC (handle); 
    238                     int dstHdc = OS.CreateCompatibleDC (hDC); 
    239                     int hBitmap = OS.CreateCompatibleBitmap (hDC, rect.width, rect.height); 
    240                     int oldBitmap = OS.SelectObject (dstHdc, hBitmap); 
     228                    auto hDC = OS.GetDC (handle); 
     229                    auto dstHdc = OS.CreateCompatibleDC (hDC); 
     230                    auto hBitmap = OS.CreateCompatibleBitmap (hDC, rect.width, rect.height); 
     231                    auto oldBitmap = OS.SelectObject (dstHdc, hBitmap); 
    241232                    OS.SetLayout (dstHdc, OS.LAYOUT_RTL); 
    242233                    if (fImageType is OS.IMAGE_BITMAP) { 
    243                         int srcHdc = OS.CreateCompatibleDC (hDC); 
    244                         int oldSrcBitmap = OS.SelectObject (srcHdc, hImage); 
     234                        auto srcHdc = OS.CreateCompatibleDC (hDC); 
     235                        auto oldSrcBitmap = OS.SelectObject (srcHdc, hImage); 
    245236                        OS.SetLayout (dstHdc, 0); 
    246237                        OS.BitBlt (dstHdc, 0, 0, rect.width, rect.height, srcHdc, 0, 0, OS.SRCCOPY); 
     
    250241                        Control control = findBackgroundControl (); 
    251242                        if (control is null) control = this; 
    252                         int newBrush = OS.CreateSolidBrush (control.getBackgroundPixel ()); 
    253                         int oldBrush = OS.SelectObject (dstHdc, newBrush); 
     243                        auto newBrush = OS.CreateSolidBrush (control.getBackgroundPixel ()); 
     244                        auto oldBrush = OS.SelectObject (dstHdc, newBrush); 
    254245                        OS.PatBlt (dstHdc, 0, 0, rect.width, rect.height, OS.PATCOPY); 
    255                         OS.DrawIconEx (dstHdc, 0, 0, hImage, 0, 0, 0, 0, OS.DI_NORMAL); 
     246                        OS.DrawIconEx (dstHdc, 0, 0, hImage, 0, 0, 0, null, OS.DI_NORMAL); 
    256247                        OS.SelectObject (dstHdc, oldBrush); 
    257248                        OS.DeleteObject (newBrush); 
     
    276267} 
    277268 
    278 void _setText (String text) { 
     269void _setText (char[] text) { 
    279270    int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits; 
    280271    if (OS.COMCTL32_MAJOR >= 6) { 
     
    284275        if ((style & DWT.RIGHT) !is 0) newBits |= OS.BS_RIGHT; 
    285276        if (imageList !is null) { 
    286             BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ()
     277            BUTTON_IMAGELIST buttonImageList
    287278            buttonImageList.himl = imageList.getHandle (); 
    288             if (text.length () is 0) { 
     279            if (text.length is 0) { 
    289280                if ((style & DWT.LEFT) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT; 
    290281                if ((style & DWT.CENTER) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_CENTER; 
     
    292283            } else { 
    293284                buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT; 
    294                 buttonImageList.margin_left = computeLeftMargin (); 
    295                 buttonImageList.margin_right = MARGIN; 
     285                buttonImageList.margin.left = computeLeftMargin (); 
     286                buttonImageList.margin.right = MARGIN; 
    296287                newBits &= ~(OS.BS_CENTER | OS.BS_RIGHT); 
    297288                newBits |= OS.BS_LEFT; 
    298289            } 
    299             OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList); 
     290            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, &buttonImageList); 
    300291        } 
    301292    } else { 
     
    313304    if ((style & DWT.RIGHT_TO_LEFT) !is 0) { 
    314305        if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) { 
    315             text = OS.IsWindowEnabled (handle) ? text : " " + text + " "; 
    316         } 
    317     } 
    318     TCHAR buffer = new TCHAR (getCodePage (), text, true); 
     306            text = OS.IsWindowEnabled (handle) ? text : " " ~ text ~ " "; 
     307        } 
     308    } 
     309    TCHAR* buffer = StrToTCHARz ( text ); 
    319310    OS.SetWindowText (handle, buffer); 
    320311} 
     
    352343} 
    353344 
    354 int callWindowProc (int hwnd, int msg, int wParam, int lParam) { 
    355     if (handle is 0) return 0
    356     return OS.CallWindowProc (ButtonProc, hwnd, msg, wParam, lParam); 
     345override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 
     346    if (handle is null) return LRESULT.ZERO
     347    return cast(LRESULT) ButtonProc( hwnd, msg, wParam, lParam); 
    357348} 
    358349 
     
    388379    if ((style & (DWT.PUSH | DWT.TOGGLE)) is 0) return MARGIN; 
    389380    int margin = 0; 
    390     if (image !is null && text.length () !is 0) { 
     381    if (image !is null && text.length !is 0) { 
    391382        Rectangle bounds = image.getBounds (); 
    392383        margin += bounds.width + MARGIN * 2; 
    393         int oldFont = 0
    394         int hDC = OS.GetDC (handle); 
    395         int newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    396         if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
    397         TCHAR buffer = new TCHAR (getCodePage (), text, true); 
    398         RECT rect = new RECT ()
     384        HFONT oldFont
     385        auto hDC = OS.GetDC (handle); 
     386        HFONT newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     387        if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
     388        TCHAR* buffer = StrToTCHARz(text); 
     389        RECT rect
    399390        int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE; 
    400         OS.DrawText (hDC, buffer, -1, rect, flags); 
     391        OS.DrawText (hDC, buffer, -1, &rect, flags); 
    401392        margin += rect.right - rect.left; 
    402         if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     393        if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    403394        OS.ReleaseDC (handle, hDC); 
    404         OS.GetClientRect (handle, rect); 
     395        OS.GetClientRect (handle, &rect); 
    405396        margin = Math.max (MARGIN, (rect.right - rect.left - margin) / 2); 
    406397    } 
     
    421412    } else { 
    422413        if ((style & DWT.COMMAND) !is 0) { 
    423             SIZE size = new SIZE ()
     414            SIZE size
    424415            if (wHint !is DWT.DEFAULT) { 
    425416                size.cx = wHint; 
    426                 OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, size); 
     417                OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, &size); 
    427418                width = size.cx; 
    428419                height = size.cy; 
    429420            } else { 
    430                 OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, size); 
     421                OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, &size); 
    431422                width = size.cy; 
    432423                height = size.cy; 
     
    435426                    size.cx = width++; 
    436427                    size.cy = 0; 
    437                     OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, size); 
     428                    OS.SendMessage (handle, OS.BCM_GETIDEALSIZE, 0, &size); 
    438429                } 
    439430            } 
     
    452443                    Rectangle rect = image.getBounds (); 
    453444                    width = rect.width; 
    454                     if (hasText && text.length () !is 0) { 
     445                    if (hasText && text.length !is 0) { 
    455446                        width += MARGIN * 2; 
    456447                    } 
     
    460451            } 
    461452            if (hasText) { 
    462                 int oldFont = 0
    463                 int hDC = OS.GetDC (handle); 
    464                 int newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    465                 if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
    466                 TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC) new TEXTMETRICW () : new TEXTMETRICA ()
    467                 OS.GetTextMetrics (hDC, lptm); 
    468                 int length = text.length ()
    469                 if (length is 0) { 
     453                HFONT oldFont
     454                auto hDC = OS.GetDC (handle); 
     455                auto newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     456                if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
     457                TEXTMETRIC lptm
     458                OS.GetTextMetrics (hDC, &lptm); 
     459                int length_ = text.length
     460                if (length_ is 0) { 
    470461                    height = Math.max (height, lptm.tmHeight); 
    471462                } else { 
    472463                    extra = Math.max (MARGIN * 2, lptm.tmAveCharWidth); 
    473                     TCHAR buffer = new TCHAR (getCodePage (), text, true); 
    474                     RECT rect = new RECT ()
     464                    TCHAR* buffer = StrToTCHARz(text); 
     465                    RECT rect
    475466                    int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE; 
    476                     OS.DrawText (hDC, buffer, -1, rect, flags); 
     467                    OS.DrawText (hDC, buffer, -1, &rect, flags); 
    477468                    width += rect.right - rect.left; 
    478469                    height = Math.max (height, rect.bottom - rect.top); 
    479470                } 
    480                 if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     471                if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    481472                OS.ReleaseDC (handle, hDC); 
    482473            } 
     
    540531            bool hasImage = (bits & (OS.BS_BITMAP | OS.BS_ICON)) !is 0; 
    541532            if (!hasImage) { 
    542                 String string = enabled ? text : " " + text + " "; 
    543                 TCHAR buffer = new TCHAR (getCodePage (), string, true); 
     533                char[] string = enabled ? text : " " ~ text ~ " "; 
     534                TCHAR* buffer = StrToTCHARz (string); 
    544535                OS.SetWindowText (handle, buffer); 
    545536            } 
     
    558549    if (OS.COMCTL32_MAJOR >= 6) { 
    559550        if (imageList !is null) { 
    560             BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ()
    561             OS.SendMessage (handle, OS.BCM_GETIMAGELIST, 0, buttonImageList); 
     551            BUTTON_IMAGELIST buttonImageList
     552            OS.SendMessage (handle, OS.BCM_GETIMAGELIST, 0, &buttonImageList); 
    562553            if (imageList !is null) imageList.dispose (); 
    563554            imageList = new ImageList (style & DWT.RIGHT_TO_LEFT); 
     
    570561            } 
    571562            buttonImageList.himl = imageList.getHandle (); 
    572             OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList); 
     563            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, &buttonImageList); 
    573564            /* 
    574565            * Bug in Windows.  Under certain cirumstances yet to be 
     
    648639 * @since 3.3 
    649640 */ 
    650 /*public*/ String getMessage () { 
     641/*public*/ char[] getMessage () { 
    651642    checkWidget (); 
    652643    return message; 
    653644} 
    654645 
    655 String getNameText () { 
     646char[] getNameText () { 
    656647    return getText (); 
    657648} 
     
    692683 * </ul> 
    693684 */ 
    694 public String getText () { 
     685public char[] getText () { 
    695686    checkWidget (); 
    696687    if ((style & DWT.ARROW) !is 0) return ""; 
     
    704695} 
    705696 
    706 bool mnemonicHit (char ch) { 
     697bool mnemonicHit (wchar ch) { 
    707698    if (!setFocus ()) return false; 
    708699    /* 
     
    716707} 
    717708 
    718 bool mnemonicMatch (char key) { 
    719     char mnemonic = findMnemonic (getText ()); 
     709bool mnemonicMatch (wchar key) { 
     710    wchar mnemonic = findMnemonic (getText ()); 
    720711    if (mnemonic is '\0') return false; 
    721     return Character.toUpperCase (key) is Character.toUpperCase (mnemonic); 
     712    return CharacterToUpper (key) is CharacterToUpper (mnemonic); 
    722713} 
    723714 
     
    819810    if (OS.COMCTL32_MAJOR >= 6) { 
    820811        if (imageList !is null) { 
    821             BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ()
     812            BUTTON_IMAGELIST buttonImageList
    822813            buttonImageList.himl = imageList.getHandle (); 
    823             if (text.length () is 0) { 
     814            if (text.length is 0) { 
    824815                if ((style & DWT.LEFT) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT; 
    825816                if ((style & DWT.CENTER) !is 0) buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_CENTER; 
     
    827818            } else { 
    828819                buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT; 
    829                 buttonImageList.margin_left = computeLeftMargin (); 
    830                 buttonImageList.margin_right = MARGIN; 
     820                buttonImageList.margin.left = computeLeftMargin (); 
     821                buttonImageList.margin.right = MARGIN; 
    831822                newBits &= ~(OS.BS_CENTER | OS.BS_RIGHT); 
    832823                newBits |= OS.BS_LEFT; 
    833824            } 
    834             OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList); 
     825            OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, &buttonImageList); 
    835826        } 
    836827    } 
     
    843834void setDefault (bool value) { 
    844835    if ((style & DWT.PUSH) is 0) return; 
    845     int hwndShell = menuShell ().handle; 
     836    auto hwndShell = menuShell ().handle; 
    846837    int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 
    847838    if (value) { 
     
    891882    /* This code is intentionally commented */ 
    892883//  if (OS.COMCTL32_MAJOR < 6) { 
    893 //      if (image is null || text.length () !is 0) { 
     884//      if (image is null || text.length !is 0) { 
    894885//          _setText (text); 
    895886//          return; 
     
    916907 * @since 3.3 
    917908 */ 
    918 /*public*/ void setMessage (String message) { 
     909/*public*/ void setMessage (char[] message) { 
    919910    checkWidget (); 
    920911    if (message is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    922913    if (OS.COMCTL32_VERSION >= OS.VERSION (6, 1)) { 
    923914        if ((style & DWT.COMMAND) !is 0) { 
    924             int length = message.length (); 
    925             char [] chars = new char [length + 1]; 
    926             message.getChars(0, length, chars, 0); 
    927             OS.SendMessage (handle, OS.BCM_SETNOTE, 0, chars); 
     915            OS.SendMessage (handle, OS.BCM_SETNOTE, 0, StrToTCHARz( message )); 
    928916        } 
    929917    } 
     
    10201008 * </ul> 
    10211009 */ 
    1022 public void setText (String string) { 
     1010public void setText (char[] string) { 
    10231011    checkWidget (); 
    10241012    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    10271015    /* This code is intentionally commented */ 
    10281016//  if (OS.COMCTL32_MAJOR < 6) { 
    1029 //      if (text.length () is 0 && image !is null) { 
     1017//      if (text.length is 0 && image !is null) { 
    10301018//          _setImage (image); 
    10311019//          return; 
     
    10501038} 
    10511039 
    1052 TCHAR windowClass () { 
    1053     return ButtonClass
     1040char[] windowClass () { 
     1041    return TCHARzToStr( ButtonClass.ptr )
    10541042} 
    10551043 
    10561044int windowProc () { 
    1057     return ButtonProc; 
     1045    return cast(int) ButtonProc; 
    10581046} 
    10591047 
     
    10611049LRESULT WM_ERASEBKGND (int wParam, int lParam) { 
    10621050    LRESULT result = super.WM_ERASEBKGND (wParam, lParam); 
    1063     if (result !is null) return result; 
     1051    if (result !is LRESULT.NULL) return result; 
    10641052    /* 
    10651053    * Bug in Windows.  For some reason, the HBRUSH that 
     
    10731061        if ((style & (DWT.RADIO | DWT.CHECK)) !is 0) { 
    10741062            if (findImageControl () !is null) { 
    1075                 drawBackground (wParam); 
     1063                drawBackground (cast(HWND)wParam); 
    10761064                return LRESULT.ONE; 
    10771065            } 
     
    10831071LRESULT WM_GETDLGCODE (int wParam, int lParam) { 
    10841072    LRESULT result = super.WM_GETDLGCODE (wParam, lParam); 
    1085     if (result !is null) return result; 
     1073    if (result !is LRESULT.NULL) return result; 
    10861074    if ((style & DWT.ARROW) !is 0) { 
    1087         return new LRESULT (OS.DLGC_STATIC); 
     1075        return cast( LRESULT )(OS.DLGC_STATIC); 
    10881076    } 
    10891077    return result; 
     
    10991087 
    11001088LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { 
    1101     if (ignoreMouse) return null
     1089    if (ignoreMouse) return LRESULT.NULL
    11021090    return super.WM_LBUTTONDOWN (wParam, lParam); 
    11031091} 
    11041092 
    11051093LRESULT WM_LBUTTONUP (int wParam, int lParam) { 
    1106     if (ignoreMouse) return null
     1094    if (ignoreMouse) return LRESULT.NULL
    11071095    return super.WM_LBUTTONUP (wParam, lParam); 
    11081096} 
     
    11311119LRESULT WM_SIZE (int wParam, int lParam) { 
    11321120    LRESULT result = super.WM_SIZE (wParam, lParam); 
    1133     if (result !is null) return result; 
     1121    if (result !is LRESULT.NULL) return result; 
    11341122    if (OS.COMCTL32_MAJOR >= 6) { 
    11351123        if ((style & (DWT.PUSH | DWT.TOGGLE)) !is 0) { 
    1136             if (imageList !is null && text.length () !is 0) { 
    1137                 BUTTON_IMAGELIST buttonImageList = new BUTTON_IMAGELIST ()
    1138                 OS.SendMessage (handle, OS.BCM_GETIMAGELIST, 0, buttonImageList); 
     1124            if (imageList !is null && text.length !is 0) { 
     1125                BUTTON_IMAGELIST buttonImageList
     1126                OS.SendMessage (handle, OS.BCM_GETIMAGELIST, 0, &buttonImageList); 
    11391127                buttonImageList.uAlign = OS.BUTTON_IMAGELIST_ALIGN_LEFT; 
    1140                 buttonImageList.margin_left = computeLeftMargin (); 
    1141                 buttonImageList.margin_right = MARGIN; 
    1142                 OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, buttonImageList); 
     1128                buttonImageList.margin.left = computeLeftMargin (); 
     1129                buttonImageList.margin.right = MARGIN; 
     1130                OS.SendMessage (handle, OS.BCM_SETIMAGELIST, 0, &buttonImageList); 
    11431131            } 
    11441132        } 
     
    11491137LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) { 
    11501138    LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam); 
    1151     if (result !is null) return result; 
     1139    if (result !is LRESULT.NULL) return result; 
    11521140    if (image2 !is null) _setImage (image); 
    11531141    return result; 
     
    11561144LRESULT WM_UPDATEUISTATE (int wParam, int lParam) { 
    11571145    LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam); 
    1158     if (result !is null) return result; 
     1146    if (result !is LRESULT.NULL) return result; 
    11591147    /* 
    11601148    * Feature in Windows.  When WM_UPDATEUISTATE is sent to 
     
    11821170                OS.InvalidateRect (handle, null, false); 
    11831171                int code = OS.DefWindowProc (handle, OS.WM_UPDATEUISTATE, wParam, lParam); 
    1184                 return new LRESULT (code); 
     1172                return cast( LRESULT )(code); 
    11851173            } 
    11861174        } 
     
    12231211        if ((style & (DWT.RADIO | DWT.CHECK)) !is 0) { 
    12241212            if (findImageControl () !is null) { 
    1225                 OS.SetBkMode (wParam, OS.TRANSPARENT); 
    1226                 return new LRESULT (OS.GetStockObject (OS.NULL_BRUSH)); 
     1213                OS.SetBkMode (cast(HANDLE)wParam, OS.TRANSPARENT); 
     1214                return cast( LRESULT )(OS.GetStockObject (OS.NULL_BRUSH)); 
    12271215            } 
    12281216        } 
     
    12331221LRESULT wmDrawChild (int wParam, int lParam) { 
    12341222    if ((style & DWT.ARROW) is 0) return super.wmDrawChild (wParam, lParam); 
    1235     DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ()
    1236     OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof); 
    1237     RECT rect = new RECT ()
    1238     OS.SetRect (rect, struct.left, struct.top, struct.right, struct.bottom); 
     1223    auto struct_ = cast(DRAWITEMSTRUCT*)lParam
     1224    //OS.MoveMemory (struct_, lParam, DRAWITEMSTRUCT.sizeof); 
     1225    RECT rect
     1226    OS.SetRect (&rect, struct_.rcItem.left, struct_.rcItem.top, struct_.rcItem.right, struct_.rcItem.bottom); 
    12391227    if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 
    12401228        int iStateId = OS.ABS_LEFTNORMAL; 
     
    12511239        */ 
    12521240        if (!getEnabled ()) iStateId += OS.ABS_UPDISABLED - OS.ABS_UPNORMAL; 
    1253         if ((struct.itemState & OS.ODS_SELECTED) !is 0) iStateId += OS.ABS_UPPRESSED - OS.ABS_UPNORMAL; 
    1254         OS.DrawThemeBackground (display.hScrollBarTheme (), struct.hDC, OS.SBP_ARROWBTN, iStateId, rect, null); 
     1241        if ((struct_.itemState & OS.ODS_SELECTED) !is 0) iStateId += OS.ABS_UPPRESSED - OS.ABS_UPNORMAL; 
     1242        OS.DrawThemeBackground (display.hScrollBarTheme (), struct_.hDC, OS.SBP_ARROWBTN, iStateId, &rect, null); 
    12551243    } else { 
    12561244        int uState = OS.DFCS_SCROLLLEFT; 
     
    12631251        if (!getEnabled ()) uState |= OS.DFCS_INACTIVE; 
    12641252        if ((style & DWT.FLAT) is DWT.FLAT) uState |= OS.DFCS_FLAT; 
    1265         if ((struct.itemState & OS.ODS_SELECTED) !is 0) uState |= OS.DFCS_PUSHED; 
    1266         OS.DrawFrameControl (struct.hDC, rect, OS.DFC_SCROLL, uState); 
    1267     } 
    1268     return null; 
    1269 
    1270  
    1271 
    1272 ++/ 
     1253        if ((struct_.itemState & OS.ODS_SELECTED) !is 0) uState |= OS.DFCS_PUSHED; 
     1254        OS.DrawFrameControl (struct_.hDC, &rect, OS.DFC_SCROLL, uState); 
     1255    } 
     1256    return LRESULT.NULL; 
     1257
     1258 
     1259