Changeset 75:f824f1836871

Show
Ignore:
Timestamp:
02/04/08 21:50:39 (1 year ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Tree

Files:

Legend:

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

    r70 r75  
    43644364alias WINAPI.InterlockedDecrement InterlockedDecrement; 
    43654365alias WINAPI.InterlockedIncrement InterlockedIncrement; 
     4366alias WINAPI.IntersectClipRect IntersectClipRect; 
    43664367alias WINAPI.IntersectRect IntersectRect; 
    43674368alias WINAPI.InvalidateRect InvalidateRect; 
  • dwt/internal/win32/WINAPI.d

    r67 r75  
    153153    LPCWSTR pszSubAppName, 
    154154    LPCWSTR pszSubIdList 
     155); 
     156int IntersectClipRect( 
     157  HDC hdc,         // handle to DC 
     158  int nLeftRect,   // x-coord of upper-left corner 
     159  int nTopRect,    // y-coord of upper-left corner 
     160  int nRightRect,  // x-coord of lower-right corner 
     161  int nBottomRect  // y-coord of lower-right corner 
    155162); 
    156163} 
  • dwt/internal/win32/WINTYPES.d

    r69 r75  
    7070    int idNew; 
    7171    DWORD dwFlags; 
     72} 
     73struct NMTVDISPINFO { 
     74    NMHDR hdr; 
     75    TVITEM item; 
     76} 
     77struct NMTVITEMCHANGE { 
     78    NMHDR hdr; 
     79    UINT uChanged; 
     80    HTREEITEM hItem; 
     81    UINT uStateNew; 
     82    UINT uStateOld; 
     83    LPARAM lParam; 
    7284} 
    7385// .... 
     
    20822094alias ULARGE_INTEGER * PULARGE_INTEGER; 
    20832095 
     2096alias extern(Windows) int (*PFNTVCOMPARE)(LPARAM, LPARAM, LPARAM); 
     2097struct TVSORTCB { 
     2098    HTREEITEM hParent; 
     2099    PFNTVCOMPARE lpfnCompare; 
     2100    LPARAM lParam; 
     2101} 
     2102 
     2103 
     2104 
     2105 
    20842106//struct WINDOWPLACEMENT { 
    20852107//    UINT length; 
     
    20912113//} 
    20922114// 
    2093 struct WINDOWPOS { 
    2094     HWND hwnd; 
    2095     HWND hwndInsertAfter; 
    2096     int x; 
    2097     int y; 
    2098     int cx; 
    2099     int cy; 
    2100     UINT flags; 
    2101 
     2115// struct WINDOWPOS { 
     2116//     HWND hwnd; 
     2117//     HWND hwndInsertAfter; 
     2118//     int x; 
     2119//     int y; 
     2120//     int cx; 
     2121//     int cy; 
     2122//     UINT flags; 
     2123//
    21022124 
    21032125// WNDCLASSA is declared in phobos 
  • dwt/widgets/Composite.d

    r54 r75  
    743743//          } 
    744744            if (defer) { 
    745                 hdwp = DeferWindowPos (hdwp, wp.hwnd, null, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 
     745                hdwp = DeferWindowPos (hdwp, wp._hwnd, null, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 
    746746                if (hdwp is null) return false; 
    747747            } else { 
    748                 SetWindowPos (wp.hwnd, null, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 
     748                SetWindowPos (wp._hwnd, null, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 
    749749            } 
    750750        } 
  • dwt/widgets/Control.d

    r54 r75  
    10131013    for (int i=0; i<lpwp.length; i++) { 
    10141014        WINDOWPOS* wp = lpwp [i]; 
    1015         if (wp !is null && wp.hwnd is handle) { 
     1015        if (wp !is null && wp._hwnd is handle) { 
    10161016            /* 
    10171017            * This code is intentionally commented.  All widgets that 
     
    10241024//              if ((bits & OS.WS_CLIPSIBLINGS) is 0) wp.flags |= OS.SWP_NOCOPYBITS; 
    10251025//          } 
    1026             SetWindowPos (wp.hwnd, null, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 
     1026            SetWindowPos (wp._hwnd, null, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 
    10271027            lpwp [i] = null; 
    10281028            return; 
     
    25732573            } 
    25742574            WINDOWPOS* wp = new WINDOWPOS; 
    2575             wp.hwnd = topHandle_; 
     2575            wp._hwnd = topHandle_; 
    25762576            wp.x = x; 
    25772577            wp.y = y; 
  • dwt/widgets/Display.d

    r73 r75  
    12741274    checkDevice (); 
    12751275    Control control = getControl (handle); 
    1276     return control !is null ? control.findItem (id) : null; 
     1276    return control !is null ? control.findItem (cast(HANDLE) id) : null; 
    12771277} 
    12781278 
  • dwt/widgets/Tree.d

    r74 r75  
    107107    TreeColumn sortColumn; 
    108108    HWND hwndParent, hwndHeader; 
    109     HANDLE hAnchor, hInsert, lastID, hSelect; 
    110     int hFirstIndexOf, hLastIndexOf, lastIndexOf, itemCount, sortDirection; 
     109    HANDLE hAnchor, hInsert, hSelect; 
     110    int lastID; 
     111    HANDLE hFirstIndexOf, hLastIndexOf; 
     112    int lastIndexOf, itemCount, sortDirection; 
    111113    bool dragStarted, gestureCompleted, insertAfter, shrink, ignoreShrink; 
    112114    bool ignoreSelect, ignoreExpand, ignoreDeselect, ignoreResize; 
     
    115117    bool ignoreCustomDraw, ignoreDrawForeground, ignoreDrawBackground, ignoreDrawFocus; 
    116118    bool ignoreDrawSelection, ignoreDrawHot, ignoreFullSelection, explorerTheme; 
    117     int scrollWidth, itemToolTipHandle, selectionForeground; 
    118     HANDLE headerToolTipHandle
     119    int scrollWidth, selectionForeground; 
     120    HANDLE headerToolTipHandle, itemToolTipHandle
    119121    static const int INSET = 3; 
    120122    static const int GRID_WIDTH = 1; 
     
    125127    static const int EXPLORER_EXTRA = 2; 
    126128    static const bool EXPLORER_THEME = true; 
    127     static const int TreeProc; 
     129    static const WNDPROC TreeProc; 
    128130    static const TCHAR[] TreeClass = OS.WC_TREEVIEW; 
    129131    static const WNDPROC HeaderProc; 
    130132    static const TCHAR[] HeaderClass = OS.WC_HEADER; 
    131133    static this() { 
    132         WNDCLASS lpWndClass = new WNDCLASS ()
    133         OS.GetClassInfo (0, TreeClass, lpWndClass); 
     134        WNDCLASS lpWndClass
     135        OS.GetClassInfo (null, TreeClass.ptr, &lpWndClass); 
    134136        TreeProc = lpWndClass.lpfnWndProc; 
    135         OS.GetClassInfo (0, HeaderClass, lpWndClass); 
     137        OS.GetClassInfo (null, HeaderClass.ptr, &lpWndClass); 
    136138        HeaderProc = lpWndClass.lpfnWndProc; 
    137139    } 
    138  
     140    private static Tree sThis; 
    139141/** 
    140142 * Constructs a new instance of this class given its parent 
     
    237239 
    238240TreeItem _getItem (HANDLE hItem) { 
    239     TVITEM tvItem = new TVITEM ()
     241    TVITEM tvItem
    240242    tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM; 
    241243    tvItem.hItem = hItem; 
    242     if (OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem) !is 0) { 
     244    if (OS.SendMessage (handle, OS.TVM_GETITEM, 0, &tvItem) !is 0) { 
    243245        return _getItem (tvItem.hItem, tvItem.lParam); 
    244246    } 
     
    248250TreeItem _getItem (HANDLE hItem, int id) { 
    249251    if ((style & DWT.VIRTUAL) is 0) return items [id]; 
    250     return id !is -1 ? items [id] : new TreeItem (this, DWT.NONE, -1, -1, hItem); 
     252    return id !is -1 ? items [id] : new TreeItem (this, DWT.NONE, cast(HANDLE)-1, cast(HANDLE)-1, hItem); 
    251253} 
    252254 
     
    352354 
    353355override HWND borderHandle () { 
    354     return hwndParent !is 0 ? hwndParent : handle; 
    355 } 
    356  
    357 LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, int wParam, int lParam) { 
    358     if (ignoreCustomDraw) return null
    359     if (nmcd.left is nmcd.right) return new LRESULT (OS.CDRF_DODEFAULT); 
    360     int hDC = nmcd.hdc; 
     356    return hwndParent !is null ? hwndParent : handle; 
     357} 
     358 
     359LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW* nmcd, int wParam, int lParam) { 
     360    if (ignoreCustomDraw) return LRESULT.NULL
     361    if (nmcd.nmcd.rc.left is nmcd.nmcd.rc.right) return cast(LRESULT) (OS.CDRF_DODEFAULT); 
     362    auto hDC = nmcd.nmcd.hdc; 
    361363    OS.RestoreDC (hDC, -1); 
    362364    TreeItem item = getItem (nmcd); 
     
    372374    * COMCTL32.DLL, 
    373375    */ 
    374     if (item is null) return null
     376    if (item is null) return LRESULT.NULL
    375377 
    376378    /* 
     
    385387    * TVM_SETITEM. 
    386388    */ 
    387     if (nmcd.left >= nmcd.right || nmcd.top >= nmcd.bottom) return null
    388     if (!OS.IsWindowVisible (handle)) return null
     389    if (nmcd.nmcd.rc.left >= nmcd.nmcd.rc.right || nmcd.nmcd.rc.top >= nmcd.nmcd.rc.bottom) return LRESULT.NULL
     390    if (!OS.IsWindowVisible (handle)) return LRESULT.NULL
    389391    if ((style & DWT.FULL_SELECTION) !is 0 || findImageControl () !is null || ignoreDrawSelection || explorerTheme) { 
    390392        OS.SetBkMode (hDC, OS.TRANSPARENT); 
    391393    } 
    392394    bool selected = isItemSelected (nmcd); 
    393     bool hot = explorerTheme && (nmcd.uItemState & OS.CDIS_HOT) !is 0; 
     395    bool hot = explorerTheme && (nmcd.nmcd.uItemState & OS.CDIS_HOT) !is 0; 
    394396    if (OS.IsWindowEnabled (handle)) { 
    395397        if (explorerTheme) { 
     
    406408    int count = 0; 
    407409    int [] order = null; 
    408     RECT clientRect = new RECT ()
    409     OS.GetClientRect (scrolledHandle (), clientRect); 
    410     if (hwndHeader !is 0) { 
    411         OS.MapWindowPoints (hwndParent, handle, clientRect, 2); 
     410    RECT clientRect
     411    OS.GetClientRect (scrolledHandle (), &clientRect); 
     412    if (hwndHeader !is null) { 
     413        OS.MapWindowPoints (hwndParent, handle, cast(POINT*) &clientRect, 2); 
    412414        count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 
    413415        if (count !is 0) { 
    414416            order = new int [count]; 
    415             OS.SendMessage (hwndHeader, OS.HDM_GETORDERARRAY, count, order); 
     417            OS.SendMessage (hwndHeader, OS.HDM_GETORDERARRAY, count, cast(int) order.ptr); 
    416418        } 
    417419    } 
     
    428430    Point size = null; 
    429431    for (int i=0; i<Math.max (1, count); i++) { 
    430         int index = order is null ? i : order [i], width = nmcd.right - nmcd.left; 
    431         if (count > 0 && hwndHeader !is 0) { 
    432             HDITEM hdItem = new HDITEM ()
     432        int index = order is null ? i : order [i], width = nmcd.nmcd.rc.right - nmcd.nmcd.rc.left; 
     433        if (count > 0 && hwndHeader !is null) { 
     434            HDITEM hdItem
    433435            hdItem.mask = OS.HDI_WIDTH; 
    434             OS.SendMessage (hwndHeader, OS.HDM_GETITEM, index, hdItem); 
     436            OS.SendMessage (hwndHeader, OS.HDM_GETITEM, index, &hdItem); 
    435437            width = hdItem.cxy; 
    436438        } 
     
    440442                if (clear || (selected && !ignoreDrawSelection) || (hot && !ignoreDrawHot)) { 
    441443                    bool draw = true; 
    442                     RECT pClipRect = new RECT ()
    443                     OS.SetRect (pClipRect, width, nmcd.top, nmcd.right, nmcd.bottom); 
     444                    RECT pClipRect
     445                    OS.SetRect (&pClipRect, width, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom); 
    444446                    if (explorerTheme) { 
    445447                        if (hooks (DWT.EraseItem)) { 
     
    449451                            pClipRect.left = itemRect.left; 
    450452                            pClipRect.right = itemRect.right; 
    451                             if (count > 0 && hwndHeader !is 0) { 
    452                                 HDITEM hdItem = new HDITEM ()
     453                            if (count > 0 && hwndHeader !is null) { 
     454                                HDITEM hdItem
    453455                                hdItem.mask = OS.HDI_WIDTH; 
    454                                 OS.SendMessage (hwndHeader, OS.HDM_GETITEM, index, hdItem); 
    455                                 pClipRect.right = Math.min (pClipRect.right, nmcd.left + hdItem.cxy); 
     456                                OS.SendMessage (hwndHeader, OS.HDM_GETITEM, index, &hdItem); 
     457                                pClipRect.right = Math.min (pClipRect.right, nmcd.nmcd.rc.left + hdItem.cxy); 
    456458                            } 
    457459                        } 
    458                         RECT pRect = new RECT ()
    459                         OS.SetRect (pRect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom); 
    460                         if (count > 0 && hwndHeader !is 0) { 
     460                        RECT pRect
     461                        OS.SetRect (&pRect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom); 
     462                        if (count > 0 && hwndHeader !is null) { 
    461463                            int totalWidth = 0; 
    462                             HDITEM hdItem = new HDITEM ()
     464                            HDITEM hdItem
    463465                            hdItem.mask = OS.HDI_WIDTH; 
    464466                            for (int j=0; j<count; j++) { 
    465                                 OS.SendMessage (hwndHeader, OS.HDM_GETITEM, j, hdItem); 
     467                                OS.SendMessage (hwndHeader, OS.HDM_GETITEM, j, &hdItem); 
    466468                                totalWidth += hdItem.cxy; 
    467469                            } 
     
    475477                        } 
    476478                        draw = false; 
    477                         int hTheme = OS.OpenThemeData (handle, Display.TREEVIEW); 
     479                        auto hTheme = OS.OpenThemeData (handle, cast(TCHAR*) Display.TREEVIEW); 
    478480                        int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT; 
    479481                        if (OS.GetFocus () !is handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS; 
    480                         OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, pRect, pClipRect); 
     482                        OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, &pRect, &pClipRect); 
    481483                        OS.CloseThemeData (hTheme); 
    482484                    } 
    483                     if (draw) fillBackground (hDC, OS.GetBkColor (hDC), pClipRect); 
     485                    if (draw) fillBackground (hDC, OS.GetBkColor (hDC), &pClipRect); 
    484486                } 
    485487            } else { 
     
    492494                        pClipRect.left -= EXPLORER_EXTRA; 
    493495                        pClipRect.right += EXPLORER_EXTRA; 
    494                         int hTheme = OS.OpenThemeData (handle, Display.TREEVIEW); 
     496                        auto hTheme = OS.OpenThemeData (handle, cast(TCHAR*) Display.TREEVIEW); 
    495497                        int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT; 
    496498                        if (OS.GetFocus () !is handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS; 
    497                         OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, pRect, pClipRect); 
     499                        OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, &pRect, &pClipRect); 
    498500                        OS.CloseThemeData (hTheme); 
    499501                    } 
     
    502504        } 
    503505        if (x + width > clientRect.left) { 
    504             RECT rect = new RECT (), backgroundRect = null; 
     506            RECT rect; 
     507            RECT* backgroundRect = null; 
     508            RECT rectTmp; 
    505509            bool drawItem = true, drawText = true, drawImage = true, drawBackground = false; 
    506510            if (i is 0) { 
     
    526530                                    gc.setClipping (iconRect.left, iconRect.top, iconRect.right - iconRect.left, iconRect.bottom - iconRect.top); 
    527531                                    gc.drawImage (image, 0, 0, bounds.width, bounds.height, iconRect.left, iconRect.top, size.x, size.y); 
    528                                     OS.SelectClipRgn (hDC, 0); 
     532                                    OS.SelectClipRgn (hDC, null); 
    529533                                    gc.dispose (); 
    530534                                } 
     
    541545                } 
    542546                if (selected && !ignoreDrawSelection && !ignoreDrawBackground) { 
    543                     if (!explorerTheme) fillBackground (hDC, OS.GetBkColor (hDC), rect); 
     547                    if (!explorerTheme) fillBackground (hDC, OS.GetBkColor (hDC), &rect); 
    544548                    drawBackground = false; 
    545549                } 
    546                 backgroundRect = rect; 
     550                backgroundRect = &rect; 
    547551                if (hooks (DWT.EraseItem)) { 
    548552                    drawItem = drawText = drawImage = true; 
    549553                    rect = item.getBounds (index, true, true, false, false, true, hDC); 
    550554                    if ((style & DWT.FULL_SELECTION) !is 0) { 
    551                         backgroundRect = rect; 
     555                        backgroundRect = &rect; 
    552556                    } else { 
    553                         backgroundRect = item.getBounds (index, true, false, false, false, true, hDC); 
     557                        rectTmp = item.getBounds (index, true, false, false, false, true, hDC); 
     558                        backgroundRect = &rectTmp; 
    554559                    } 
    555560                } 
     
    557562                selectionForeground = -1; 
    558563                ignoreDrawForeground = ignoreDrawBackground = ignoreDrawSelection = ignoreDrawFocus = ignoreDrawHot = false; 
    559                 OS.SetRect (rect, x, nmcd.top, x + width, nmcd.bottom); 
    560                 backgroundRect = rect; 
     564                OS.SetRect (&rect, x, nmcd.nmcd.rc.top, x + width, nmcd.nmcd.rc.bottom); 
     565                backgroundRect = &rect; 
    561566            } 
    562567            int clrText = -1, clrTextBk = -1; 
    563             int hFont = item.cellFont !is null ? item.cellFont [index] : -1; 
    564             if (hFont is -1) hFont = item.font; 
     568            HFONT hFont = item.cellFont !is null ? item.cellFont [index] : cast(HFONT)-1; 
     569            if (hFont is cast(HFONT)-1) hFont = item.font; 
    565570            if (selectionForeground !is -1) clrText = selectionForeground; 
    566571            if (OS.IsWindowEnabled (handle)) { 
     
    591596            } 
    592597            if (explorerTheme) { 
    593                 if (selected || (nmcd.uItemState & OS.CDIS_HOT) !is 0) { 
     598                if (selected || (nmcd.nmcd.uItemState & OS.CDIS_HOT) !is 0) { 
    594599                    if ((style & DWT.FULL_SELECTION) !is 0) { 
    595600                        drawBackground = false; 
     
    651656                            if (!explorerTheme) { 
    652657                                //if ((nmcd.uItemState & OS.CDIS_FOCUS) !is 0) { 
    653                                 if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0) is nmcd.dwItemSpec) { 
     658                                if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0) is nmcd.nmcd.dwItemSpec) { 
    654659                                    if (handle is OS.GetFocus ()) { 
    655660                                        int uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0); 
     
    697702                                        } 
    698703                                        if (!ignoreFullSelection && index is count - 1) { 
    699                                             RECT selectionRect = new RECT (); 
    700                                             OS.SetRect (selectionRect, backgroundRect.left, backgroundRect.top, nmcd.right, backgroundRect.bottom); 
     704                                            RECT* selectionRect = new RECT (); 
     705                                            OS.SetRect (selectionRect, backgroundRect.left, backgroundRect.top, nmcd.nmcd.rc.right, backgroundRect.bottom); 
    701706                                            backgroundRect = selectionRect; 
    702707                                        } 
    703708                                    } else { 
    704                                         RECT pRect = new RECT ()
    705                                         OS.SetRect (pRect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom); 
    706                                         if (count > 0 && hwndHeader !is 0) { 
     709                                        RECT pRect
     710                                        OS.SetRect (&pRect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom); 
     711                                        if (count > 0 && hwndHeader !is null) { 
    707712                                            int totalWidth = 0; 
    708                                             HDITEM hdItem = new HDITEM ()
     713                                            HDITEM hdItem
    709714                                            hdItem.mask = OS.HDI_WIDTH; 
    710715                                            for (int j=0; j<count; j++) { 
    711                                                 OS.SendMessage (hwndHeader, OS.HDM_GETITEM, j, hdItem); 
     716                                                OS.SendMessage (hwndHeader, OS.HDM_GETITEM, j, &hdItem); 
    712717                                                totalWidth += hdItem.cxy; 
    713718                                            } 
     
    720725                                            } 
    721726                                            if (index is count - 1) { 
    722                                                 RECT selectionRect = new RECT (); 
     727                                                RECT* selectionRect = new RECT (); 
    723728                                                OS.SetRect (selectionRect, backgroundRect.left, backgroundRect.top, pRect.right, backgroundRect.bottom); 
    724729                                                backgroundRect = selectionRect; 
    725730                                            } 
    726731                                        } 
    727                                         int hTheme = OS.OpenThemeData (handle, Display.TREEVIEW); 
     732                                        auto hTheme = OS.OpenThemeData (handle, cast(TCHAR*) Display.TREEVIEW); 
    728733                                        int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT; 
    729734                                        if (OS.GetFocus () !is handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS; 
    730                                         OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, pRect, backgroundRect); 
     735                                        OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, &pRect, backgroundRect); 
    731736                                        OS.CloseThemeData (hTheme); 
    732737                                    } 
     
    756761                            if (i is 0) { 
    757762                                int right = Math.min (rect.right, width); 
    758                                 OS.SetRect (rect, rect.left, rect.top, right, rect.bottom); 
    759                                 if (drawBackground) fillImageBackground (hDC, control, rect); 
     763                                OS.SetRect (&rect, rect.left, rect.top, right, rect.bottom); 
     764                                if (drawBackground) fillImageBackground (hDC, control, &rect); 
    760765                            } else { 
    761                                 if (drawBackground) fillImageBackground (hDC, control, rect); 
     766                                if (drawBackground) fillImageBackground (hDC, control, &rect); 
    762767                            } 
    763768                        } 
     
    791796                            gc.dispose (); 
    792797                        } 
    793                         OS.SetRect (rect, rect.left + size.x + offset, rect.top, rect.right - inset, rect.bottom); 
     798                        OS.SetRect (&rect, rect.left + size.x + offset, rect.top, rect.right - inset, rect.bottom); 
    794799                    } else { 
    795800                        if (i is 0) { 
     
    799804                            } 
    800805                        } else { 
    801                             OS.SetRect (rect, rect.left + offset, rect.top, rect.right - inset, rect.bottom); 
     806                            OS.SetRect (&rect, rect.left + offset, rect.top, rect.right - inset, rect.bottom); 
    802807                        } 
    803808                    } 
     
    819824                        } 
    820825                        if (string !is null) { 
    821                             if (hFont !is -1) hFont = OS.SelectObject (hDC, hFont); 
     826                            if (hFont !is cast(HFONT)-1) hFont = OS.SelectObject (hDC, hFont); 
    822827                            if (clrText !is -1) clrText = OS.SetTextColor (hDC, clrText); 
    823828                            if (clrTextBk !is -1) clrTextBk = OS.SetBkColor (hDC, clrTextBk); 
     
    829834                                if ((column.style & DWT.RIGHT) !is 0) flags |= OS.DT_RIGHT; 
    830835                            } 
    831                             TCHAR buffer = new TCHAR (getCodePage (), string, false); 
    832                             if (!ignoreDrawForeground) OS.DrawText (hDC, buffer, buffer.length (), rect, flags); 
    833                             OS.DrawText (hDC, buffer, buffer.length (), rect, flags | OS.DT_CALCRECT); 
    834                             if (hFont !is -1) hFont = OS.SelectObject (hDC, hFont); 
     836                            TCHAR[] buffer = StrToTCHARs (getCodePage (), string, false); 
     837                            if (!ignoreDrawForeground) OS.DrawText (hDC, buffer.ptr, buffer.length, &rect, flags); 
     838                            OS.DrawText (hDC, buffer.ptr, buffer.length, &rect, flags | OS.DT_CALCRECT); 
     839                            if (hFont !is cast(HFONT)-1) hFont = OS.SelectObject (hDC, hFont); 
    835840                            if (clrText !is -1) clrText = OS.SetTextColor (hDC, clrText); 
    836841                            if (clrTextBk !is -1) clrTextBk = OS.SetBkColor (hDC, clrTextBk); 
     
    868873                if (!explorerTheme) { 
    869874                    //if ((nmcd.uItemState & OS.CDIS_FOCUS) !is 0) { 
    870                     if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0) is nmcd.dwItemSpec) { 
     875                    if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0) is nmcd.nmcd.dwItemSpec) { 
    871876                        if (i is 0 /*nmcd.iSubItem is 0*/ || (style & DWT.FULL_SELECTION) !is 0) { 
    872877                            if (handle is OS.GetFocus ()) { 
     
    897902    if (linesVisible) { 
    898903        if ((style & DWT.FULL_SELECTION) !is 0) { 
    899             if (hwndHeader !is 0) { 
     904            if (hwndHeader !is null) { 
    900905                if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0) !is 0) { 
    901                     HDITEM hdItem = new HDITEM ()
     906                    HDITEM hdItem
    902907                    hdItem.mask = OS.HDI_WIDTH; 
    903                     OS.SendMessage (hwndHeader, OS.HDM_GETITEM, 0, hdItem); 
    904                     RECT rect = new RECT ()
    905                     OS.SetRect (rect, nmcd.left + hdItem.cxy, nmcd.top, nmcd.right, nmcd.bottom); 
    906                     OS.DrawEdge (hDC, rect, OS.BDR_SUNKENINNER, OS.BF_BOTTOM); 
    907                 } 
    908             } 
    909         } 
    910         RECT rect = new RECT ()
    911         OS.SetRect (rect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom); 
    912         OS.DrawEdge (hDC, rect, OS.BDR_SUNKENINNER, OS.BF_BOTTOM); 
     908                    OS.SendMessage (hwndHeader, OS.HDM_GETITEM, 0, &hdItem); 
     909                    RECT rect
     910                    OS.SetRect (&rect, nmcd.nmcd.rc.left + hdItem.cxy, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom); 
     911                    OS.DrawEdge (hDC, &rect, OS.BDR_SUNKENINNER, OS.BF_BOTTOM); 
     912                } 
     913            } 
     914        } 
     915        RECT rect
     916        OS.SetRect (&rect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom); 
     917        OS.DrawEdge (hDC, &rect, OS.BDR_SUNKENINNER, OS.BF_BOTTOM); 
    913918    } 
    914919    if (!explorerTheme) { 
     
    916921            int uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0); 
    917922            if ((uiState & OS.UISF_HIDEFOCUS) is 0) { 
    918                 int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0); 
     923                auto hItem = cast(HANDLE) OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0); 
    919924                if (hItem is item.handle) { 
    920925                    if (!ignoreDrawFocus && findImageControl () !is null) { 
    921926                        if ((style & DWT.FULL_SELECTION) !is 0) { 
    922                             RECT focusRect = new RECT ()
    923                             OS.SetRect (focusRect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom); 
    924                             if (count > 0 && hwndHeader !is 0) { 
     927                            RECT focusRect
     928                            OS.SetRect (&focusRect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom); 
     929                            if (count > 0 && hwndHeader !is null) { 
    925930                                int width = 0; 
    926                                 HDITEM hdItem = new HDITEM ()
     931                                HDITEM hdItem
    927932                                hdItem.mask = OS.HDI_WIDTH; 
    928933                                for (int j=0; j<count; j++) { 
    929                                     OS.SendMessage (hwndHeader, OS.HDM_GETITEM, j, hdItem); 
     934                                    OS.SendMessage (hwndHeader, OS.HDM_GETITEM, j, &hdItem); 
    930935                                    width += hdItem.cxy; 
    931936                                } 
    932937                                focusRect.left = 0; 
    933                                 RECT rect = new RECT ()
    934                                 OS.GetClientRect (handle, rect); 
     938                                RECT rect
     939                                OS.GetClientRect (handle, &rect); 
    935940                                focusRect.right = Math.max (width, rect.right - OS.GetSystemMetrics (OS.SM_CXVSCROLL)); 
    936941                            } 
    937                             OS.DrawFocusRect (hDC, focusRect); 
     942                            OS.DrawFocusRect (hDC, &focusRect); 
    938943                        } else { 
    939944                            int index = OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0); 
     
    941946                            RECT clipRect = item.getBounds (index, true, false, false, false, true, hDC); 
    942947                            OS.IntersectClipRect (hDC, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom); 
    943                             OS.DrawFocusRect (hDC, focusRect); 
    944                             OS.SelectClipRgn (hDC, 0); 
     948                            OS.DrawFocusRect (hDC, &focusRect); 
     949                            OS.SelectClipRgn (hDC, null); 
    945950                        } 
    946951                    } 
     
    949954        } 
    950955    } 
    951     return new LRESULT (OS.CDRF_DODEFAULT); 
    952 } 
    953  
    954 LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, int wParam, int lParam) { 
     956    return cast(LRESULT) (OS.CDRF_DODEFAULT); 
     957} 
     958 
     959LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW* nmcd, int wParam, int lParam) { 
    955960    /* 
    956961    * Even when custom draw is being ignored, the font needs 
     
    969974    * COMCTL32.DLL, 
    970975    */ 
    971     if (item is null) return null
    972     int hDC = nmcd.hdc; 
    973     int index = hwndHeader !is 0 ? OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0) : 0; 
    974     int hFont = item.cellFont !is null ? item.cellFont [index] : -1; 
    975     if (hFont is -1) hFont = item.font; 
    976     if (hFont !is -1) OS.SelectObject (hDC, hFont); 
    977     if (ignoreCustomDraw || nmcd.left is nmcd.right) { 
    978         return new LRESULT (hFont is -1 ? OS.CDRF_DODEFAULT : OS.CDRF_NEWFONT); 
     976    if (item is null) return LRESULT.NULL
     977    auto hDC = nmcd.nmcd.hdc; 
     978    int index = hwndHeader !is null ? OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0) : 0; 
     979    HFONT hFont = item.cellFont !is null ? item.cellFont [index] : cast(HFONT)-1; 
     980    if (hFont is cast(HFONT)-1) hFont = item.font; 
     981    if (hFont !is cast(HFONT)-1) OS.SelectObject (hDC, hFont); 
     982    if (ignoreCustomDraw || nmcd.nmcd.rc.left is nmcd.nmcd.rc.right) { 
     983        return cast(LRESULT) (hFont is cast(HFONT)-1 ? OS.CDRF_DODEFAULT : OS.CDRF_NEWFONT); 
    979984    } 
    980985    int count = 0; 
    981     RECT clipRect = null; 
    982     if (hwndHeader !is 0) { 
     986    RECT* clipRect = null; 
     987    if (hwndHeader !is null) { 
    983988        count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 
    984989        if (count !is 0) { 
     
    989994            if (clip) { 
    990995                clipRect = new RECT (); 
    991                 HDITEM hdItem = new HDITEM ()
     996                HDITEM hdItem
    992997                hdItem.mask = OS.HDI_WIDTH; 
    993                 OS.SendMessage (hwndHeader, OS.HDM_GETITEM, index, hdItem); 
    994                 OS.SetRect (clipRect, nmcd.left, nmcd.top, nmcd.left + hdItem.cxy, nmcd.bottom); 
     998                OS.SendMessage (hwndHeader, OS.HDM_GETITEM, index, &hdItem); 
     999                OS.SetRect (clipRect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.left + hdItem.cxy, nmcd.nmcd.rc.bottom); 
    9951000            } 
    9961001        } 
     
    10151020    } 
    10161021    bool selected = isItemSelected (nmcd); 
    1017     bool hot = explorerTheme && (nmcd.uItemState & OS.CDIS_HOT) !is 0; 
    1018     if (OS.IsWindowVisible (handle) && nmcd.left < nmcd.right && nmcd.top < nmcd.bottom) { 
    1019         if (hFont !is -1) OS.SelectObject (hDC, hFont); 
     1022    bool hot = explorerTheme && (nmcd.nmcd.uItemState & OS.CDIS_HOT) !is 0; 
     1023    if (OS.IsWindowVisible (handle) && nmcd.nmcd.rc.left < nmcd.nmcd.rc.right && nmcd.nmcd.rc.top < nmcd.nmcd.rc.bottom) { 
     1024        if (hFont !is cast(HFONT)-1) OS.SelectObject (hDC, hFont); 
    10201025        if (linesVisible) { 
    1021             RECT rect = new RECT ()
    1022             OS.SetRect (rect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom); 
    1023             OS.DrawEdge (hDC, rect, OS.BDR_SUNKENINNER, OS.BF_BOTTOM); 
     1026            RECT rect
     1027            OS.SetRect (&rect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom); 
     1028            OS.DrawEdge (hDC, &rect, OS.BDR_SUNKENINNER, OS.BF_BOTTOM); 
    10241029        } 
    10251030        //TODO - BUG - measure and erase sent when first column is clipped 
     
    10431048            gc.dispose (); 
    10441049            OS.RestoreDC (hDC, nSavedDC); 
    1045             if (isDisposed () || item.isDisposed ()) return null
    1046             if (hwndHeader !is 0) { 
     1050            if (isDisposed () || item.isDisposed ()) return LRESULT.NULL
     1051            if (hwndHeader !is null) { 
    10471052                if (count is 0) { 
    10481053                    if (event.x + event.width > scrollWidth) { 
     
    10561061        ignoreDrawForeground = ignoreDrawBackground = ignoreDrawSelection = ignoreDrawFocus = ignoreDrawHot = ignoreFullSelection = false; 
    10571062        if (hooks (DWT.EraseItem)) { 
    1058             RECT rect = new RECT ()
    1059             OS.SetRect (rect, nmcd.left, nmcd.top, nmcd.right, nmcd.bottom); 
     1063            RECT rect
     1064            OS.SetRect (&rect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom); 
    10601065            if (OS.IsWindowEnabled (handle) || findImageControl () !is null) { 
    1061                 drawBackground (hDC, rect); 
     1066                drawBackground (hDC, &rect); 
    10621067            } else { 
    1063                 fillBackground (hDC, OS.GetBkColor (hDC), rect); 
     1068                fillBackground (hDC, OS.GetBkColor (hDC), &rect); 
    10641069            } 
    10651070            RECT cellRect = item.getBounds (index, true, true, true, true, true, hDC); 
    10661071            if (clrSortBk !is -1) { 
    10671072                RECT fullRect = item.getBounds (index, true, true, true, true, true, hDC); 
    1068                 drawBackground (hDC, fullRect, clrSortBk); 
     1073                drawBackground (hDC, &fullRect, clrSortBk); 
    10691074            } 
    10701075            int nSavedDC = OS.SaveDC (hDC); 
     
    10821087            } 
    10831088            data.uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0); 
    1084             if (hFont !is -1) data.hFont = hFont; 
     1089            if (hFont !is cast(HFONT)-1) data.hFont = hFont; 
    10851090            GC gc = GC.win32_new (hDC, data); 
    10861091            Event event = new Event (); 
     
    10941099            if (!explorerTheme) { 
    10951100                //if ((nmcd.uItemState & OS.CDIS_FOCUS) !is 0) { 
    1096                 if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0) is nmcd.dwItemSpec) { 
     1101                if (OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0) is nmcd.nmcd.dwItemSpec) { 
    10971102                    if (handle is OS.GetFocus ()) { 
    10981103                        int uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0); 
     
    11111116            gc.dispose (); 
    11121117            OS.RestoreDC (hDC, nSavedDC); 
    1113             if (isDisposed () || item.isDisposed ()) return null
     1118            if (isDisposed () || item.isDisposed ()) return LRESULT.NULL
    11141119            if (event.doit) { 
    11151120                ignoreDrawForeground = (event.detail & DWT.FOREGROUND) is 0; 
     
    11281133                    if (count is 0) { 
    11291134                        if ((style & DWT.FULL_SELECTION) !is 0) { 
    1130                             fillBackground (hDC, clrTextBk, rect); 
     1135                            fillBackground (hDC, clrTextBk, &rect); 
    11311136                        } else { 
    11321137                            RECT textRect = item.getBounds (index, true, false, true, false, true, hDC); 
    1133                             fillBackground (hDC, clrTextBk, textRect); 
     1138                            fillBackground (hDC, clrTextBk, &textRect); 
    11341139                        } 
    11351140                    } else { 
    1136                         fillBackground (hDC, clrTextBk, cellRect); 
     1141                        fillBackground (hDC, clrTextBk, &cellRect); 
    11371142                    } 
    11381143                } 
     
    11531158                    if ((style & DWT.FULL_SELECTION) !is 0) { 
    11541159                        if ((style & DWT.FULL_SELECTION) !is 0 && count is 0) { 
    1155                             fillBackground (hDC, OS.GetBkColor (hDC), rect); 
     1160                            fillBackground (hDC, OS.GetBkColor (hDC), &rect); 
    11561161                        } else { 
    1157         &