changeset 73:42fc35b18200

TreeItem and some author comments
author Frank Benoit <benoit@tionex.de>
date Tue, 05 Feb 2008 00:02:38 +0100
parents 14663720fb36
children ecfb28edd2e1
files dwt/widgets/Display.d dwt/widgets/Table.d dwt/widgets/TableColumn.d dwt/widgets/TableItem.d dwt/widgets/Text.d dwt/widgets/ToolBar.d dwt/widgets/ToolItem.d dwt/widgets/ToolTip.d dwt/widgets/Tracker.d dwt/widgets/TrayItem.d dwt/widgets/Tree.d dwt/widgets/TreeColumn.d dwt/widgets/TreeItem.d dwt/widgets/Widget.d
diffstat 14 files changed, 386 insertions(+), 414 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/widgets/Display.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/Display.d	Tue Feb 05 00:02:38 2008 +0100
@@ -12,40 +12,6 @@
  *******************************************************************************/
 module dwt.widgets.Display;
 
-/+
-class Display : Device {
-    RECT clickRect;
-    int clickCount, lastTime, lastButton, lastClickHwnd;
-    int lastKey, lastAscii, lastMouse;
-    bool lastVirtual, lastNull, lastDead;
-    byte [] keyboard = new byte [256];
-    bool accelKeyHit, mnemonicKeyHit;
-    bool lockActiveWindow, captureChanged, xMouse;
-    Tray tray;
-    Thread thread;
-    void wakeThread();
-    public void wake () ;
-    public bool isValidThread() ;
-    static Display getDefault();
-    static Display getCurrent();
-bool filterEvent (Event event) ;
-bool filters (int eventType) ;
-bool filterMessage (MSG msg) ;
-int getLastEventTime () ;
-void postEvent (Event event) ;
-int getClickCount (int type, int button, HWND hwnd, int lParam) ;
-static int translateKey (int key) ;
-bool translateMnemonic (MSG msg, Control control) ;
-bool translateTraversal (MSG msg, Control control) ;
-static char mbcsToWcs (int ch) ;
-static char mbcsToWcs (int ch, int codePage) ;
-int numpadKey (int key) ;
-int asciiKey (int key) ;
-int shiftedKey (int key) ;
-int controlKey (int key) ;
-HTHEME hEditTheme () ;
-}
-+/
 import dwt.DWT;
 import dwt.DWTError;
 import dwt.DWTException;
--- a/dwt/widgets/Table.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/Table.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.Table;
 
--- a/dwt/widgets/TableColumn.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/TableColumn.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.TableColumn;
 
--- a/dwt/widgets/TableItem.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/TableItem.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.TableItem;
 
--- a/dwt/widgets/Text.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/Text.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.Text;
 
--- a/dwt/widgets/ToolBar.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/ToolBar.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.ToolBar;
 
--- a/dwt/widgets/ToolItem.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/ToolItem.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.ToolItem;
 
--- a/dwt/widgets/ToolTip.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/ToolTip.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.ToolTip;
 
--- a/dwt/widgets/Tracker.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/Tracker.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.Tracker;
 
--- a/dwt/widgets/TrayItem.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/TrayItem.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,6 +7,8 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.TrayItem;
 
--- a/dwt/widgets/Tree.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/Tree.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,15 +7,11 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.Tree;
 
-import dwt.widgets.Composite;
-class Tree : Composite {
-}
-/++
-
-
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.events.SelectionEvent;
@@ -28,35 +24,22 @@
 import dwt.graphics.Image;
 import dwt.graphics.Point;
 import dwt.graphics.Rectangle;
-import dwt.internal.Callback;
 import dwt.internal.ImageList;
-import dwt.internal.win32.HDHITTESTINFO;
-import dwt.internal.win32.HDITEM;
-import dwt.internal.win32.HDLAYOUT;
-import dwt.internal.win32.LRESULT;
-import dwt.internal.win32.NMHDR;
-import dwt.internal.win32.NMHEADER;
-import dwt.internal.win32.NMRGINFO;
-import dwt.internal.win32.NMTTDISPINFO;
-import dwt.internal.win32.NMTVCUSTOMDRAW;
-import dwt.internal.win32.NMTVDISPINFO;
-import dwt.internal.win32.NMTVITEMCHANGE;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.PAINTSTRUCT;
-import dwt.internal.win32.POINT;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.SCROLLINFO;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.TEXTMETRIC;
-import dwt.internal.win32.TEXTMETRICA;
-import dwt.internal.win32.TEXTMETRICW;
-import dwt.internal.win32.TOOLINFO;
-import dwt.internal.win32.TVHITTESTINFO;
-import dwt.internal.win32.TVINSERTSTRUCT;
-import dwt.internal.win32.TVITEM;
-import dwt.internal.win32.TVSORTCB;
-import dwt.internal.win32.WINDOWPOS;
-import dwt.internal.win32.WNDCLASS;
+
+import dwt.widgets.Composite;
+import dwt.widgets.TreeItem;
+import dwt.widgets.TreeColumn;
+import dwt.widgets.TypedListener;
+import dwt.widgets.Event;
+import dwt.widgets.Display;
+import dwt.widgets.Shell;
+import dwt.widgets.Control;
+import dwt.widgets.Listener;
+import dwt.widgets.Widget;
+
+import dwt.dwthelper.utils;
+
 
 /**
  * Instances of this class provide a selectable user interface object
@@ -109,7 +92,7 @@
  * IMPORTANT: This class is <em>not</em> intended to be subclassed.
  * </p>
  */
-public class Tree extends Composite {
+public class Tree : Composite {
 
     alias Composite.computeSize computeSize;
     alias Composite.setBackgroundImage setBackgroundImage;
@@ -122,7 +105,8 @@
     ImageList imageList, headerImageList;
     TreeItem currentItem;
     TreeColumn sortColumn;
-    int hwndParent, hwndHeader, hAnchor, hInsert, lastID, hSelect;
+    HWND hwndParent, hwndHeader;
+    HANDLE hAnchor, hInsert, lastID, hSelect;
     int hFirstIndexOf, hLastIndexOf, lastIndexOf, itemCount, sortDirection;
     bool dragStarted, gestureCompleted, insertAfter, shrink, ignoreShrink;
     bool ignoreSelect, ignoreExpand, ignoreDeselect, ignoreResize;
@@ -131,19 +115,19 @@
     bool ignoreCustomDraw, ignoreDrawForeground, ignoreDrawBackground, ignoreDrawFocus;
     bool ignoreDrawSelection, ignoreDrawHot, ignoreFullSelection, explorerTheme;
     int scrollWidth, itemToolTipHandle, headerToolTipHandle, selectionForeground;
-    static final int INSET = 3;
-    static final int GRID_WIDTH = 1;
-    static final int SORT_WIDTH = 10;
-    static final int HEADER_MARGIN = 12;
-    static final int HEADER_EXTRA = 3;
-    static final int INCREMENT = 5;
-    static final int EXPLORER_EXTRA = 2;
-    static final bool EXPLORER_THEME = true;
-    static final int TreeProc;
-    static final TCHAR TreeClass = new TCHAR (0, OS.WC_TREEVIEW, true);
-    static final int HeaderProc;
-    static final TCHAR HeaderClass = new TCHAR (0, OS.WC_HEADER, true);
-    static {
+    static const int INSET = 3;
+    static const int GRID_WIDTH = 1;
+    static const int SORT_WIDTH = 10;
+    static const int HEADER_MARGIN = 12;
+    static const int HEADER_EXTRA = 3;
+    static const int INCREMENT = 5;
+    static const int EXPLORER_EXTRA = 2;
+    static const bool EXPLORER_THEME = true;
+    static const int TreeProc;
+    static const TCHAR[] TreeClass = OS.WC_TREEVIEW;
+    static const WNDPROC HeaderProc;
+    static const TCHAR[] HeaderClass = OS.WC_HEADER;
+    static this() {
         WNDCLASS lpWndClass = new WNDCLASS ();
         OS.GetClassInfo (0, TreeClass, lpWndClass);
         TreeProc = lpWndClass.lpfnWndProc;
@@ -181,7 +165,7 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public Tree (Composite parent, int style) {
+public this (Composite parent, int style) {
     super (parent, checkStyle (style));
 }
 
@@ -250,7 +234,7 @@
     }
 }
 
-TreeItem _getItem (int hItem) {
+TreeItem _getItem (HANDLE hItem) {
     TVITEM tvItem = new TVITEM ();
     tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
     tvItem.hItem = hItem;
@@ -260,12 +244,12 @@
     return null;
 }
 
-TreeItem _getItem (int hItem, int id) {
+TreeItem _getItem (HANDLE hItem, int id) {
     if ((style & DWT.VIRTUAL) is 0) return items [id];
     return id !is -1 ? items [id] : new TreeItem (this, DWT.NONE, -1, -1, hItem);
 }
 
-override void _setBackgroundPixel (int newPixel) {
+void _setBackgroundPixel (int newPixel) {
     int oldPixel = OS.SendMessage (handle, OS.TVM_GETBKCOLOR, 0, 0);
     if (oldPixel !is newPixel) {
         /*
@@ -365,7 +349,7 @@
     addListener (DWT.Collapse, typedListener);
 }
 
-override int borderHandle () {
+override HWND borderHandle () {
     return hwndParent !is 0 ? hwndParent : handle;
 }
 
@@ -825,11 +809,11 @@
                     * all text drawing for empty rectangles.
                     */
                     if (rect.left < rect.right) {
-                        String string = null;
+                        char[] string = null;
                         if (index is 0) {
                             string = item.text;
                         } else {
-                            String [] strings  = item.strings;
+                            char[] [] strings  = item.strings;
                             if (strings !is null) string = strings [index];
                         }
                         if (string !is null) {
@@ -1491,7 +1475,7 @@
     return new LRESULT (OS.CDRF_NOTIFYITEMDRAW | OS.CDRF_NOTIFYPOSTPAINT);
 }
 
-override int callWindowProc (int hwnd, int msg, int wParam, int lParam) {
+override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) {
     if (handle is 0) return 0;
     if (hwndParent !is 0 && hwnd is hwndParent) {
         return OS.DefWindowProc (hwnd, msg, wParam, lParam);
@@ -1689,7 +1673,7 @@
     return true;
 }
 
-override bool checkHandle (int hwnd) {
+override bool checkHandle (HWND hwnd) {
     return hwnd is handle || (hwndParent !is 0 && hwnd is hwndParent) || (hwndHeader !is 0 && hwnd is hwndHeader);
 }
 
@@ -1756,7 +1740,7 @@
     }
 }
 
-void clear (int hItem, TVITEM tvItem) {
+void clear (HANDLE hItem, TVITEM* tvItem) {
     tvItem.hItem = hItem;
     TreeItem item = null;
     if (OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem) !is 0) {
@@ -1796,7 +1780,7 @@
     clearAll (hItem, tvItem, all);
 }
 
-void clearAll (int hItem, TVITEM tvItem, bool all) {
+void clearAll (HANDLE hItem, TVITEM* tvItem, bool all) {
     while (hItem !is 0) {
         clear (hItem, tvItem);
         int hFirstItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
@@ -1807,7 +1791,7 @@
 
 int CompareFunc (int lParam1, int lParam2, int lParamSort) {
     TreeItem item1 = items [lParam1], item2 = items [lParam2];
-    String text1 = item1.getText (lParamSort), text2 = item2.getText (lParamSort);
+    char[] text1 = item1.getText (lParamSort), text2 = item2.getText (lParamSort);
     return sortDirection is DWT.UP ? text1.compareTo (text2) : text2.compareTo (text1);
 }
 
@@ -1954,9 +1938,9 @@
     for (int i=0; i<items.length; i++) {
         TreeItem item = items [i];
         if (item !is null) {
-            String [] strings = item.strings;
+            char[] [] strings = item.strings;
             if (strings !is null) {
-                String [] temp = new String [columnCount + 1];
+                char[] [] temp = new char[] [columnCount + 1];
                 System.arraycopy (strings, 0, temp, 0, index);
                 System.arraycopy (strings, index, temp, index + 1, columnCount - index);
                 item.strings = temp;
@@ -1971,7 +1955,7 @@
             if (index is 0) {
                 if (columnCount !is 0) {
                     if (strings is null) {
-                        item.strings = new String [columnCount + 1];
+                        item.strings = new char[] [columnCount + 1];
                         item.strings [1] = item.text;
                     }
                     item.text = "";
@@ -2073,7 +2057,7 @@
     }
 }
 
-void createItem (TreeItem item, int hParent, int hInsertAfter, int hItem) {
+void createItem (TreeItem item, HANDLE hParent, HANDLE hInsertAfter, HANDLE hItem) {
     int id = -1;
     if (item !is null) {
         id = lastID < items.length ? lastID : 0;
@@ -2415,11 +2399,11 @@
                 item.cellFont = null;
             } else {
                 if (item.strings !is null) {
-                    String [] strings = item.strings;
+                    char[] [] strings = item.strings;
                     if (index is 0) {
                         item.text = strings [1] !is null ? strings [1] : "";
                     }
-                    String [] temp = new String [columnCount];
+                    char[] [] temp = new char[] [columnCount];
                     System.arraycopy (strings, 0, temp, 0, index);
                     System.arraycopy (strings, index + 1, temp, index, columnCount - index);
                     item.strings = temp;
@@ -2518,7 +2502,7 @@
     }
 }
 
-void destroyItem (TreeItem item, int hItem) {
+void destroyItem (TreeItem item, HANDLE hItem) {
     hFirstIndexOf = hLastIndexOf = 0;
     itemCount = -1;
     /*
@@ -2661,7 +2645,7 @@
     updateFullSelection ();
 }
 
-int findIndex (int hFirstItem, int hItem) {
+int findIndex (HANDLE hFirstItem, HANDLE hItem) {
     if (hFirstItem is 0) return -1;
     if (hFirstItem is hFirstIndexOf) {
         if (hFirstIndexOf is hItem) {
@@ -2713,11 +2697,11 @@
     return -1;
 }
 
-override Widget findItem (int hItem) {
+override Widget findItem (HANDLE hItem) {
     return _getItem (hItem);
 }
 
-int findItem (int hFirstItem, int index) {
+HANDLE findItem (HANDLE hFirstItem, int index) {
     if (hFirstItem is 0) return 0;
     if (hFirstItem is hFirstIndexOf) {
         if (index is 0) {
@@ -3100,7 +3084,7 @@
     return getItemCount (hItem);
 }
 
-int getItemCount (int hItem) {
+int getItemCount (HANDLE hItem) {
     int count = 0, hFirstItem = hItem;
     if (hItem is hFirstIndexOf) {
         if (itemCount !is -1) return itemCount;
@@ -3309,7 +3293,7 @@
         tvItem.hItem = hItem;
         OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
         if ((tvItem.state & OS.TVIS_SELECTED) is 0) return new TreeItem [0];
-        return new TreeItem [] {_getItem (tvItem.hItem, tvItem.lParam)};
+        return [_getItem (tvItem.hItem, tvItem.lParam)];
     }
     int count = 0;
     TreeItem [] guess = new TreeItem [(style & DWT.VIRTUAL) !is 0 ? 8 : 1];
@@ -3709,7 +3693,7 @@
     if (hwndHeader !is 0) display.addControl (hwndHeader, this);
 }
 
-void releaseItem (int hItem, TVITEM tvItem, bool release) {
+void releaseItem (HANDLE hItem, TVITEM* tvItem, bool release) {
     if (hItem is hAnchor) hAnchor = 0;
     if (hItem is hInsert) hInsert = 0;
     tvItem.hItem = hItem;
@@ -3725,7 +3709,7 @@
     }
 }
 
-void releaseItems (int hItem, TVITEM tvItem) {
+void releaseItems (HANDLE hItem, TVITEM* tvItem) {
     hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
     while (hItem !is 0) {
         releaseItems (hItem, tvItem);
@@ -3943,7 +3927,7 @@
     setItemCount (count, OS.TVGN_ROOT, hItem);
 }
 
-void setItemCount (int count, int hParent, int hItem) {
+void setItemCount (int count, HANDLE hParent, HANDLE hItem) {
     bool redraw = false;
     if (OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0) is 0) {
         redraw = drawCount is 0 && OS.IsWindowVisible (handle);
@@ -4033,7 +4017,7 @@
     OS.InvalidateRect (handle, null, true);
 }
 
-override int scrolledHandle () {
+override HWND scrolledHandle () {
     if (hwndHeader is 0) return handle;
     int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
     return count is 0 ? handle : hwndParent;
@@ -4084,7 +4068,7 @@
     OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
 }
 
-override void setBackgroundImage (int hBitmap) {
+override void setBackgroundImage (HBITMAP hBitmap) {
     super.setBackgroundImage (hBitmap);
     if (hBitmap !is 0) {
         /*
@@ -4119,7 +4103,7 @@
     updateFullSelection ();
 }
 
-void setBackgroundPixel (int pixel) {
+override void setBackgroundPixel (int pixel) {
     Control control = findImageControl ();
     if (control !is null) {
         setBackgroundImage (control.backgroundImage);
@@ -4306,7 +4290,7 @@
     OS.FillRect (memDC, rect, hBrush);
     OS.DeleteObject (hBrush);
     int oldFont = OS.SelectObject (hDC, defaultFont ());
-    TEXTMETRIC tm = OS.IsUnicode ? (TEXTMETRIC) new TEXTMETRICW () : new TEXTMETRICA ();
+    TEXTMETRIC tm;
     OS.GetTextMetrics (hDC, tm);
     OS.SelectObject (hDC, oldFont);
     int itemWidth = Math.min (tm.tmHeight, width);
@@ -4564,7 +4548,7 @@
 public void setSelection (TreeItem item) {
     checkWidget ();
     if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
-    setSelection (new TreeItem [] {item});
+    setSelection ([item]);
 }
 
 /**
@@ -5022,7 +5006,7 @@
     sort (OS.TVI_ROOT, false);
 }
 
-void sort (int hParent, bool all) {
+void sort (HANDLE hParent, bool all) {
     int itemCount = OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
     if (itemCount is 0 || itemCount is 1) return;
     hFirstIndexOf = hLastIndexOf = 0;
@@ -5048,7 +5032,7 @@
     }
 }
 
-override String toolTipText (NMTTDISPINFO hdr) {
+override char[] toolTipText (NMTTDISPINFO* hdr) {
     int hwndToolTip = OS.SendMessage (handle, OS.TVM_GETTOOLTIPS, 0, 0);
     if (hwndToolTip is hdr.hwndFrom && toolTipText !is null) return ""; //$NON-NLS-1$
     if (headerToolTipHandle is hdr.hwndFrom) {
@@ -5064,8 +5048,8 @@
         if (!hooks (DWT.EraseItem) && !hooks (DWT.PaintItem)) {
             int pos = OS.GetMessagePos ();
             POINT pt = new POINT();
-            pt.x = (short) (pos & 0xFFFF);
-            pt.y = (short) (pos >> 16);
+            pt.x = cast(short) (pos & 0xFFFF);
+            pt.y = cast(short) (pos >> 16);
             OS.ScreenToClient (handle, pt);
             TVHITTESTINFO lpht = new TVHITTESTINFO ();
             lpht.x = pt.x;
@@ -5079,7 +5063,7 @@
                 OS.GetClientRect (hwndParent, rect);
                 OS.MapWindowPoints (hwndParent, handle, rect, 2);
                 TreeItem item = _getItem (lpht.hItem);
-                String text = null;
+                char[] text = null;
                 int index = 0, count = Math.max (1, OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0));
                 int [] order = new int [count];
                 OS.SendMessage (hwndHeader, OS.HDM_GETORDERARRAY, count, order);
@@ -5097,7 +5081,7 @@
                             if (order [index] is 0) {
                                 text = item.text;
                             } else {
-                                String[] strings = item.strings;
+                                char[][] strings = item.strings;
                                 if (strings !is null) text = strings [order [index]];
                             }
                         }
@@ -5114,7 +5098,7 @@
     return super.toolTipText (hdr);
 }
 
-override int topHandle () {
+override HWND topHandle () {
     return hwndParent !is 0 ? hwndParent : handle;
 }
 
@@ -5248,15 +5232,15 @@
     return bits | OS.TVS_DISABLEDRAGDROP;
 }
 
-override TCHAR windowClass () {
-    return TreeClass;
+override char[] windowClass () {
+    return TCHARsToStr(TreeClass);
 }
 
 override int windowProc () {
-    return TreeProc;
-}
-
-override int windowProc (int hwnd, int msg, int wParam, int lParam) {
+    return cast(int) TreeProc;
+}
+
+override int windowProc (HWND hwnd, int msg, int wParam, int lParam) {
     if (hwndHeader !is 0 && hwnd is hwndHeader) {
         switch (msg) {
             /* This code is intentionally commented */
@@ -5312,13 +5296,13 @@
             }
             case OS.WM_SETCURSOR: {
                 if (wParam is hwnd) {
-                    int hitTest = (short) (lParam & 0xFFFF);
+                    int hitTest = cast(short) (lParam & 0xFFFF);
                     if (hitTest is OS.HTCLIENT) {
                         HDHITTESTINFO pinfo = new HDHITTESTINFO ();
                         int pos = OS.GetMessagePos ();
                         POINT pt = new POINT ();
-                        pt.x = (short) (pos & 0xFFFF);
-                        pt.y = (short) (pos >> 16);
+                        pt.x = cast(short) (pos & 0xFFFF);
+                        pt.y = cast(short) (pos >> 16);
                         OS.ScreenToClient (hwnd, pt);
                         pinfo.x = pt.x;
                         pinfo.y = pt.y;
@@ -5733,8 +5717,8 @@
 
 override LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) {
     TVHITTESTINFO lpht = new TVHITTESTINFO ();
-    lpht.x = (short) (lParam & 0xFFFF);
-    lpht.y = (short) (lParam >> 16);
+    lpht.x = cast(short) (lParam & 0xFFFF);
+    lpht.y = cast(short) (lParam >> 16);
     OS.SendMessage (handle, OS.TVM_HITTEST, 0, lpht);
     if (lpht.hItem !is 0) {
         if ((style & DWT.CHECK) !is 0) {
@@ -5801,8 +5785,8 @@
     * below the last item is selected.
     */
     TVHITTESTINFO lpht = new TVHITTESTINFO ();
-    lpht.x = (short) (lParam & 0xFFFF);
-    lpht.y = (short) (lParam >> 16);
+    lpht.x = cast(short) (lParam & 0xFFFF);
+    lpht.y = cast(short) (lParam >> 16);
     OS.SendMessage (handle, OS.TVM_HITTEST, 0, lpht);
     if (lpht.hItem is 0 || (lpht.flags & OS.TVHT_ONITEMBUTTON) !is 0) {
         Display display = this.display;
@@ -6140,7 +6124,7 @@
     * issue a fake mouse up.
     */
     if (dragStarted) {
-        sendDragEvent (1, (short) (lParam & 0xFFFF), (short) (lParam >> 16));
+        sendDragEvent (1, cast(short) (lParam & 0xFFFF), cast(short) (lParam >> 16));
     } else {
         int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
         if ((bits & OS.TVS_DISABLEDRAGDROP) is 0) {
@@ -6166,8 +6150,8 @@
         if (display.xMouse) mask |= OS.MK_XBUTTON1 | OS.MK_XBUTTON2;
         if (((wParam & 0xFFFF) & mask) is 0) {
             TVHITTESTINFO lpht = new TVHITTESTINFO ();
-            lpht.x = (short) (lParam & 0xFFFF);
-            lpht.y = (short) (lParam >> 16);
+            lpht.x = cast(short) (lParam & 0xFFFF);
+            lpht.y = cast(short) (lParam >> 16);
             OS.SendMessage (handle, OS.TVM_HITTEST, 0, lpht);
             if (lpht.hItem !is 0) {
                 int hDC = OS.GetDC (handle);
@@ -6259,8 +6243,8 @@
     * This behavior is consistent with the table.
     */
     TVHITTESTINFO lpht = new TVHITTESTINFO ();
-    lpht.x = (short) (lParam & 0xFFFF);
-    lpht.y = (short) (lParam >> 16);
+    lpht.x = cast(short) (lParam & 0xFFFF);
+    lpht.y = cast(short) (lParam >> 16);
     OS.SendMessage (handle, OS.TVM_HITTEST, 0, lpht);
     if (lpht.hItem !is 0) {
         int flags = OS.TVHT_ONITEMICON | OS.TVHT_ONITEMLABEL;
@@ -6519,7 +6503,7 @@
     return null;
 }
 
-override LRESULT wmNotify (NMHDR hdr, int wParam, int lParam) {
+override LRESULT wmNotify (NMHDR* hdr, int wParam, int lParam) {
     if (hdr.hwndFrom is itemToolTipHandle && hwndHeader !is 0) {
         if (!OS.IsWinCE) {
             switch (hdr.code) {
@@ -6537,8 +6521,8 @@
                     }
                     int pos = OS.GetMessagePos ();
                     POINT pt = new POINT();
-                    pt.x = (short) (pos & 0xFFFF);
-                    pt.y = (short) (pos >> 16);
+                    pt.x = cast(short) (pos & 0xFFFF);
+                    pt.y = cast(short) (pos >> 16);
                     OS.ScreenToClient (handle, pt);
                     TVHITTESTINFO lpht = new TVHITTESTINFO ();
                     lpht.x = pt.x;
@@ -6789,7 +6773,7 @@
     return super.wmNotify (hdr, wParam, lParam);
 }
 
-override LRESULT wmNotifyChild (NMHDR hdr, int wParam, int lParam) {
+override LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) {
     switch (hdr.code) {
         case OS.TVN_GETDISPINFOA:
         case OS.TVN_GETDISPINFOW: {
@@ -6886,11 +6870,11 @@
                 index = OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
             }
             if ((lptvdi.mask & OS.TVIF_TEXT) !is 0) {
-                String string = null;
+                char[] string = null;
                 if (index is 0) {
                     string = item.text;
                 } else {
-                    String [] strings  = item.strings;
+                    char[] [] strings  = item.strings;
                     if (strings !is null) string = strings [index];
                 }
                 if (string !is null) {
@@ -6958,8 +6942,8 @@
             if (hooks (DWT.DefaultSelection)) {
                 POINT pt = new POINT ();
                 int pos = OS.GetMessagePos ();
-                pt.x = (short) (pos & 0xFFFF);
-                pt.y = (short) (pos >> 16);
+                pt.x = cast(short) (pos & 0xFFFF);
+                pt.y = cast(short) (pos >> 16);
                 OS.ScreenToClient (handle, pt);
                 TVHITTESTINFO lpht = new TVHITTESTINFO ();
                 lpht.x = pt.x;
@@ -7213,4 +7197,3 @@
 }
 
 }
-++/
\ No newline at end of file
--- a/dwt/widgets/TreeColumn.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/TreeColumn.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,18 +7,11 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.TreeColumn;
 
-import dwt.widgets.Item;
-import dwt.widgets.Widget;
-
-class TreeColumn : Item {
-    public this (Widget parent, int style) {
-        super (parent, style);
-    }
-}
-/++
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.events.ControlListener;
@@ -28,12 +21,13 @@
 import dwt.graphics.GCData;
 import dwt.graphics.Image;
 import dwt.graphics.Rectangle;
-import dwt.internal.win32.HDITEM;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.TOOLINFO;
-import dwt.internal.win32.TVITEM;
+
+import dwt.widgets.Item;
+import dwt.widgets.Widget;
+import dwt.widgets.Tree;
+
+import dwt.dwthelper.utils;
 
 /**
  * Instances of this class represent a column in a tree widget.
@@ -51,10 +45,10 @@
  *
  * @since 3.1
  */
-public class TreeColumn extends Item {
+public class TreeColumn : Item {
     Tree parent;
     bool resizable, moveable;
-    String toolTipText;
+    char[] toolTipText;
     int id;
 
 /**
@@ -89,7 +83,7 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public TreeColumn (Tree parent, int style) {
+public this (Tree parent, int style) {
     super (parent, checkStyle (style));
     resizable = true;
     this.parent = parent;
@@ -130,7 +124,7 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public TreeColumn (Tree parent, int style, int index) {
+public this (Tree parent, int style, int index) {
     super (parent, checkStyle (style));
     resizable = true;
     this.parent = parent;
@@ -254,7 +248,7 @@
     return moveable;
 }
 
-override String getNameText () {
+override char[] getNameText () {
     return getText ();
 }
 
@@ -303,7 +297,7 @@
  *
  * @since 3.2
  */
-public String getToolTipText () {
+public char[] getToolTipText () {
     checkWidget();
     return toolTipText;
 }
@@ -665,7 +659,7 @@
     }
 }
 
-override public void setText (String string) {
+override public void setText (char[] string) {
     checkWidget ();
     if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     if (string.equals (text)) return;
@@ -708,7 +702,7 @@
  *
  * @since 3.2
  */
-public void setToolTipText (String string) {
+public void setToolTipText (char[] string) {
     checkWidget();
     toolTipText = string;
     int hwndHeaderToolTip = parent.headerToolTipHandle;
@@ -769,4 +763,4 @@
     }
 }
 }
-++/
+
--- a/dwt/widgets/TreeItem.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/TreeItem.d	Tue Feb 05 00:02:38 2008 +0100
@@ -7,19 +7,11 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
  *******************************************************************************/
 module dwt.widgets.TreeItem;
 
-import dwt.widgets.Item;
-import dwt.widgets.Widget;
-
-class TreeItem : Item {
-    public this (Widget parent, int style) {
-        super (parent, style);
-    }
-}
-/++
-
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.graphics.Color;
@@ -28,10 +20,13 @@
 import dwt.graphics.Point;
 import dwt.graphics.Rectangle;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.SCROLLINFO;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.TVITEM;
+
+import dwt.widgets.Item;
+import dwt.widgets.Widget;
+import dwt.widgets.Tree;
+import dwt.widgets.Event;
+
+import dwt.dwthelper.utils;
 
 /**
  * Instances of this class represent a selectable user interface object
@@ -48,7 +43,7 @@
  * </p>
  */
 
-public class TreeItem extends Item {
+public class TreeItem : Item {
     /**
      * the handle to the OS resource
      * (Warning: This field is platform dependent)
@@ -59,13 +54,15 @@
      * platforms and should never be accessed from application code.
      * </p>
      */
-    public int handle;
+    public HANDLE handle;
     Tree parent;
-    String [] strings;
+    char[] [] strings;
     Image [] images;
     bool cached;
-    int background = -1, foreground = -1, font = -1;
-    int [] cellBackground, cellForeground, cellFont;
+    int background = -1, foreground = -1;
+    HFONT font = cast(HFONT)-1;
+    int [] cellBackground, cellForeground;
+    HFONT[] cellFont;
 
 /**
  * Constructs a new instance of this class given its parent
@@ -97,8 +94,8 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public TreeItem (Tree parent, int style) {
-    this (parent, style, OS.TVGN_ROOT, OS.TVI_LAST, 0);
+public this (Tree parent, int style) {
+    this (parent, style, cast(HANDLE)OS.TVGN_ROOT, cast(HANDLE)OS.TVI_LAST, null);
 }
 
 /**
@@ -133,8 +130,8 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public TreeItem (Tree parent, int style, int index) {
-    this (parent, style, OS.TVGN_ROOT, findPrevious (parent, index), 0);
+public this (Tree parent, int style, int index) {
+    this (parent, style, cast(HANDLE) OS.TVGN_ROOT, findPrevious (parent, index), null);
 }
 
 /**
@@ -167,8 +164,8 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public TreeItem (TreeItem parentItem, int style) {
-    this (checkNull (parentItem).parent, style, parentItem.handle, OS.TVI_LAST, 0);
+public this (TreeItem parentItem, int style) {
+    this (checkNull (parentItem).parent, style, parentItem.handle, cast(HANDLE)OS.TVI_LAST, null);
 }
 
 /**
@@ -203,11 +200,11 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public TreeItem (TreeItem parentItem, int style, int index) {
-    this (checkNull (parentItem).parent, style, parentItem.handle, findPrevious (parentItem, index), 0);
+public this (TreeItem parentItem, int style, int index) {
+    this (checkNull (parentItem).parent, style, parentItem.handle, findPrevious (parentItem, index), null);
 }
 
-TreeItem (Tree parent, int style, int hParent, int hInsertAfter, int hItem) {
+this (Tree parent, int style, HANDLE hParent, HANDLE hInsertAfter, HANDLE hItem) {
     super (parent, style);
     this.parent = parent;
     parent.createItem (this, hParent, hInsertAfter, hItem);
@@ -218,26 +215,27 @@
     return item;
 }
 
-static int findPrevious (Tree parent, int index) {
-    if (parent is null) return 0;
+static HANDLE findPrevious (Tree parent, int index) {
+    if (parent is null) return null;
     if (index < 0) DWT.error (DWT.ERROR_INVALID_RANGE);
-    if (index is 0) return OS.TVI_FIRST;
-    int hwnd = parent.handle;
-    int hFirstItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
-    int hItem = parent.findItem (hFirstItem, index - 1);
-    if (hItem is 0) DWT.error (DWT.ERROR_INVALID_RANGE);
+    if (index is 0) return cast(HANDLE) OS.TVI_FIRST;
+    auto hwnd = parent.handle;
+    HANDLE hFirstItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+    HANDLE hItem = parent.findItem (hFirstItem, index - 1);
+    if (hItem is null) DWT.error (DWT.ERROR_INVALID_RANGE);
     return hItem;
 }
 
-static int findPrevious (TreeItem parentItem, int index) {
-    if (parentItem is null) return 0;
+static HANDLE findPrevious (TreeItem parentItem, int index) {
+    if (parentItem is null) return null;
     if (index < 0) DWT.error (DWT.ERROR_INVALID_RANGE);
-    if (index is 0) return OS.TVI_FIRST;
+    if (index is 0) return cast(HANDLE) OS.TVI_FIRST;
     Tree parent = parentItem.parent;
-    int hwnd = parent.handle, hParent = parentItem.handle;
-    int hFirstItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
-    int hItem = parent.findItem (hFirstItem, index - 1);
-    if (hItem is 0) DWT.error (DWT.ERROR_INVALID_RANGE);
+    auto hwnd = parent.handle;
+    auto hParent = parentItem.handle;
+    HANDLE hFirstItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
+    HANDLE hItem = parent.findItem (hFirstItem, index - 1);
+    if (hItem is null) DWT.error (DWT.ERROR_INVALID_RANGE);
     return hItem;
 }
 
@@ -251,16 +249,18 @@
     strings = null;
     images = null;
     if ((parent.style & DWT.CHECK) !is 0) {
-        int hwnd = parent.handle;
-        TVITEM tvItem = new TVITEM ();
+        auto hwnd = parent.handle;
+        TVITEM tvItem;
         tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
         tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
         tvItem.state = 1 << 12;
         tvItem.hItem = handle;
-        OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+        OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
     }
-    background = foreground = font = -1;
-    cellBackground = cellForeground = cellFont = null;
+    background = foreground = -1;
+    HFONT font = cast(HFONT)-1;
+    cellBackground = cellForeground = null;
+    cellFont = null;
     if ((parent.style & DWT.VIRTUAL) !is 0) cached = false;
 }
 
@@ -289,17 +289,17 @@
  */
 public void clear (int index, bool all) {
     checkWidget ();
-    int hwnd = parent.handle;
-    int hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
-    if (hItem is 0) error (DWT.ERROR_INVALID_RANGE);
+    auto hwnd = parent.handle;
+    HANDLE hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+    if (hItem is null) error (DWT.ERROR_INVALID_RANGE);
     hItem = parent.findItem (hItem, index);
-    if (hItem is 0) error (DWT.ERROR_INVALID_RANGE);
-    TVITEM tvItem = new TVITEM ();
+    if (hItem is null) error (DWT.ERROR_INVALID_RANGE);
+    TVITEM tvItem;
     tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
-    parent.clear (hItem, tvItem);
+    parent.clear (hItem, &tvItem);
     if (all) {
-        hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
-        parent.clearAll (hItem, tvItem, all);
+        hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hItem);
+        parent.clearAll (hItem, &tvItem, all);
     }
 }
 
@@ -324,18 +324,18 @@
  */
 public void clearAll (bool all) {
     checkWidget ();
-    int hwnd = parent.handle;
-    int hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
-    if (hItem is 0) return;
-    TVITEM tvItem = new TVITEM ();
+    auto hwnd = parent.handle;
+    auto hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+    if (hItem is null) return;
+    TVITEM tvItem;
     tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
-    parent.clearAll (hItem, tvItem, all);
+    parent.clearAll (hItem, &tvItem, all);
 }
 
 override void destroyWidget () {
-    TVITEM tvItem = new TVITEM ();
+    TVITEM tvItem;
     tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
-    parent.releaseItem (handle, tvItem, false);
+    parent.releaseItem (handle, &tvItem, false);
     parent.destroyItem (this, handle);
     releaseHandle ();
 }
@@ -424,34 +424,35 @@
 }
 
 RECT getBounds (int index, bool getText, bool getImage, bool fullText) {
-    return getBounds (index, getText, getImage, fullText, false, true, 0);
+    return getBounds (index, getText, getImage, fullText, false, true, null);
 }
 
 //TODO - take into account grid (add bool arg) to damage less during redraw
-RECT getBounds (int index, bool getText, bool getImage, bool fullText, bool fullImage, bool clip, int hDC) {
-    if (!getText && !getImage) return new RECT ();
-    int hwnd = parent.handle;
+RECT getBounds (int index, bool getText, bool getImage, bool fullText, bool fullImage, bool clip, HDC hDC) {
+    if (!getText && !getImage) return RECT.init;
+    auto hwnd = parent.handle;
     if ((parent.style & DWT.VIRTUAL) is 0 && !cached && !parent.painted) {
-        TVITEM tvItem = new TVITEM ();
+        TVITEM tvItem;
         tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
         tvItem.hItem = handle;
         tvItem.pszText = OS.LPSTR_TEXTCALLBACK;
         parent.ignoreCustomDraw = true;
-        OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+        OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
         parent.ignoreCustomDraw = false;
     }
     bool firstColumn = index is 0;
-    int columnCount = 0, hwndHeader = parent.hwndHeader;
-    if (hwndHeader !is 0) {
+    int columnCount = 0;
+    auto hwndHeader = parent.hwndHeader;
+    if (hwndHeader !is null) {
         columnCount = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
         firstColumn = index is OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
     }
-    RECT rect = new RECT ();
+    RECT rect;
     if (firstColumn) {
-        rect.left = handle;
+        rect.left = cast(int) handle;
         bool full = columnCount is 0 && getText && getImage && fullText && fullImage;
-        if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, full ? 0 : 1, rect) is 0) {
-            return new RECT ();
+        if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, full ? 0 : 1, cast(int)&rect) is 0) {
+            return RECT.init;
         }
         if (getImage && !fullImage) {
             if (OS.SendMessage (hwnd, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0) !is 0) {
@@ -463,11 +464,11 @@
             }
         }
         if (fullText || fullImage || clip) {
-            if (hwndHeader !is 0) {
-                RECT headerRect = new RECT ();
+            if (hwndHeader !is null) {
+                RECT headerRect;
                 if (columnCount !is 0) {
-                    if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect) is 0) {
-                        return new RECT ();
+                    if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, cast(int) &headerRect) is 0) {
+                        return RECT.init;
                     }
                 } else {
                     headerRect.right = parent.scrollWidth;
@@ -481,14 +482,14 @@
             }
         }
     } else {
-        if (!(0 <= index && index < columnCount)) return new RECT ();
-        RECT headerRect = new RECT ();
-        if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect) is 0) {
-            return new RECT ();
+        if (!(0 <= index && index < columnCount)) return RECT.init;
+        RECT headerRect;
+        if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, cast(int) &headerRect) is 0) {
+            return RECT.init;
         }
-        rect.left = handle;
-        if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, rect) is 0) {
-            return new RECT ();
+        rect.left = cast(int)handle;
+        if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, cast(int) &rect) is 0) {
+            return RECT.init;
         }
         rect.left = headerRect.left;
         if (fullText && getImage) {
@@ -510,21 +511,22 @@
                     rect.left = rect.right + Tree.INSET;
                     rect.right = headerRect.right;
                 } else {
-                    String string = index is 0 ? text : strings !is null ? strings [index] : null;
+                    char[] string = index is 0 ? text : strings !is null ? strings [index] : null;
                     if (string !is null) {
-                        RECT textRect = new RECT ();
-                        TCHAR buffer = new TCHAR (parent.getCodePage (), string, false);
+                        RECT textRect;
+                        TCHAR[] buffer = StrToTCHARs (parent.getCodePage (), string, false);
                         int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT;
-                        int hNewDC = hDC, hFont = 0;
-                        if (hDC is 0) {
+                        auto hNewDC = hDC;
+                        HFONT hFont;
+                        if (hDC is null) {
                             hNewDC = OS.GetDC (hwnd);
-                            hFont = cellFont !is null ? cellFont [index] : -1;
-                            if (hFont is -1) hFont = font;
-                            if (hFont is -1) hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
+                            hFont = cellFont !is null ? cellFont [index] : cast(HFONT)-1;
+                            if (hFont is cast(HFONT)-1) hFont = font;
+                            if (hFont is cast(HFONT)-1) hFont = cast(HFONT) OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
                             hFont = OS.SelectObject (hNewDC, hFont);
                         }
-                        OS.DrawText (hNewDC, buffer, buffer.length (), textRect, flags);
-                        if (hDC is 0) {
+                        OS.DrawText (hNewDC, buffer.ptr, buffer.length, &textRect, flags);
+                        if (hDC is null) {
                             OS.SelectObject (hNewDC, hFont);
                             OS.ReleaseDC (hwnd, hNewDC);
                         }
@@ -567,12 +569,12 @@
     checkWidget ();
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
     if ((parent.style & DWT.CHECK) is 0) return false;
-    int hwnd = parent.handle;
-    TVITEM tvItem = new TVITEM ();
+    auto hwnd = parent.handle;
+    TVITEM tvItem;
     tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
     tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
     tvItem.hItem = handle;
-    int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+    int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
     return (result !is 0) && (((tvItem.state >> 12) & 1) is 0);
 }
 
@@ -590,12 +592,13 @@
  */
 public bool getExpanded () {
     checkWidget ();
-    int hwnd = parent.handle, state = 0;
+    auto hwnd = parent.handle;
+    int state = 0;
     if (OS.IsWinCE) {
-        TVITEM tvItem = new TVITEM ();
+        TVITEM tvItem;
         tvItem.hItem = handle;
         tvItem.mask = OS.TVIF_STATE;
-        OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+        OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
         state = tvItem.state;
     } else {
         /*
@@ -624,7 +627,7 @@
 public Font getFont () {
     checkWidget ();
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
-    return font is -1 ? parent.getFont () : Font.win32_new (display, font);
+    return font is cast(HFONT)-1 ? parent.getFont () : Font.win32_new (display, font);
 }
 
 /**
@@ -646,8 +649,8 @@
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
     int count = Math.max (1, parent.getColumnCount ());
     if (0 > index || index > count -1) return getFont ();
-    int hFont = (cellFont !is null) ? cellFont [index] : font;
-    return hFont is -1 ? getFont () : Font.win32_new (display, hFont);
+    auto hFont = (cellFont !is null) ? cellFont [index] : font;
+    return hFont is cast(HFONT)-1 ? getFont () : Font.win32_new (display, hFont);
 }
 
 /**
@@ -710,12 +713,12 @@
     checkWidget ();
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
     if ((parent.style & DWT.CHECK) is 0) return false;
-    int hwnd = parent.handle;
-    TVITEM tvItem = new TVITEM ();
+    auto hwnd = parent.handle;
+    TVITEM tvItem;
     tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
     tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
     tvItem.hItem = handle;
-    int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+    int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
     return (result !is 0) && ((tvItem.state >> 12) > 2);
 }
 
@@ -740,11 +743,11 @@
     checkWidget ();
     if (index < 0) error (DWT.ERROR_INVALID_RANGE);
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
-    int hwnd = parent.handle;
-    int hFirstItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
-    if (hFirstItem is 0) error (DWT.ERROR_INVALID_RANGE);
-    int hItem = parent.findItem (hFirstItem, index);
-    if (hItem is 0) error (DWT.ERROR_INVALID_RANGE);
+    auto hwnd = parent.handle;
+    auto hFirstItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+    if (hFirstItem is null) error (DWT.ERROR_INVALID_RANGE);
+    auto hItem = parent.findItem (hFirstItem, index);
+    if (hItem is null) error (DWT.ERROR_INVALID_RANGE);
     return parent._getItem (hItem);
 }
 
@@ -762,9 +765,9 @@
 public int getItemCount () {
     checkWidget ();
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
-    int hwnd = parent.handle;
-    int hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
-    if (hItem is 0) return 0;
+    auto hwnd = parent.handle;
+    auto hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+    if (hItem is null) return 0;
     return parent.getItemCount (hItem);
 }
 
@@ -787,7 +790,7 @@
 public TreeItem [] getItems () {
     checkWidget ();
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
-    int hwnd = parent.handle;
+    auto hwnd = parent.handle;
     int hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
     if (hItem is 0) return new TreeItem [0];
     return parent.getItems (hItem);
@@ -875,12 +878,12 @@
  */
 public TreeItem getParentItem () {
     checkWidget ();
-    int hwnd = parent.handle;
-    int hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, handle);
-    return hItem !is 0 ? parent._getItem (hItem) : null;
+    auto hwnd = parent.handle;
+    auto hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, handle);
+    return hItem !is null ? parent._getItem (hItem) : null;
 }
 
-override public String getText () {
+override public char[] getText () {
     checkWidget();
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
     return super.getText ();
@@ -900,13 +903,13 @@
  *
  * @since 3.1
  */
-public String getText (int index) {
+public char[] getText (int index) {
     checkWidget();
     if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED);
     if (index is 0) return getText ();
     if (strings !is null) {
         if (0 <= index && index < strings.length) {
-            String string = strings [index];
+            char[] string = strings [index];
             return string !is null ? string : "";
         }
     }
@@ -964,17 +967,17 @@
     checkWidget ();
     if (item is null) error (DWT.ERROR_NULL_ARGUMENT);
     if (item.isDisposed()) error(DWT.ERROR_INVALID_ARGUMENT);
-    int hwnd = parent.handle;
-    int hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
-    return hItem is 0 ? -1 : parent.findIndex (hItem, item.handle);
+    auto hwnd = parent.handle;
+    auto hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+    return hItem is null ? -1 : parent.findIndex (hItem, item.handle);
 }
 
 void redraw () {
     if (parent.currentItem is this || parent.drawCount !is 0) return;
-    int hwnd = parent.handle;
+    auto hwnd = parent.handle;
     if (!OS.IsWindowVisible (hwnd)) return;
-    RECT rect = new RECT ();
-    rect.left = handle;
+    RECT rect;
+    rect.left = cast(int)handle;
     /*
     * When there are no columns and the tree is not
     * full selection, redraw only the text.  This is
@@ -982,8 +985,8 @@
     */
     bool full = (parent.style & (DWT.FULL_SELECTION | DWT.VIRTUAL)) !is 0;
     if (!full) {
-        int hwndHeader = parent.hwndHeader;
-        if (hwndHeader !is 0) {
+        auto hwndHeader = parent.hwndHeader;
+        if (hwndHeader !is null) {
             full = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0) !is 0;
         }
         if (!full) {
@@ -992,32 +995,32 @@
             }
         }
     }
-    if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, full ? 0 : 1, rect) !is 0) {
-        OS.InvalidateRect (hwnd, rect, true);
+    if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, full ? 0 : 1, cast(int) &rect) !is 0) {
+        OS.InvalidateRect (hwnd, &rect, true);
     }
 }
 
 void redraw (int column, bool drawText, bool drawImage) {
     if (parent.currentItem is this || parent.drawCount !is 0) return;
-    int hwnd = parent.handle;
+    auto hwnd = parent.handle;
     if (!OS.IsWindowVisible (hwnd)) return;
     bool fullImage = column is 0 && drawText && drawImage;
-    RECT rect = getBounds (column, drawText, drawImage, true, fullImage, true, 0);
-    OS.InvalidateRect (hwnd, rect, true);
+    RECT rect = getBounds (column, drawText, drawImage, true, fullImage, true, null);
+    OS.InvalidateRect (hwnd, &rect, true);
 }
 
 override void releaseChildren (bool destroy) {
     if (destroy) {
-        TVITEM tvItem = new TVITEM ();
+        TVITEM tvItem;
         tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
-        parent.releaseItems (handle, tvItem);
+        parent.releaseItems (handle, &tvItem);
     }
     super.releaseChildren (destroy);
 }
 
 override void releaseHandle () {
     super.releaseHandle ();
-    handle = 0;
+    handle = null;
     parent = null;
 }
 
@@ -1025,7 +1028,8 @@
     super.releaseWidget ();
     strings = null;
     images = null;
-    cellBackground = cellForeground = cellFont = null;
+    cellBackground = cellForeground = null;
+    cellFont = null;
 }
 
 /**
@@ -1040,20 +1044,20 @@
  */
 public void removeAll () {
     checkWidget ();
-    int hwnd = parent.handle;
-    TVITEM tvItem = new TVITEM ();
+    auto hwnd = parent.handle;
+    TVITEM tvItem;
     tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
-    tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
-    while (tvItem.hItem !is 0) {
-        OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+    tvItem.hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, cast(int)handle);
+    while (tvItem.hItem !is null) {
+        OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, cast(int)&tvItem);
         TreeItem item = tvItem.lParam !is -1 ? parent.items [tvItem.lParam] : null;
         if (item !is null && !item.isDisposed ()) {
             item.dispose ();
         } else {
-            parent.releaseItem (tvItem.hItem, tvItem, false);
+            parent.releaseItem (tvItem.hItem, &tvItem, false);
             parent.destroyItem (null, tvItem.hItem);
         }
-        tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+        tvItem.hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, cast(int)handle);
     }
 }
 
@@ -1148,12 +1152,12 @@
 public void setChecked (bool checked) {
     checkWidget ();
     if ((parent.style & DWT.CHECK) is 0) return;
-    int hwnd = parent.handle;
-    TVITEM tvItem = new TVITEM ();
+    auto hwnd = parent.handle;
+    TVITEM tvItem;
     tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
     tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
     tvItem.hItem = handle;
-    OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+    OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
     int state = tvItem.state >> 12;
     if (checked) {
         if ((state & 0x1) !is 0) state++;
@@ -1164,7 +1168,7 @@
     if (tvItem.state is state) return;
     if ((parent.style & DWT.VIRTUAL) !is 0) cached = true;
     tvItem.state = state;
-    OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+    OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
     /*
     * Bug in Windows.  When TVM_SETITEM is used to set
     * the state image of an item inside TVN_GETDISPINFO,
@@ -1173,10 +1177,10 @@
     */
     if ((parent.style & DWT.VIRTUAL) !is 0) {
         if (parent.currentItem is this && OS.IsWindowVisible (hwnd)) {
-            RECT rect = new RECT ();
-            rect.left = handle;
-            if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, rect) !is 0) {
-                OS.InvalidateRect (hwnd, rect, true);
+            RECT rect;
+            rect.left = cast(int) handle;
+            if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, cast(int) &rect) !is 0) {
+                OS.InvalidateRect (hwnd, &rect, true);
             }
         }
     }
@@ -1197,16 +1201,16 @@
     checkWidget ();
 
     /* Do nothing when the item is a leaf or already expanded */
-    int hwnd = parent.handle;
+    auto hwnd = parent.handle;
     if (OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle) is 0) {
         return;
     }
     int state = 0;
     if (OS.IsWinCE) {
-        TVITEM tvItem = new TVITEM ();
+        TVITEM tvItem;
         tvItem.hItem = handle;
         tvItem.mask = OS.TVIF_STATE;
-        OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+        OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
         state = tvItem.state;
     } else {
         /*
@@ -1232,39 +1236,44 @@
     * it is safe to turn redraw back on without redrawing
     * the control.
     */
-    RECT oldRect = null;
+    RECT oldRect;
     RECT [] rects = null;
-    SCROLLINFO oldInfo = null;
-    int count = 0, hBottomItem = 0;
+    SCROLLINFO oldInfo;
+    bool oldInfoNull = true;
+    int count = 0;
+    HANDLE hBottomItem;
     bool redraw = false, noScroll = true;
-    int hTopItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
-    if (noScroll && hTopItem !is 0) {
-        oldInfo = new SCROLLINFO ();
+    HANDLE hTopItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+    if (noScroll && hTopItem !is null) {
+        //oldInfo = new SCROLLINFO ();
+        oldInfoNull = false;
         oldInfo.cbSize = SCROLLINFO.sizeof;
         oldInfo.fMask = OS.SIF_ALL;
-        if (!OS.GetScrollInfo (hwnd, OS.SB_HORZ, oldInfo)) {
-            oldInfo = null;
+        if (!OS.GetScrollInfo (hwnd, OS.SB_HORZ, &oldInfo)) {
+            //oldInfo = null;
+            oldInfoNull = true;
         }
         if (parent.drawCount is 0 && OS.IsWindowVisible (hwnd)) {
             bool noAnimate = true;
             count = OS.SendMessage (hwnd, OS.TVM_GETVISIBLECOUNT, 0, 0);
             rects = new RECT [count + 1];
-            int hItem = hTopItem, index = 0;
-            while (hItem !is 0 && (noAnimate || hItem !is handle) && index < count) {
-                RECT rect = new RECT ();
-                rect.left = hItem;
-                if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, rect) !is 0) {
+            HANDLE hItem = hTopItem;
+            int index = 0;
+            while (hItem !is null && (noAnimate || hItem !is handle) && index < count) {
+                RECT rect;
+                rect.left = cast(int) hItem;
+                if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, cast(int) &rect) !is 0) {
                     rects [index++] = rect;
                 }
-                hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hItem);
+                hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, cast(int) &hItem);
             }
             if (noAnimate || hItem !is handle) {
                 redraw = true;
                 count = index;
                 hBottomItem = hItem;
-                oldRect = new RECT ();
-                OS.GetClientRect (hwnd, oldRect);
-                int topHandle = parent.topHandle ();
+                //oldRect = new RECT ();
+                OS.GetClientRect (hwnd, &oldRect);
+                auto topHandle = parent.topHandle ();
                 OS.UpdateWindow (topHandle);
                 OS.DefWindowProc (topHandle, OS.WM_SETREDRAW, 0, 0);
                 if (hwnd !is topHandle) {
@@ -1291,7 +1300,7 @@
     * check whether the selection has changed and issue
     * the event.
     */
-    int hOldItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+    auto hOldItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
 
     /* Expand or collapse the item */
     parent.ignoreExpand = true;
@@ -1299,26 +1308,27 @@
     parent.ignoreExpand = false;
 
     /* Scroll back to the top item */
-    if (noScroll && hTopItem !is 0) {
+    if (noScroll && hTopItem !is null) {
         bool collapsed = false;
         if (!expanded) {
-            RECT rect = new RECT ();
-            rect.left = hTopItem;
-            while (hTopItem !is 0 && OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, rect) is 0) {
-                hTopItem = rect.left = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hTopItem);
+            RECT rect;
+            rect.left = cast(int)hTopItem;
+            while (hTopItem !is null && OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, cast(int) &rect) is 0) {
+                rect.left = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, hTopItem);
+                hTopItem = cast(HANDLE) rect.left;
                 collapsed = true;
             }
         }
         bool scrolled = true;
-        if (hTopItem !is 0) {
+        if (hTopItem !is null) {
             OS.SendMessage (hwnd, OS.TVM_SELECTITEM, OS.TVGN_FIRSTVISIBLE, hTopItem);
-            scrolled = hTopItem !is OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
+            scrolled = hTopItem !is cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_FIRSTVISIBLE, 0);
         }
-        if (!collapsed && !scrolled && oldInfo !is null) {
-            SCROLLINFO newInfo = new SCROLLINFO ();
+        if (!collapsed && !scrolled && !oldInfoNull ) {
+            SCROLLINFO newInfo;
             newInfo.cbSize = SCROLLINFO.sizeof;
             newInfo.fMask = OS.SIF_ALL;
-            if (OS.GetScrollInfo (hwnd, OS.SB_HORZ, newInfo)) {
+            if (OS.GetScrollInfo (hwnd, OS.SB_HORZ, &newInfo)) {
                 if (oldInfo.nPos !is newInfo.nPos) {
                     int lParam = OS.SB_THUMBPOSITION | ((oldInfo.nPos << 16) & 0xFFFF0000);
                     OS.SendMessage (hwnd, OS.WM_HSCROLL, lParam, 0);
@@ -1328,25 +1338,26 @@
         if (redraw) {
             bool fixScroll = false;
             if (!collapsed && !scrolled) {
-                RECT newRect = new RECT ();
-                OS.GetClientRect (hwnd, newRect);
-                if (OS.EqualRect (oldRect, newRect)) {
-                    int hItem = hTopItem, index = 0;
-                    while (hItem !is 0 && index < count) {
-                        RECT rect = new RECT ();
-                        rect.left = hItem;
-                        if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, rect) !is 0) {
-                            if (!OS.EqualRect (rect, rects [index])) {
+                RECT newRect;
+                OS.GetClientRect (hwnd, &newRect);
+                if (OS.EqualRect (&oldRect, &newRect)) {
+                    HANDLE hItem = hTopItem;
+                    int index = 0;
+                    while (hItem !is null && index < count) {
+                        RECT rect;
+                        rect.left = cast(int) hItem;
+                        if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, cast(int) &rect) !is 0) {
+                            if (!OS.EqualRect (&rect, & rects [index])) {
                                 break;
                             }
                         }
-                        hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hItem);
+                        hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXTVISIBLE, hItem);
                         index++;
                     }
                     fixScroll = index is count && hItem is hBottomItem;
                 }
             }
-            int topHandle = parent.topHandle ();
+            auto topHandle = parent.topHandle ();
             OS.DefWindowProc (topHandle, OS.WM_SETREDRAW, 1, 0);
             if (hwnd !is topHandle) {
                 OS.DefWindowProc (hwnd, OS.WM_SETREDRAW, 1, 0);
@@ -1357,17 +1368,17 @@
 //          OS.SendMessage (hwnd, OS.WM_SETREDRAW, 1, 0);
             if (fixScroll) {
                 parent.updateScrollBar ();
-                SCROLLINFO info = new SCROLLINFO ();
+                SCROLLINFO info;
                 info.cbSize = SCROLLINFO.sizeof;
                 info.fMask = OS.SIF_ALL;
-                if (OS.GetScrollInfo (hwnd, OS.SB_VERT, info)) {
-                    OS.SetScrollInfo (hwnd, OS.SB_VERT, info, true);
+                if (OS.GetScrollInfo (hwnd, OS.SB_VERT, &info)) {
+                    OS.SetScrollInfo (hwnd, OS.SB_VERT, &info, true);
                 }
                 if (handle is hBottomItem) {
-                    RECT rect = new RECT ();
-                    rect.left = hBottomItem;
-                    if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, rect) !is 0) {
-                        OS.InvalidateRect (hwnd, rect, true);
+                    RECT rect;
+                    rect.left = cast(int) hBottomItem;
+                    if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, cast(int)&rect) !is 0) {
+                        OS.InvalidateRect (hwnd, &rect, true);
                     }
                 }
             } else {
@@ -1376,17 +1387,17 @@
                     if (hwnd !is topHandle) OS.InvalidateRect (hwnd, null, true);
                 } else {
                     int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN;
-                    OS.RedrawWindow (topHandle, null, 0, flags);
+                    OS.RedrawWindow (topHandle, null, null, flags);
                 }
             }
         }
     }
 
     /* Check for a selection event */
-    int hNewItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+    auto hNewItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
     if (hNewItem !is hOldItem) {
         Event event = new Event ();
-        if (hNewItem !is 0) {
+        if (hNewItem !is null) {
             event.item = parent._getItem (hNewItem);
             parent.hAnchor = hNewItem;
         }
@@ -1416,7 +1427,7 @@
     if (font !is null && font.isDisposed ()) {
         DWT.error (DWT.ERROR_INVALID_ARGUMENT);
     }
-    int hFont = -1;
+    HFONT hFont = cast(HFONT)-1;
     if (font !is null) {
         parent.customDraw = true;
         hFont = font.handle;
@@ -1433,12 +1444,12 @@
     if ((parent.style & DWT.VIRTUAL) is 0 && !cached && !parent.painted) {
         return;
     }
-    int hwnd = parent.handle;
-    TVITEM tvItem = new TVITEM ();
+    auto hwnd = parent.handle;
+    TVITEM tvItem;
     tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
     tvItem.hItem = handle;
     tvItem.pszText = OS.LPSTR_TEXTCALLBACK;
-    OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+    OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
 }
 
 
@@ -1468,15 +1479,15 @@
     }
     int count = Math.max (1, parent.getColumnCount ());
     if (0 > index || index > count - 1) return;
-    int hFont = -1;
+    HFONT hFont = cast(HFONT)-1;
     if (font !is null) {
         parent.customDraw = true;
         hFont = font.handle;
     }
     if (cellFont is null) {
-        cellFont = new int [count];
+        cellFont = new HFONT [count];
         for (int i = 0; i < count; i++) {
-            cellFont [i] = -1;
+            cellFont [i] = cast(HFONT) -1;
         }
     }
     if (cellFont [index] is hFont) return;
@@ -1492,12 +1503,12 @@
         if ((parent.style & DWT.VIRTUAL) is 0 && !cached && !parent.painted) {
             return;
         }
-        int hwnd = parent.handle;
-        TVITEM tvItem = new TVITEM ();
+        auto hwnd = parent.handle;
+        TVITEM tvItem;
         tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
         tvItem.hItem = handle;
         tvItem.pszText = OS.LPSTR_TEXTCALLBACK;
-        OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+        OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
     } else {
         redraw (index, true, false);
     }
@@ -1596,12 +1607,12 @@
 public void setGrayed (bool grayed) {
     checkWidget ();
     if ((parent.style & DWT.CHECK) is 0) return;
-    int hwnd = parent.handle;
-    TVITEM tvItem = new TVITEM ();
+    auto hwnd = parent.handle;
+    TVITEM tvItem;
     tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
     tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
     tvItem.hItem = handle;
-    OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+    OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, &tvItem);
     int state = tvItem.state >> 12;
     if (grayed) {
         if (state <= 2) state +=2;
@@ -1612,7 +1623,7 @@
     if (tvItem.state is state) return;
     if ((parent.style & DWT.VIRTUAL) !is 0) cached = true;
     tvItem.state = state;
-    OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+    OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
     /*
     * Bug in Windows.  When TVM_SETITEM is used to set
     * the state image of an item inside TVN_GETDISPINFO,
@@ -1621,10 +1632,10 @@
     */
     if ((parent.style & DWT.VIRTUAL) !is 0) {
         if (parent.currentItem is this && OS.IsWindowVisible (hwnd)) {
-            RECT rect = new RECT ();
-            rect.left = handle;
-            if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, rect) !is 0) {
-                OS.InvalidateRect (hwnd, rect, true);
+            RECT rect;
+            rect.left = cast(int)handle;
+            if (OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 0, cast(int)&rect) !is 0) {
+                OS.InvalidateRect (hwnd, &rect, true);
             }
         }
     }
@@ -1678,7 +1689,7 @@
     Image oldImage = null;
     if (index is 0) {
         if (image !is null && image.type is DWT.ICON) {
-            if (image.equals (this.image)) return;
+            if (image==/*eq*/this.image) return;
         }
         oldImage = this.image;
         super.setImage (image);
@@ -1691,7 +1702,7 @@
     }
     if (images !is null) {
         if (image !is null && image.type is DWT.ICON) {
-            if (image.equals (images [index])) return;
+            if (image==/*eq*/images [index]) return;
         }
         oldImage = images [index];
         images [index] = image;
@@ -1706,8 +1717,8 @@
         if ((parent.style & DWT.VIRTUAL) is 0 &&!cached && !parent.painted) {
             return;
         }
-        int hwnd = parent.handle;
-        TVITEM tvItem = new TVITEM ();
+        auto hwnd = parent.handle;
+        TVITEM tvItem;
         tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_IMAGE | OS.TVIF_SELECTEDIMAGE;
         tvItem.hItem = handle;
         tvItem.iImage = tvItem.iSelectedImage = OS.I_IMAGECALLBACK;
@@ -1719,7 +1730,7 @@
         */
         tvItem.mask |= OS.TVIF_TEXT;
         tvItem.pszText = OS.LPSTR_TEXTCALLBACK;
-        OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+        OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
     } else {
         bool drawText = (image is null && oldImage !is null) || (image !is null && oldImage is null);
         redraw (index, drawText, true);
@@ -1746,8 +1757,8 @@
 public void setItemCount (int count) {
     checkWidget ();
     count = Math.max (0, count);
-    int hwnd = parent.handle;
-    int hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+    auto hwnd = parent.handle;
+    auto hItem = cast(HANDLE) OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
     parent.setItemCount (count, handle, hItem);
 }
 
@@ -1766,11 +1777,11 @@
  *
  * @since 3.1
  */
-override public void setText (String [] strings) {
+public void setText (char[][] strings) {
     checkWidget();
     if (strings is null) error (DWT.ERROR_NULL_ARGUMENT);
     for (int i=0; i<strings.length; i++) {
-        String string = strings [i];
+        char[] string = strings [i];
         if (string !is null) setText (i, string);
     }
 }
@@ -1791,21 +1802,21 @@
  *
  * @since 3.1
  */
-public void setText (int index, String string) {
+public void setText (int index, char[] string) {
     checkWidget();
     if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
     if (index is 0) {
-        if (string.equals (text)) return;
+        if (string==/*eq*/text) return;
         super.setText (string);
     }
     int count = Math.max (1, parent.getColumnCount ());
     if (0 > index || index > count - 1) return;
     if (strings is null && index !is 0) {
-        strings = new String [count];
+        strings = new char[] [count];
         strings [0] = text;
     }
     if (strings !is null) {
-        if (string.equals (strings [index])) return;
+        if (string==/*eq*/strings [index]) return;
         strings [index] = string;
     }
     if ((parent.style & DWT.VIRTUAL) !is 0) cached = true;
@@ -1813,18 +1824,18 @@
         if ((parent.style & DWT.VIRTUAL) is 0 && !cached && !parent.painted) {
             return;
         }
-        int hwnd = parent.handle;
-        TVITEM tvItem = new TVITEM ();
+        auto hwnd = parent.handle;
+        TVITEM tvItem;
         tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
         tvItem.hItem = handle;
         tvItem.pszText = OS.LPSTR_TEXTCALLBACK;
-        OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+        OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, &tvItem);
     } else {
         redraw (index, true, false);
     }
 }
 
-public void setText (String string) {
+override public void setText (char[] string) {
     checkWidget();
     setText (0, string);
 }
@@ -1836,4 +1847,4 @@
 }
 
 }
-++/
+
--- a/dwt/widgets/Widget.d	Mon Feb 04 22:32:14 2008 +0100
+++ b/dwt/widgets/Widget.d	Tue Feb 05 00:02:38 2008 +0100
@@ -456,7 +456,7 @@
     return display.filters (eventType);
 }
 
-Widget findItem (int id) {
+Widget findItem (HANDLE id) {
     return null;
 }