Changeset 218:c749c13479ef

Show
Ignore:
Timestamp:
05/18/08 13:57:18 (3 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

rebuild some function to work again with heap RECT. Also some overrides

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/widgets/Tree.d

    r214 r218  
    480480                    if (explorerTheme) { 
    481481                        if (hooks (DWT.EraseItem)) { 
    482                             RECT itemRect = item.getBounds (index, true, true, false, false, true, hDC); 
     482                            RECT* itemRect = item.getBounds (index, true, true, false, false, true, hDC); 
    483483                            itemRect.left -= EXPLORER_EXTRA; 
    484484                            itemRect.right += EXPLORER_EXTRA + 1; 
     
    522522        } 
    523523        if (x + width > clientRect.left) { 
    524             RECT rect; 
    525             RECT* backgroundRect = null; 
    526             RECT rectTmp; 
    527             bool drawItem = true, drawText = true, drawImage = true, drawBackground = false; 
     524            RECT* rect = new RECT(), backgroundRect = null; 
     525            bool drawItem = true, drawText = true, drawImage = true, drawBackground_ = false; 
    528526            if (i is 0) { 
    529527                drawItem = drawImage = drawText = false; 
     
    545543                                    data.device = display; 
    546544                                    GC gc = GC.win32_new (hDC, data); 
    547                                     RECT iconRect = item.getBounds (index, false, true, false, false, true, hDC); 
     545                                    RECT* iconRect = item.getBounds (index, false, true, false, false, true, hDC); 
    548546                                    gc.setClipping (iconRect.left, iconRect.top, iconRect.right - iconRect.left, iconRect.bottom - iconRect.top); 
    549547                                    gc.drawImage (image, 0, 0, bounds.width, bounds.height, iconRect.left, iconRect.top, size.x, size.y); 
     
    554552                        } 
    555553                    } else { 
    556                         drawItem = drawText = drawBackground = true; 
     554                        drawItem = drawText = drawBackground_ = true; 
    557555                        rect = item.getBounds (index, true, false, false, false, true, hDC); 
    558556                        if (linesVisible) { 
     
    563561                } 
    564562                if (selected && !ignoreDrawSelection && !ignoreDrawBackground) { 
    565                     if (!explorerTheme) fillBackground (hDC, OS.GetBkColor (hDC), &rect); 
    566                     drawBackground = false; 
    567                 } 
    568                 backgroundRect = &rect; 
     563                    if (!explorerTheme) fillBackground (hDC, OS.GetBkColor (hDC), rect); 
     564                    drawBackground_ = false; 
     565                } 
     566                backgroundRect = rect; 
    569567                if (hooks (DWT.EraseItem)) { 
    570568                    drawItem = drawText = drawImage = true; 
    571569                    rect = item.getBounds (index, true, true, false, false, true, hDC); 
    572570                    if ((style & DWT.FULL_SELECTION) !is 0) { 
    573                         backgroundRect = &rect; 
     571                        backgroundRect = rect; 
    574572                    } else { 
    575                         rectTmp = item.getBounds (index, true, false, false, false, true, hDC); 
    576                         backgroundRect = &rectTmp; 
     573                        backgroundRect = item.getBounds (index, true, false, false, false, true, hDC); 
    577574                    } 
    578575                } 
     
    580577                selectionForeground = -1; 
    581578                ignoreDrawForeground = ignoreDrawBackground = ignoreDrawSelection = ignoreDrawFocus = ignoreDrawHot = false; 
    582                 OS.SetRect (&rect, x, nmcd.nmcd.rc.top, x + width, nmcd.nmcd.rc.bottom); 
    583                 backgroundRect = &rect; 
     579                OS.SetRect (rect, x, nmcd.nmcd.rc.top, x + width, nmcd.nmcd.rc.bottom); 
     580                backgroundRect = rect; 
    584581            } 
    585582            int clrText = -1, clrTextBk = -1; 
     
    592589                        OS.SetTextColor (hDC, getForegroundPixel ()); 
    593590                        OS.SetBkColor (hDC, getBackgroundPixel ()); 
    594                         drawForeground = drawBackground = true; 
     591                        drawForeground = drawBackground_ = true; 
    595592                    } 
    596593                } else { 
    597                     drawForeground = drawBackground = true; 
     594                    drawForeground = drawBackground_ = true; 
    598595                } 
    599596                if (drawForeground) { 
     
    601598                    if (clrText is -1) clrText = item.foreground; 
    602599                } 
    603                 if (drawBackground) { 
     600                if (drawBackground_) { 
    604601                    clrTextBk = item.cellBackground !is null ? item.cellBackground [index] : -1; 
    605602                    if (clrTextBk is -1) clrTextBk = item.background; 
     
    608605            } else { 
    609606                if (clrTextBk is -1 && index is sortIndex) { 
    610                     drawBackground = true; 
     607                    drawBackground_ = true; 
    611608                    clrTextBk = clrSortBk; 
    612609                } 
     
    615612                if (selected || (nmcd.nmcd.uItemState & OS.CDIS_HOT) !is 0) { 
    616613                    if ((style & DWT.FULL_SELECTION) !is 0) { 
    617                         drawBackground = false; 
     614                        drawBackground_ = false; 
    618615                    } else { 
    619616                        if (i is 0) { 
    620                             drawBackground = false; 
     617                            drawBackground_ = false; 
    621618                            if (!hooks (DWT.EraseItem)) drawText = false; 
    622619                        } 
     
    631628                    } 
    632629                    if (hooks (DWT.EraseItem)) { 
    633                         RECT cellRect = item.getBounds (index, true, true, true, true, true, hDC); 
     630                        RECT* cellRect = item.getBounds (index, true, true, true, true, true, hDC); 
    634631                        int nSavedDC = OS.SaveDC (hDC); 
    635632                        GCData data = new GCData (); 
     
    693690                                } else { 
    694691                                    if (!explorerTheme) { 
    695                                         drawBackground = true; 
     692                                        drawBackground_ = true; 
    696693                                        ignoreDrawBackground = false; 
    697694                                        if ((handle is OS.GetFocus () || display.getHighContrast ()) && OS.IsWindowEnabled (handle)) { 
     
    754751                if (!ignoreDrawBackground) { 
    755752                    if (clrTextBk !is -1) { 
    756                         if (drawBackground) fillBackground (hDC, clrTextBk, backgroundRect); 
     753                        if (drawBackground_) fillBackground (hDC, clrTextBk, backgroundRect); 
    757754                    } else { 
    758755                        Control control = findImageControl (); 
     
    760757                            if (i is 0) { 
    761758                                int right = Math.min (rect.right, width); 
    762                                 OS.SetRect (&rect, rect.left, rect.top, right, rect.bottom); 
    763                                 if (drawBackground) fillImageBackground (hDC, control, &rect); 
     759                                OS.SetRect (rect, rect.left, rect.top, right, rect.bottom); 
     760                                if (drawBackground_) fillImageBackground (hDC, control, rect); 
    764761                            } else { 
    765                                 if (drawBackground) fillImageBackground (hDC, control, &rect); 
     762                                if (drawBackground_) fillImageBackground (hDC, control, rect); 
    766763                            } 
    767764                        } 
     
    794791                            gc.dispose (); 
    795792                        } 
    796                         OS.SetRect (&rect, rect.left + size.x + offset, rect.top, rect.right - inset, rect.bottom); 
     793                        OS.SetRect (rect, rect.left + size.x + offset, rect.top, rect.right - inset, rect.bottom); 
    797794                    } else { 
    798795                        if (i is 0) { 
     
    802799                            } 
    803800                        } else { 
    804                             OS.SetRect (&rect, rect.left + offset, rect.top, rect.right - inset, rect.bottom); 
     801                            OS.SetRect (rect, rect.left + offset, rect.top, rect.right - inset, rect.bottom); 
    805802                        } 
    806803                    } 
     
    833830                            } 
    834831                            TCHAR[] buffer = StrToTCHARs (getCodePage (), string, false); 
    835                             if (!ignoreDrawForeground) OS.DrawText (hDC, buffer.ptr, buffer.length, &rect, flags); 
    836                             OS.DrawText (hDC, buffer.ptr, buffer.length, &rect, flags | OS.DT_CALCRECT); 
     832                            if (!ignoreDrawForeground) OS.DrawText (hDC, buffer.ptr, buffer.length, rect, flags); 
     833                            OS.DrawText (hDC, buffer.ptr, buffer.length, rect, flags | OS.DT_CALCRECT); 
    837834                            if (hFont !is cast(HFONT)-1) hFont = cast(HFONT)OS.SelectObject (hDC, hFont); 
    838835                            if (clrText !is -1) clrText = OS.SetTextColor (hDC, clrText); 
     
    844841            if (selectionForeground !is -1) clrText = selectionForeground; 
    845842            if (hooks (DWT.PaintItem)) { 
    846                 RECT itemRect = item.getBounds (index, true, true, false, false, false, hDC); 
     843                RECT* itemRect = item.getBounds (index, true, true, false, false, false, hDC); 
    847844                int nSavedDC = OS.SaveDC (hDC); 
    848845                GCData data = new GCData (); 
     
    884881                event.width = itemRect.right - itemRect.left; 
    885882                event.height = itemRect.bottom - itemRect.top; 
    886                 RECT cellRect = item.getBounds (index, true, true, true, true, true, hDC); 
     883                RECT* cellRect = item.getBounds (index, true, true, true, true, true, hDC); 
    887884                int cellWidth = cellRect.right - cellRect.left; 
    888885                int cellHeight = cellRect.bottom - cellRect.top; 
     
    931928                            } else { 
    932929                                int index = OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0); 
    933                                 RECT focusRect = item.getBounds (index, true, false, false, false, false, hDC); 
    934                                 RECT clipRect = item.getBounds (index, true, false, false, false, true, hDC); 
     930                                RECT* focusRect = item.getBounds (index, true, false, false, false, false, hDC); 
     931                                RECT* clipRect = item.getBounds (index, true, false, false, false, true, hDC); 
    935932                                OS.IntersectClipRect (hDC, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom); 
    936                                 OS.DrawFocusRect (hDC, &focusRect); 
     933                                OS.DrawFocusRect (hDC, focusRect); 
    937934                                OS.SelectClipRgn (hDC, null); 
    938935                            } 
     
    10241021            RECT rect; 
    10251022            OS.SetRect (&rect, nmcd.nmcd.rc.left, nmcd.nmcd.rc.top, nmcd.nmcd.rc.right, nmcd.nmcd.rc.bottom); 
    1026             RECT cellRect = item.getBounds (index, true, true, true, true, true, hDC); 
     1023            RECT* cellRect = item.getBounds (index, true, true, true, true, true, hDC); 
    10271024            if (clrSortBk !is -1) { 
    1028                 drawBackground (hDC, &cellRect, clrSortBk); 
     1025                drawBackground (hDC, cellRect, clrSortBk); 
    10291026            } else { 
    10301027                if (OS.IsWindowEnabled (handle) || findImageControl () !is null) { 
     
    10991096                            fillBackground (hDC, clrTextBk, &rect); 
    11001097                        } else { 
    1101                             RECT textRect = item.getBounds (index, true, false, false, false, true, hDC); 
     1098                            RECT* textRect = item.getBounds (index, true, false, false, false, true, hDC); 
    11021099                            if (measureEvent !is null) { 
    11031100                                textRect.right = Math.min (cellRect.right, measureEvent.x + measureEvent.width); 
    11041101                            } 
    1105                             fillBackground (hDC, clrTextBk, &textRect); 
     1102                            fillBackground (hDC, clrTextBk, textRect); 
    11061103                        } 
    11071104                    } else { 
    1108                         fillBackground (hDC, clrTextBk, &cellRect); 
     1105                        fillBackground (hDC, clrTextBk, cellRect); 
    11091106                    } 
    11101107                } 
     
    11171114                if (explorerTheme) { 
    11181115                    if ((style & DWT.FULL_SELECTION) is 0) { 
    1119                         RECT pRect = item.getBounds (index, true, true, false, false, false, hDC); 
    1120                         RECT pClipRect = item.getBounds (index, true, true, true, false, true, hDC); 
     1116                        RECT* pRect = item.getBounds (index, true, true, false, false, false, hDC); 
     1117                        RECT* pClipRect = item.getBounds (index, true, true, true, false, true, hDC); 
    11211118                        if (measureEvent !is null) { 
    11221119                            pRect.right = Math.min (pClipRect.right, measureEvent.x + measureEvent.width); 
     
    11301127                        int iStateId = selected ? OS.TREIS_SELECTED : OS.TREIS_HOT; 
    11311128                        if (OS.GetFocus () !is handle && selected && !hot) iStateId = OS.TREIS_SELECTEDNOTFOCUS; 
    1132                         OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, &pRect, &pClipRect); 
     1129                        OS.DrawThemeBackground (hTheme, hDC, OS.TVP_TREEITEM, iStateId, pRect, pClipRect); 
    11331130                        OS.CloseThemeData (hTheme); 
    11341131                    } 
     
    11451142                            fillBackground (hDC, OS.GetBkColor (hDC), &rect); 
    11461143                        } else { 
    1147                             fillBackground (hDC, OS.GetBkColor (hDC), &cellRect); 
     1144                            fillBackground (hDC, OS.GetBkColor (hDC), cellRect); 
    11481145                        } 
    11491146                    } else { 
    1150                         RECT textRect = item.getBounds (index, true, false, false, false, true, hDC); 
     1147                        RECT* textRect = item.getBounds (index, true, false, false, false, true, hDC); 
    11511148                        if (measureEvent !is null) { 
    11521149                            textRect.right = Math.min (cellRect.right, measureEvent.x + measureEvent.width); 
    11531150                        } 
    1154                         fillBackground (hDC, OS.GetBkColor (hDC), &textRect); 
     1151                        fillBackground (hDC, OS.GetBkColor (hDC), textRect); 
    11551152                    } 
    11561153                } 
     
    11791176            } 
    11801177            if (focused && !ignoreDrawFocus && (style & DWT.FULL_SELECTION) is 0) { 
    1181                 RECT textRect = item.getBounds (index, true, explorerTheme, false, false, true, hDC); 
     1178                RECT* textRect = item.getBounds (index, true, explorerTheme, false, false, true, hDC); 
    11821179                if (measureEvent !is null) { 
    11831180                    textRect.right = Math.min (cellRect.right, measureEvent.x + measureEvent.width); 
     
    11851182                nmcd.nmcd.uItemState &= ~OS.CDIS_FOCUS; 
    11861183                OS.MoveMemory (lParam, nmcd, NMTVCUSTOMDRAW.sizeof); 
    1187                 if( focusRect is null ) focusRect = new RECT; 
    1188                 *focusRect = textRect; 
     1184                focusRect = textRect; 
    11891185            } 
    11901186            if (explorerTheme) { 
     
    11921188                OS.MoveMemory (cast(void*)lParam, nmcd, NMTVCUSTOMDRAW.sizeof); 
    11931189            } 
    1194             RECT itemRect = item.getBounds (index, true, true, false, false, false, hDC); 
     1190            RECT* itemRect = item.getBounds (index, true, true, false, false, false, hDC); 
    11951191            OS.SaveDC (hDC); 
    11961192            OS.SelectClipRgn (hDC, null); 
     
    13231319                            fillBackground (hDC, clrTextBk, &rect); 
    13241320                        } else { 
    1325                             RECT textRect = item.getBounds (index, true, false, true, false, true, hDC); 
    1326                             fillBackground (hDC, clrTextBk, &textRect); 
     1321                            RECT* textRect = item.getBounds (index, true, false, true, false, true, hDC); 
     1322                            fillBackground (hDC, clrTextBk, textRect); 
    13271323                        } 
    13281324                    } 
     
    26592655} 
    26602656 
    2661 void destroyScrollBar (int type) { 
     2657override void destroyScrollBar (int type) { 
    26622658    super.destroyScrollBar (type); 
    26632659    int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 
     
    27222718} 
    27232719 
    2724 bool findCell (int x, int y, inout TreeItem item, inout int index, inout RECT cellRect, inout RECT itemRect) { 
     2720bool findCell (int x, int y, inout TreeItem item, inout int index, inout RECT* cellRect, inout RECT* itemRect) { 
    27252721    bool found = false; 
    27262722    TVHITTESTINFO lpht; 
     
    27572753            } else { 
    27582754                cellRect.right = Math.min (cellRect.right, rect.right); 
    2759                 if (OS.PtInRect ( &cellRect, pt)) { 
     2755                if (OS.PtInRect ( cellRect, pt)) { 
    27602756                    if (isCustomToolTip ()) { 
    27612757                        Event event = sendMeasureItemEvent (item, order [index], hDC); 
    27622758                        if (isDisposed () || item.isDisposed ()) break; 
    2763                         //itemRect [0] = new RECT (); 
     2759                        itemRect = new RECT (); 
    27642760                        itemRect.left = event.x; 
    27652761                        itemRect.right = event.x + event.width; 
     
    43774373 
    43784374Event sendMeasureItemEvent (TreeItem item, int index, HDC hDC) { 
    4379     RECT itemRect = item.getBounds (index, true, true, false, false, false, hDC); 
     4375    RECT* itemRect = item.getBounds (index, true, true, false, false, false, hDC); 
    43804376    int nSavedDC = OS.SaveDC (hDC); 
    43814377    GCData data = new GCData (); 
     
    54125408        int index; 
    54135409        TreeItem item; 
    5414         RECT cellRect, itemRect; 
     5410        RECT* cellRect, itemRect; 
    54155411        if (findCell (pt.x, pt.y, item, index, cellRect, itemRect)) { 
    54165412            String text = null; 
     
    65826578            int index; 
    65836579            TreeItem item; 
    6584             RECT cellRect, itemRect; 
     6580            RECT* cellRect, itemRect; 
    65856581            if (findCell (x, y, item, index, cellRect, itemRect)) { 
    65866582                /* 
     
    76007596            int index; 
    76017597            TreeItem item; 
    7602             RECT cellRect, itemRect; 
     7598            RECT* cellRect, itemRect; 
    76037599            if (findCell (pt.x, pt.y, item, index, cellRect, itemRect)) { 
    7604                 RECT* toolRect = toolTipRect (&itemRect); 
     7600                RECT* toolRect = toolTipRect (itemRect); 
    76057601                OS.MapWindowPoints (handle, null, cast(POINT*)toolRect, 2); 
    76067602                int width = toolRect.right - toolRect.left; 
     
    76437639                    int index; 
    76447640                    TreeItem item; 
    7645                     RECT cellRect, itemRect; 
     7641                    RECT* cellRect, itemRect; 
    76467642                    int pos = OS.GetMessagePos (); 
    76477643                    POINT pt; 
     
    76577653                        cellRect = item.getBounds (index, true, true, false, false, false, hDC); 
    76587654                        if (hooks (DWT.EraseItem)) { 
    7659                             Event event = sendEraseItemEvent (item, nmcd, index, &cellRect); 
     7655                            Event event = sendEraseItemEvent (item, nmcd, index, cellRect); 
    76607656                            if (isDisposed () || item.isDisposed ()) break; 
    76617657                            if (event.doit) { 
     
    76687664                            int nSavedDC = OS.SaveDC (nmcd.nmcd.hdc); 
    76697665                            int gridWidth = getLinesVisible () ? Table.GRID_WIDTH : 0; 
    7670                             RECT* insetRect = toolTipInset (&cellRect); 
     7666                            RECT* insetRect = toolTipInset (cellRect); 
    76717667                            OS.SetWindowOrgEx (nmcd.nmcd.hdc, insetRect.left, insetRect.top, null); 
    76727668                            GCData data = new GCData (); 
     
    76817677                            if (image !is null || index is 0) { 
    76827678                                Point size = getImageSize (); 
    7683                                 RECT imageRect = item.getBounds (index, false, true, false, false, false, hDC); 
     7679                                RECT* imageRect = item.getBounds (index, false, true, false, false, false, hDC); 
    76847680                                if (imageList is null) size.x = imageRect.right - imageRect.left; 
    76857681                                if (image !is null) { 
     
    77107706                        if (hooks (DWT.PaintItem)) { 
    77117707                            itemRect = item.getBounds (index, true, true, false, false, false, hDC); 
    7712                             sendPaintItemEvent (item, nmcd, index, &itemRect); 
     7708                            sendPaintItemEvent (item, nmcd, index, itemRect); 
    77137709                        } 
    77147710                        OS.SelectObject (hDC, oldFont); 
  • dwt/widgets/TreeColumn.d

    r213 r218  
    367367                auto hFont = item.fontHandle (index); 
    368368                if (hFont !is cast(HFONT)-1) hFont = OS.SelectObject (hDC, hFont); 
    369                 RECT itemRect = item.getBounds (index, true, true, false, false, false, hDC); 
     369                RECT* itemRect = item.getBounds (index, true, true, false, false, false, hDC); 
    370370                if (hFont !is cast(HFONT)-1) OS.SelectObject (hDC, hFont); 
    371371                itemRight = itemRect.right; 
     
    660660    checkWidget (); 
    661661    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
    662     if (string==/*eq*/text) return; 
     662    if (string.equals (text)) return; 
    663663    int index = parent.indexOf (this); 
    664664    if (index is -1) return; 
  • dwt/widgets/TreeItem.d

    r213 r218  
    403403    checkWidget (); 
    404404    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); 
    405     RECT rect = getBounds (0, true, false, false); 
     405    RECT* rect = getBounds (0, true, false, false); 
    406406    int width = rect.right - rect.left, height = rect.bottom - rect.top; 
    407407    return new Rectangle (rect.left, rect.top, width, height); 
     
    425425    checkWidget(); 
    426426    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); 
    427     RECT rect = getBounds (index, true, true, true); 
     427    RECT* rect = getBounds (index, true, true, true); 
    428428    int width = rect.right - rect.left, height = rect.bottom - rect.top; 
    429429    return new Rectangle (rect.left, rect.top, width, height); 
    430430} 
    431431 
    432 RECT getBounds (int index, bool getText, bool getImage, bool fullText) { 
     432RECT* getBounds (int index, bool getText, bool getImage, bool fullText) { 
    433433    return getBounds (index, getText, getImage, fullText, false, true, null); 
    434434} 
    435435 
    436436//TODO - take into account grid (add bool arg) to damage less during redraw 
    437 RECT getBounds (int index, bool getText, bool getImage, bool fullText, bool fullImage, bool clip, HDC hDC) { 
    438     if (!getText && !getImage) return RECT.init
     437RECT* getBounds (int index, bool getText, bool getImage, bool fullText, bool fullImage, bool clip, HDC hDC) { 
     438    if (!getText && !getImage) return new RECT()
    439439    auto hwnd = parent.handle; 
    440440    if ((parent.style & DWT.VIRTUAL) is 0 && !cached && !parent.painted) { 
     
    454454        firstColumn = index is OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0); 
    455455    } 
    456     RECT rect
     456    RECT* rect = new RECT()
    457457    if (firstColumn) { 
    458458        bool full = columnCount is 0 && getText && getImage && fullText && fullImage; 
    459         if (!OS.TreeView_GetItemRect (hwnd, handle, &rect, !full)) { 
    460             return RECT.init
     459        if (!OS.TreeView_GetItemRect (hwnd, handle, rect, !full)) { 
     460            return new RECT()
    461461        } 
    462462        if (getImage && !fullImage) { 
     
    471471        if (fullText || fullImage || clip) { 
    472472            if (hwndHeader !is null) { 
    473                 RECT headerRect
     473                RECT* headerRect = new RECT()
    474474                if (columnCount !is 0) { 
    475                     if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, cast(int) &headerRect) is 0) { 
    476                         return RECT.init
     475                    if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, cast(int) headerRect) is 0) { 
     476                        return new RECT()
    477477                    } 
    478478                } else { 
     
    488488        } 
    489489    } else { 
    490         if (!(0 <= index && index < columnCount)) return RECT.init
    491         RECT headerRect
    492         if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, cast(int) &headerRect) is 0) { 
    493             return RECT.init
    494         } 
    495         if (!OS.TreeView_GetItemRect (hwnd, handle, &rect, false)) { 
    496             return RECT.init
     490        if (!(0 <= index && index < columnCount)) return new RECT()
     491        RECT* headerRect = new RECT()
     492        if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, cast(int) headerRect) is 0) { 
     493            return new RECT()
     494        } 
     495        if (!OS.TreeView_GetItemRect (hwnd, handle, rect, false)) { 
     496            return new RECT()
    497497        } 
    498498        rect.left = headerRect.left; 
     
    518518                    String string = index is 0 ? text : strings !is null ? strings [index] : null; 
    519519                    if (string !is null) { 
    520                         RECT textRect
     520                        RECT* textRect = new RECT()
    521521                        TCHAR[] buffer = StrToTCHARs (parent.getCodePage (), string, false); 
    522522                        int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT; 
     
    529529                            hFont = OS.SelectObject (hNewDC, hFont); 
    530530                        } 
    531                         OS.DrawText (hNewDC, buffer.ptr, buffer.length, &textRect, flags); 
     531                        OS.DrawText (hNewDC, buffer.ptr, buffer.length, textRect, flags); 
    532532                        if (hDC is null) { 
    533533                            OS.SelectObject (hNewDC, hFont); 
     
    848848    checkWidget(); 
    849849    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); 
    850     RECT rect = getBounds (index, false, true, false); 
     850    RECT* rect = getBounds (index, false, true, false); 
    851851    int width = rect.right - rect.left, height = rect.bottom - rect.top; 
    852852    return new Rectangle (rect.left, rect.top, width, height); 
     
    938938    checkWidget(); 
    939939    if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); 
    940     RECT rect = getBounds (index, true, false, true); 
     940    RECT* rect = getBounds (index, true, false, true); 
    941941    if (index is 0) rect.left += Tree.INSET - 1; 
    942942    rect.left = Math.min (rect.left, rect.right); 
     
    10051005    if (!OS.IsWindowVisible (hwnd)) return; 
    10061006    bool fullImage = column is 0 && drawText && drawImage; 
    1007     RECT rect = getBounds (column, drawText, drawImage, true, fullImage, true, null); 
    1008     OS.InvalidateRect (hwnd, &rect, true); 
     1007    RECT* rect = getBounds (column, drawText, drawImage, true, fullImage, true, null); 
     1008    OS.InvalidateRect (hwnd, rect, true); 
    10091009} 
    10101010