changeset 40:3052439af4b5

Shell
author Frank Benoit <benoit@tionex.de>
date Fri, 01 Feb 2008 20:19:46 +0100
parents f5e70f9aeeda
children f871c501e610
files dwt/dwthelper/utils.d dwt/internal/win32/OS.d dwt/widgets/Canvas.d dwt/widgets/Decorations.d dwt/widgets/Menu.d dwt/widgets/Shell.d dwt/widgets/ToolTip.d dwt/widgets/Widget.d
diffstat 8 files changed, 340 insertions(+), 337 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/dwthelper/utils.d	Fri Feb 01 17:45:36 2008 +0100
+++ b/dwt/dwthelper/utils.d	Fri Feb 01 20:19:46 2008 +0100
@@ -137,8 +137,21 @@
     }
 }
 
+struct GCStats {
+    size_t poolsize;        // total size of pool
+    size_t usedsize;        // bytes allocated
+    size_t freeblocks;      // number of blocks marked FREE
+    size_t freelistsize;    // total of memory on free lists
+    size_t pageblocks;      // number of blocks marked PAGE
+}
+
+extern(System) GCStats gc_stats();
+
+size_t RuntimeTotalMemory(){
+    GCStats s = gc_stats();
+    return s.poolsize;
+}
 
 
 
 
-
--- a/dwt/internal/win32/OS.d	Fri Feb 01 17:45:36 2008 +0100
+++ b/dwt/internal/win32/OS.d	Fri Feb 01 20:19:46 2008 +0100
@@ -71,7 +71,7 @@
         public const static BOOL IsWinCE = false;
     }
 
-    public static const BOOL IsPPC_;
+    public static const BOOL IsPPC_ = false;
     public static const BOOL IsHPC = false;
 
     // PORTING_FIXME, is it Windows WFSP?
@@ -119,7 +119,7 @@
         IsWin95 = (info.dwPlatformId is VER_PLATFORM_WIN32_WINDOWS);
         IsWinNT = (info.dwPlatformId is VER_PLATFORM_WIN32_NT);
         //IsSP_ = false;
-        IsPPC_ = false;
+        //IsPPC_ = false;
         //IsHPC = false;
         IsDBLocale = false;
         WIN32_MAJOR = info.dwMajorVersion;
@@ -999,7 +999,7 @@
     public static const int LOCALE_USER_DEFAULT = 1024;
     public static const int LOGPIXELSX = 0x58;
     public static const int LOGPIXELSY = 0x5a;
-    public static const int LPSTR_TEXTCALLBACK = 0xffffffff;
+    public static const TCHAR* LPSTR_TEXTCALLBACK = cast(TCHAR*)0xffffffff;
     public static const int LR_DEFAULTCOLOR = 0x0;
     public static const int LR_SHARED = 0x8000;
     public static const int LVCFMT_BITMAP_ON_RIGHT = 0x1000;
@@ -4194,6 +4194,7 @@
 alias WINAPI.FreeLibrary FreeLibrary;
 alias WINAPI.GdiSetBatchLimit GdiSetBatchLimit;
 alias WINAPI.GetACP GetACP;
+alias STDWIN.GetAsyncKeyState GetAsyncKeyState;
 alias WINAPI.GetActiveWindow GetActiveWindow;
 alias WINAPI.GetBkColor GetBkColor;
 alias WINAPI.GetCapture GetCapture;
--- a/dwt/widgets/Canvas.d	Fri Feb 01 17:45:36 2008 +0100
+++ b/dwt/widgets/Canvas.d	Fri Feb 01 20:19:46 2008 +0100
@@ -50,6 +50,7 @@
 public class Canvas : Composite {
 
     alias Composite.drawBackground drawBackground;
+    alias Composite.windowProc windowProc;
 
     Caret caret;
 
--- a/dwt/widgets/Decorations.d	Fri Feb 01 17:45:36 2008 +0100
+++ b/dwt/widgets/Decorations.d	Fri Feb 01 20:19:46 2008 +0100
@@ -112,6 +112,9 @@
  */
 
 public class Decorations : Canvas {
+
+    alias Canvas.windowProc windowProc;
+
     Image image, smallImage, largeImage;
     Image [] images;
     Menu menuBar;
--- a/dwt/widgets/Menu.d	Fri Feb 01 17:45:36 2008 +0100
+++ b/dwt/widgets/Menu.d	Fri Feb 01 20:19:46 2008 +0100
@@ -34,6 +34,7 @@
 public MenuItem [] getItems () ;
 void fixMenus (Decorations newParent) ;
 public bool isEnabled () ;
+public bool getEnabled () ;
 }
 /++
 import dwt.DWT;
--- a/dwt/widgets/Shell.d	Fri Feb 01 17:45:36 2008 +0100
+++ b/dwt/widgets/Shell.d	Fri Feb 01 20:19:46 2008 +0100
@@ -10,31 +10,6 @@
  *******************************************************************************/
 module dwt.widgets.Shell;
 
-import dwt.widgets.Decorations;
-import dwt.widgets.Control;
-import dwt.widgets.Menu;
-import dwt.widgets.ToolTip;
-import dwt.internal.win32.OS;
-
-class Shell : Decorations {
-    HIMC hIMC;
-    HWND hwndMDIClient_;
-    //, lpstrTip, toolTipHandle, balloonTipHandle;
-    Menu activeMenu;
-    void checkWidget ();
-    void updateModal () ;
-    void fixShell (Shell newShell, Control control) ;
-    void setActiveControl (Control control) ;
-    void register () ;
-    void releaseBrushes () ;
-    void releaseChildren (bool destroy) ;
-    void setToolTipText (HWND hwnd, char[] text) ;
-    void fixToolTip () ;
-    ToolTip findToolTip (int id) ;
-void setToolTipTitle (HWND hwndToolTip, char[] text, HICON icon) ;
-HWND hwndMDIClient () ;
-}
-/++
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.events.ShellListener;
@@ -44,6 +19,16 @@
 import dwt.graphics.Region;
 import dwt.internal.win32.OS;
 
+import dwt.widgets.Composite;
+import dwt.widgets.Decorations;
+import dwt.widgets.Control;
+import dwt.widgets.Menu;
+import dwt.widgets.ToolTip;
+import dwt.widgets.Display;
+import dwt.widgets.TypedListener;
+
+import dwt.dwthelper.utils;
+
 /**
  * Instances of this class represent the "windows"
  * which the desktop or "window manager" is managing.
@@ -140,34 +125,47 @@
  * @see Decorations
  * @see DWT
  */
-public class Shell extends Decorations {
+public class Shell : Decorations {
     Menu activeMenu;
     ToolTip [] toolTips;
-    int hIMC, hwndMDIClient, lpstrTip, toolTipHandle, balloonTipHandle;
+    HIMC hIMC;
+    HWND hwndMDIClient_;
+    TCHAR* lpstrTip;
+    HANDLE toolTipHandle_;
+    HANDLE balloonTipHandle_;
     int minWidth = DWT.DEFAULT, minHeight = DWT.DEFAULT;
-    int [] brushes;
+    HBRUSH [] brushes;
     bool showWithParent;
-    String toolTitle, balloonTitle;
-    int toolIcon, balloonIcon;
-    int windowProc;
+    char[] toolTitle, balloonTitle;
+    HICON toolIcon;
+    HICON balloonIcon;
+    alias extern(Windows) int function(HWND, uint, uint, int) TWindowProc;
+    TWindowProc windowProc_;
     Control lastActive, lockToolTipControl;
-    SHACTIVATEINFO psai;
+    static if( OS.IsWinCE ){
+        SHACTIVATEINFO psai;
+    }
     Region region;
-    static /*final*/ int ToolTipProc;
-    static final int DialogProc;
-    static final TCHAR DialogClass = new TCHAR (0, OS.IsWinCE ? "Dialog" : "#32770", true);
-    final static int [] SYSTEM_COLORS = {
+    static /*final*/ TWindowProc ToolTipProc;
+    static const TWindowProc DialogProc;
+    static if( OS.IsWinCE ){
+        static const TCHAR[] DialogClass = "Dialog\0";
+    }
+    else{
+        static const TCHAR[] DialogClass = "#32770\0";
+    }
+    const static int [] SYSTEM_COLORS = [
         OS.COLOR_BTNFACE,
         OS.COLOR_WINDOW,
         OS.COLOR_BTNTEXT,
         OS.COLOR_WINDOWTEXT,
         OS.COLOR_HIGHLIGHT,
         OS.COLOR_SCROLLBAR,
-    };
+    ];
     final static int BRUSHES_SIZE = 32;
-    static {
-        WNDCLASS lpWndClass = new WNDCLASS ();
-        OS.GetClassInfo (0, DialogClass, lpWndClass);
+    static this() {
+        WNDCLASS lpWndClass;
+        OS.GetClassInfo (null, DialogClass.ptr, &lpWndClass);
         DialogProc = lpWndClass.lpfnWndProc;
     }
 
@@ -180,8 +178,8 @@
  *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
  * </ul>
  */
-public Shell () {
-    this ((Display) null);
+public this () {
+    this (cast(Display) null);
 }
 
 /**
@@ -219,8 +217,8 @@
  * @see DWT#APPLICATION_MODAL
  * @see DWT#SYSTEM_MODAL
  */
-public Shell (int style) {
-    this ((Display) null, style);
+public this (int style) {
+    this (cast(Display) null, style);
 }
 
 /**
@@ -242,7 +240,7 @@
  *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
  * </ul>
  */
-public Shell (Display display) {
+public this (Display display) {
     this (display, OS.IsWinCE ? DWT.NONE : DWT.SHELL_TRIM);
 }
 
@@ -289,11 +287,11 @@
  * @see DWT#APPLICATION_MODAL
  * @see DWT#SYSTEM_MODAL
  */
-public Shell (Display display, int style) {
-    this (display, null, style, 0, false);
+public this (Display display, int style) {
+    this (display, null, style, null, false);
 }
 
-Shell (Display display, Shell parent, int style, int handle, bool embedded) {
+this (Display display, Shell parent, int style, HWND handle, bool embedded) {
     super ();
     checkSubclass ();
     if (display is null) display = Display.getCurrent ();
@@ -308,7 +306,7 @@
     this.parent = parent;
     this.display = display;
     this.handle = handle;
-    if (handle !is 0 && !embedded) {
+    if (handle !is null && !embedded) {
         state |= FOREIGN_HANDLE;
     }
     createWidget ();
@@ -336,7 +334,7 @@
  *    <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
  * </ul>
  */
-public Shell (Shell parent) {
+public this (Shell parent) {
     this (parent, OS.IsWinCE ? DWT.NONE : DWT.DIALOG_TRIM);
 }
 
@@ -387,8 +385,8 @@
  * @see DWT#APPLICATION_MODAL
  * @see DWT#SYSTEM_MODAL
  */
-public Shell (Shell parent, int style) {
-    this (parent !is null ? parent.display : null, parent, style, 0, false);
+public this (Shell parent, int style) {
+    this (parent !is null ? parent.display : null, parent, style, null, false);
 }
 
 /**
@@ -405,11 +403,11 @@
  * @param handle the handle for the shell
  * @return a new shell object containing the specified display and handle
  */
-public static Shell win32_new (Display display, int handle) {
+public static Shell win32_new (Display display, HWND handle) {
     return new Shell (display, null, DWT.NO_TRIM, handle, true);
 }
 
-public static Shell internal_new (Display display, int handle) {
+public static Shell internal_new (Display display, HWND handle) {
     return new Shell (display, null, DWT.NO_TRIM, handle, false);
 }
 
@@ -453,35 +451,35 @@
     addListener (DWT.Deactivate, typedListener);
 }
 
-int balloonTipHandle () {
-    if (balloonTipHandle is 0) createBalloonTipHandle ();
-    return balloonTipHandle;
+HANDLE balloonTipHandle () {
+    if (balloonTipHandle_ is null) createBalloonTipHandle ();
+    return balloonTipHandle_;
 }
 
-int callWindowProc (int hwnd, int msg, int wParam, int lParam) {
-    if (handle is 0) return 0;
-    if (hwnd is toolTipHandle || hwnd is balloonTipHandle) {
-        return OS.CallWindowProc (ToolTipProc, hwnd, msg, wParam, lParam);
+override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) {
+    if (handle is null) return LRESULT.ZERO;
+    if (hwnd is toolTipHandle_ || hwnd is balloonTipHandle_) {
+        return cast(LRESULT) ToolTipProc( hwnd, msg, wParam, lParam);
     }
-    if (hwndMDIClient !is 0) {
-        return OS.DefFrameProc (hwnd, hwndMDIClient, msg, wParam, lParam);
+    if (hwndMDIClient_ !is null) {
+        return cast(LRESULT) OS.DefFrameProc (hwnd, hwndMDIClient_, msg, wParam, lParam);
     }
-    if (windowProc !is 0) {
-        return OS.CallWindowProc (windowProc, hwnd, msg, wParam, lParam);
+    if (windowProc_ !is null) {
+        return cast(LRESULT) windowProc_( hwnd, msg, wParam, lParam);
     }
     if ((style & DWT.TOOL) !is 0) {
         int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX | DWT.BORDER | DWT.RESIZE;
-        if ((style & trim) is 0) return OS.DefWindowProc (hwnd, msg, wParam, lParam);
+        if ((style & trim) is 0) return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam);
     }
     if (parent !is null) {
         switch (msg) {
             case OS.WM_KILLFOCUS:
             case OS.WM_SETFOCUS:
-                return OS.DefWindowProc (hwnd, msg, wParam, lParam);
+                return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam);
         }
-        return OS.CallWindowProc (DialogProc, hwnd, msg, wParam, lParam);
+        return cast(LRESULT) DialogProc( hwnd, msg, wParam, lParam);
     }
-    return OS.DefWindowProc (hwnd, msg, wParam, lParam);
+    return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam);
 }
 
 /**
@@ -505,19 +503,19 @@
 }
 
 void createBalloonTipHandle () {
-    balloonTipHandle = OS.CreateWindowEx (
+    balloonTipHandle_ = OS.CreateWindowEx (
         0,
-        new TCHAR (0, OS.TOOLTIPS_CLASS, true),
+        StrToTCHARz( OS.TOOLTIPS_CLASS ),
         null,
         OS.TTS_ALWAYSTIP | OS.TTS_BALLOON,
         OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0,
         handle,
-        0,
+        null,
         OS.GetModuleHandle (null),
         null);
-    if (balloonTipHandle is 0) error (DWT.ERROR_NO_HANDLES);
-    if (ToolTipProc is 0) {
-        ToolTipProc = OS.GetWindowLong (balloonTipHandle, OS.GWL_WNDPROC);
+    if (balloonTipHandle_ is null) error (DWT.ERROR_NO_HANDLES);
+    if (ToolTipProc is null) {
+        ToolTipProc = cast(TWindowProc) OS.GetWindowLong (balloonTipHandle_, OS.GWL_WNDPROC);
     }
     /*
     * Feature in Windows.  Despite the fact that the
@@ -526,13 +524,13 @@
     * is set.  The fix is to set TTM_SETMAXTIPWIDTH to
     * a large value.
     */
-    OS.SendMessage (balloonTipHandle, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
-    display.addControl (balloonTipHandle, this);
-    OS.SetWindowLong (balloonTipHandle, OS.GWL_WNDPROC, display.windowProc);
+    OS.SendMessage (balloonTipHandle_, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
+    display.addControl (balloonTipHandle_, this);
+    OS.SetWindowLong (balloonTipHandle_, OS.GWL_WNDPROC, display.windowProc);
 }
 
 void createHandle () {
-    bool embedded = handle !is 0 && (state & FOREIGN_HANDLE) is 0;
+    bool embedded = handle !is null && (state & FOREIGN_HANDLE) is 0;
 
     /*
     * On Windows 98 and NT, setting a window to be the
@@ -546,14 +544,14 @@
     * The following code is intentionally commented.
     */
 //  if ((style & DWT.ON_TOP) !is 0) display.lockActiveWindow = true;
-    if (handle is 0 || embedded) {
+    if (handle is null || embedded) {
         super.createHandle ();
     } else {
         state |= CANVAS;
         if ((style & (DWT.H_SCROLL | DWT.V_SCROLL)) is 0) {
             state |= THEME_BACKGROUND;
         }
-        windowProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
+        windowProc_ = cast(TWindowProc) OS.GetWindowLong (handle, OS.GWL_WNDPROC);
     }
 
     /*
@@ -578,16 +576,16 @@
         */
         OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
         int flags = OS.SWP_DRAWFRAME | OS.SWP_NOMOVE | OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE;
-        SetWindowPos (handle, 0, 0, 0, 0, 0, flags);
-        if (OS.IsWinCE) _setMaximized (true);
-        if (OS.IsPPC) {
+        SetWindowPos (handle, null, 0, 0, 0, 0, flags);
+        static if (OS.IsWinCE) _setMaximized (true);
+        static if (OS.IsPPC_) {
             psai = new SHACTIVATEINFO ();
             psai.cbSize = SHACTIVATEINFO.sizeof;
         }
     }
     if (OS.IsDBLocale) {
         hIMC = OS.ImmCreateContext ();
-        if (hIMC !is 0) OS.ImmAssociateContext (handle, hIMC);
+        if (hIMC !is null) OS.ImmAssociateContext (handle, hIMC);
     }
 }
 
@@ -603,29 +601,29 @@
     toolTips [id] = toolTip;
     toolTip.id = id + Display.ID_START;
     if (OS.IsWinCE) return;
-    TOOLINFO lpti = new TOOLINFO ();
+    TOOLINFO lpti;
     lpti.cbSize = TOOLINFO.sizeof;
     lpti.hwnd = handle;
     lpti.uId = toolTip.id;
     lpti.uFlags = OS.TTF_TRACK;
     lpti.lpszText = OS.LPSTR_TEXTCALLBACK;
-    OS.SendMessage (toolTip.hwndToolTip (), OS.TTM_ADDTOOL, 0, lpti);
+    OS.SendMessage (toolTip.hwndToolTip (), OS.TTM_ADDTOOL, 0, &lpti);
 }
 
 void createToolTipHandle () {
-    toolTipHandle = OS.CreateWindowEx (
+    toolTipHandle_ = OS.CreateWindowEx (
         0,
-        new TCHAR (0, OS.TOOLTIPS_CLASS, true),
+        StrToTCHARz( OS.TOOLTIPS_CLASS ),
         null,
         OS.TTS_ALWAYSTIP,
         OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0,
         handle,
-        0,
+        null,
         OS.GetModuleHandle (null),
         null);
-    if (toolTipHandle is 0) error (DWT.ERROR_NO_HANDLES);
-    if (ToolTipProc is 0) {
-        ToolTipProc = OS.GetWindowLong (toolTipHandle, OS.GWL_WNDPROC);
+    if (toolTipHandle_ is null) error (DWT.ERROR_NO_HANDLES);
+    if (ToolTipProc is null) {
+        ToolTipProc = cast(TWindowProc) OS.GetWindowLong (toolTipHandle_, OS.GWL_WNDPROC);
     }
     /*
     * Feature in Windows.  Despite the fact that the
@@ -634,27 +632,27 @@
     * is set.  The fix is to set TTM_SETMAXTIPWIDTH to
     * a large value.
     */
-    OS.SendMessage (toolTipHandle, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
-    display.addControl (toolTipHandle, this);
-    OS.SetWindowLong (toolTipHandle, OS.GWL_WNDPROC, display.windowProc);
+    OS.SendMessage (toolTipHandle_, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
+    display.addControl (toolTipHandle_, this);
+    OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, display.windowProc);
 }
 
 void deregister () {
     super.deregister ();
-    if (toolTipHandle !is 0) display.removeControl (toolTipHandle);
-    if (balloonTipHandle !is 0) display.removeControl (balloonTipHandle);
+    if (toolTipHandle_ !is null) display.removeControl (toolTipHandle_);
+    if (balloonTipHandle_ !is null) display.removeControl (balloonTipHandle_);
 }
 
 void destroyToolTip (ToolTip toolTip) {
     if (toolTips is null) return;
     toolTips [toolTip.id - Display.ID_START] = null;
     if (OS.IsWinCE) return;
-    if (balloonTipHandle !is 0) {
-        TOOLINFO lpti = new TOOLINFO ();
+    if (balloonTipHandle_ !is null) {
+        TOOLINFO lpti;
         lpti.cbSize = TOOLINFO.sizeof;
         lpti.uId = toolTip.id;
         lpti.hwnd = handle;
-        OS.SendMessage (balloonTipHandle, OS.TTM_DELTOOL, 0, lpti);
+        OS.SendMessage (balloonTipHandle_, OS.TTM_DELTOOL, 0, &lpti);
     }
     toolTip.id = -1;
 }
@@ -696,7 +694,7 @@
     }
 }
 
-int findBrush (int value, int lbStyle) {
+HBRUSH findBrush (int value, int lbStyle) {
     if (lbStyle is OS.BS_SOLID) {
         for (int i=0; i<SYSTEM_COLORS.length; i++) {
             if (value is OS.GetSysColor (SYSTEM_COLORS [i])) {
@@ -704,12 +702,12 @@
             }
         }
     }
-    if (brushes is null) brushes = new int [BRUSHES_SIZE];
-    LOGBRUSH logBrush = new LOGBRUSH ();
+    if (brushes is null) brushes = new HBRUSH [BRUSHES_SIZE];
+    LOGBRUSH logBrush;
     for (int i=0; i<brushes.length; i++) {
-        int hBrush = brushes [i];
-        if (hBrush is 0) break;
-        OS.GetObject (hBrush, LOGBRUSH.sizeof, logBrush);
+        HBRUSH hBrush = brushes [i];
+        if (hBrush is null) break;
+        OS.GetObject (hBrush, LOGBRUSH.sizeof, &logBrush);
         switch (logBrush.lbStyle) {
             case OS.BS_SOLID:
                 if (lbStyle is OS.BS_SOLID) {
@@ -723,16 +721,16 @@
                 break;
         }
     }
-    int length = brushes.length;
-    int hBrush = brushes [--length];
-    if (hBrush !is 0) OS.DeleteObject (hBrush);
-    System.arraycopy (brushes, 0, brushes, 1, length);
+    int length_ = brushes.length;
+    HBRUSH hBrush = brushes [--length_];
+    if (hBrush !is null) OS.DeleteObject (hBrush);
+    System.arraycopy (brushes, 0, brushes, 1, length_);
     switch (lbStyle) {
         case OS.BS_SOLID:
             hBrush = OS.CreateSolidBrush (value);
             break;
         case OS.BS_PATTERN:
-            hBrush = OS.CreatePatternBrush (value);
+            hBrush = OS.CreatePatternBrush ( cast(HBITMAP) value);
             break;
     }
     return brushes [0] = hBrush;
@@ -766,8 +764,8 @@
     * application).  The fix is to activate the disabled parent
     * shell before disposing or hiding the active shell.
     */
-    int hwndParent = OS.GetParent (handle);
-    if (hwndParent !is 0 && handle is OS.GetActiveWindow ()) {
+    auto hwndParent = OS.GetParent (handle);
+    if (hwndParent !is null && handle is OS.GetActiveWindow ()) {
         if (!OS.IsWindowEnabled (hwndParent) && OS.IsWindowVisible (hwndParent)) {
             OS.SetActiveWindow (hwndParent);
         }
@@ -777,7 +775,7 @@
 void fixShell (Shell newShell, Control control) {
     if (this is newShell) return;
     if (control is lastActive) setActiveControl (null);
-    String toolTipText = control.toolTipText;
+    char[] toolTipText = control.toolTipText_;
     if (toolTipText !is null) {
         control.setToolTipText (this, null);
         control.setToolTipText (newShell, toolTipText);
@@ -797,13 +795,13 @@
     * the mouse leaves the control.
     */
     if (OS.COMCTL32_MAJOR >= 6) {
-        if (toolTipHandle is 0) return;
-        TOOLINFO lpti = new TOOLINFO ();
+        if (toolTipHandle_ is null) return;
+        TOOLINFO lpti;
         lpti.cbSize = TOOLINFO.sizeof;
-        if (OS.SendMessage (toolTipHandle, OS.TTM_GETCURRENTTOOL, 0, lpti) !is 0) {
+        if (OS.SendMessage (toolTipHandle_, OS.TTM_GETCURRENTTOOL, 0, &lpti) !is 0) {
             if ((lpti.uFlags & OS.TTF_IDISHWND) !is 0) {
-                OS.SendMessage (toolTipHandle, OS.TTM_DELTOOL, 0, lpti);
-                OS.SendMessage (toolTipHandle, OS.TTM_ADDTOOL, 0, lpti);
+                OS.SendMessage (toolTipHandle_, OS.TTM_DELTOOL, 0, &lpti);
+                OS.SendMessage (toolTipHandle_, OS.TTM_ADDTOOL, 0, &lpti);
             }
         }
     }
@@ -845,31 +843,31 @@
     if (!OS.IsWinCE) {
         if (OS.IsIconic (handle)) return super.getBounds ();
     }
-    RECT rect = new RECT ();
-    OS.GetWindowRect (handle, rect);
+    RECT rect;
+    OS.GetWindowRect (handle, &rect);
     int width = rect.right - rect.left;
     int height = rect.bottom - rect.top;
     return new Rectangle (rect.left, rect.top, width, height);
 }
 
 ToolTip getCurrentToolTip () {
-    if (toolTipHandle !is 0) {
-        ToolTip tip = getCurrentToolTip (toolTipHandle);
+    if (toolTipHandle_ !is null) {
+        ToolTip tip = getCurrentToolTip (toolTipHandle_);
         if (tip !is null) return tip;
     }
-    if (balloonTipHandle !is 0) {
-        ToolTip tip = getCurrentToolTip (balloonTipHandle);
+    if (balloonTipHandle_ !is null) {
+        ToolTip tip = getCurrentToolTip (balloonTipHandle_);
         if (tip !is null) return tip;
     }
     return null;
 }
 
-ToolTip getCurrentToolTip (int hwndToolTip) {
-    if (hwndToolTip is 0) return null;
+ToolTip getCurrentToolTip (HWND hwndToolTip) {
+    if (hwndToolTip is null) return null;
     if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, 0) !is 0) {
-        TOOLINFO lpti = new TOOLINFO ();
+        TOOLINFO lpti;
         lpti.cbSize = TOOLINFO.sizeof;
-        if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, lpti) !is 0) {
+        if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, &lpti) !is 0) {
             if ((lpti.uFlags & OS.TTF_IDISHWND) is 0) return findToolTip (lpti.uId);
         }
     }
@@ -901,29 +899,29 @@
 public int getImeInputMode () {
     checkWidget ();
     if (!OS.IsDBLocale) return 0;
-    int hIMC = OS.ImmGetContext (handle);
-    int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1];
-    bool open = OS.ImmGetOpenStatus (hIMC);
-    if (open) open = OS.ImmGetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence);
+    auto hIMC = OS.ImmGetContext (handle);
+    uint lpfdwConversion, lpfdwSentence;
+    bool open = cast(bool) OS.ImmGetOpenStatus (hIMC);
+    if (open) open = cast(bool) OS.ImmGetConversionStatus (hIMC, &lpfdwConversion, &lpfdwSentence);
     OS.ImmReleaseContext (handle, hIMC);
     if (!open) return DWT.NONE;
     int result = 0;
-    if ((lpfdwConversion [0] & OS.IME_CMODE_ROMAN) !is 0) result |= DWT.ROMAN;
-    if ((lpfdwConversion [0] & OS.IME_CMODE_FULLSHAPE) !is 0) result |= DWT.DBCS;
-    if ((lpfdwConversion [0] & OS.IME_CMODE_KATAKANA) !is 0) return result | DWT.PHONETIC;
-    if ((lpfdwConversion [0] & OS.IME_CMODE_NATIVE) !is 0) return result | DWT.NATIVE;
+    if ((lpfdwConversion & OS.IME_CMODE_ROMAN) !is 0) result |= DWT.ROMAN;
+    if ((lpfdwConversion & OS.IME_CMODE_FULLSHAPE) !is 0) result |= DWT.DBCS;
+    if ((lpfdwConversion & OS.IME_CMODE_KATAKANA) !is 0) return result | DWT.PHONETIC;
+    if ((lpfdwConversion & OS.IME_CMODE_NATIVE) !is 0) return result | DWT.NATIVE;
     return result | DWT.ALPHA;
 }
 
 public Point getLocation () {
     checkWidget ();
-    if (!OS.IsWinCE) {
+    static if (!OS.IsWinCE) {
         if (OS.IsIconic (handle)) {
             return super.getLocation ();
         }
     }
-    RECT rect = new RECT ();
-    OS.GetWindowRect (handle, rect);
+    RECT rect;
+    OS.GetWindowRect (handle, &rect);
     return new Point (rect.left, rect.top);
 }
 
@@ -954,10 +952,10 @@
         if ((style & DWT.RESIZE) !is 0) {
             height = Math.max (height, OS.GetSystemMetrics (OS.SM_CYMINTRACK));
         } else {
-            RECT rect = new RECT ();
+            RECT rect;
             int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
             int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
-            OS.AdjustWindowRectEx (rect, bits1, false, bits2);
+            OS.AdjustWindowRectEx (&rect, bits1, false, bits2);
             height = Math.max (height, rect.bottom - rect.top);
         }
     }
@@ -993,8 +991,8 @@
     if (!OS.IsWinCE) {
         if (OS.IsIconic (handle)) return super.getSize ();
     }
-    RECT rect = new RECT ();
-    OS.GetWindowRect (handle, rect);
+    RECT rect;
+    OS.GetWindowRect (handle, &rect);
     int width = rect.right - rect.left;
     int height = rect.bottom - rect.top;
     return new Point (width, height);
@@ -1050,22 +1048,22 @@
     return getVisible ();
 }
 
-int hwndMDIClient () {
-    if (hwndMDIClient is 0) {
+HWND hwndMDIClient () {
+    if (hwndMDIClient_ is null) {
         int widgetStyle = OS.MDIS_ALLCHILDSTYLES | OS.WS_CHILD | OS.WS_CLIPCHILDREN | OS.WS_CLIPSIBLINGS;
-        hwndMDIClient = OS.CreateWindowEx (
+        hwndMDIClient_ = OS.CreateWindowEx (
             0,
-            new TCHAR (0, "MDICLIENT", true),
+            StrToTCHARz("MDICLIENT"),
             null,
             widgetStyle,
             0, 0, 0, 0,
             handle,
-            0,
+            null,
             OS.GetModuleHandle (null),
             new CREATESTRUCT ());
-//      OS.ShowWindow (hwndMDIClient, OS.SW_SHOW);
+//      OS.ShowWindow (hwndMDIClient_, OS.SW_SHOW);
     }
-    return hwndMDIClient;
+    return hwndMDIClient_;
 }
 
 /**
@@ -1091,7 +1089,7 @@
  */
 public void open () {
     checkWidget ();
-    STARTUPINFO lpStartUpInfo = Display.lpStartupInfo;
+    STARTUPINFO* lpStartUpInfo = Display.lpStartupInfo;
     if (lpStartUpInfo is null || (lpStartUpInfo.dwFlags & OS.STARTF_USESHOWWINDOW) is 0) {
         bringToTop ();
         if (isDisposed ()) return;
@@ -1121,22 +1119,22 @@
     * NOTE: This allows other cross thread messages to be delivered,
     * most notably WM_ACTIVATE.
     */
-    MSG msg = new MSG ();
+    MSG msg;
     int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_SENDMESSAGE;
-    OS.PeekMessage (msg, 0, 0, 0, flags);
+    OS.PeekMessage (&msg, null, 0, 0, flags);
     if (!restoreFocus () && !traverseGroup (true)) setFocus ();
 }
 
 void register () {
     super.register ();
-    if (toolTipHandle !is 0) display.addControl (toolTipHandle, this);
-    if (balloonTipHandle !is 0) display.addControl (balloonTipHandle, this);
+    if (toolTipHandle_ !is null) display.addControl (toolTipHandle_, this);
+    if (balloonTipHandle_ !is null) display.addControl (balloonTipHandle_, this);
 }
 
 void releaseBrushes () {
     if (brushes !is null) {
         for (int i=0; i<brushes.length; i++) {
-            if (brushes [i] !is 0) OS.DeleteObject (brushes [i]);
+            if (brushes [i] !is null) OS.DeleteObject (brushes [i]);
         }
     }
     brushes = null;
@@ -1164,7 +1162,7 @@
 
 void releaseHandle () {
     super.releaseHandle ();
-    hwndMDIClient = 0;
+    hwndMDIClient_ = null;
 }
 
 void releaseParent () {
@@ -1176,14 +1174,14 @@
     releaseBrushes ();
     activeMenu = null;
     display.clearModal (this);
-    if (lpstrTip !is 0) {
-        int hHeap = OS.GetProcessHeap ();
+    if (lpstrTip !is null) {
+        auto hHeap = OS.GetProcessHeap ();
         OS.HeapFree (hHeap, 0, lpstrTip);
     }
-    lpstrTip = 0;
-    toolTipHandle = balloonTipHandle = 0;
+    lpstrTip = null;
+    toolTipHandle_ = balloonTipHandle_ = null;
     if (OS.IsDBLocale) {
-        if (hIMC !is 0) OS.ImmDestroyContext (hIMC);
+        if (hIMC !is null) OS.ImmDestroyContext (hIMC);
     }
     lastActive = null;
     region = null;
@@ -1224,9 +1222,9 @@
     eventTable.unhook (DWT.Deactivate, listener);
 }
 
-LRESULT selectPalette (int hPalette) {
-    int hDC = OS.GetDC (handle);
-    int hOld = OS.SelectPalette (hDC, hPalette, false);
+LRESULT selectPalette (HPALETTE hPalette) {
+    auto hDC = OS.GetDC (handle);
+    auto hOld = OS.SelectPalette (hDC, hPalette, false);
     int result = OS.RealizePalette (hDC);
     if (result > 0) {
         OS.InvalidateRect (handle, null, true);
@@ -1336,11 +1334,11 @@
     checkWidget ();
     if (!OS.IsDBLocale) return;
     bool imeOn = mode !is DWT.NONE && mode !is DWT.ROMAN;
-    int hIMC = OS.ImmGetContext (handle);
+    auto hIMC = OS.ImmGetContext (handle);
     OS.ImmSetOpenStatus (hIMC, imeOn);
     if (imeOn) {
-        int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1];
-        if (OS.ImmGetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence)) {
+        uint lpfdwConversion, lpfdwSentence;
+        if (OS.ImmGetConversionStatus (hIMC, &lpfdwConversion, &lpfdwSentence)) {
             int newBits = 0;
             int oldBits = OS.IME_CMODE_NATIVE | OS.IME_CMODE_KATAKANA;
             if ((mode & DWT.PHONETIC) !is 0) {
@@ -1362,8 +1360,8 @@
             } else {
                 oldBits |= OS.IME_CMODE_ROMAN;
             }
-            lpfdwConversion [0] |= newBits;  lpfdwConversion [0] &= ~oldBits;
-            OS.ImmSetConversionStatus (hIMC, lpfdwConversion [0], lpfdwSentence [0]);
+            lpfdwConversion |= newBits;  lpfdwConversion &= ~oldBits;
+            OS.ImmSetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence);
         }
     }
     OS.ImmReleaseContext (handle, hIMC);
@@ -1393,10 +1391,10 @@
         if ((style & DWT.RESIZE) !is 0) {
             heightLimit = OS.GetSystemMetrics (OS.SM_CYMINTRACK);
         } else {
-            RECT rect = new RECT ();
+            RECT rect;
             int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
             int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
-            OS.AdjustWindowRectEx (rect, bits1, false, bits2);
+            OS.AdjustWindowRectEx (&rect, bits1, false, bits2);
             heightLimit = rect.bottom - rect.top;
         }
     }
@@ -1434,8 +1432,8 @@
 }
 
 void setItemEnabled (int cmd, bool enabled) {
-    int hMenu = OS.GetSystemMenu (handle, false);
-    if (hMenu is 0) return;
+    auto hMenu = OS.GetSystemMenu (handle, false);
+    if (hMenu is null) return;
     int flags = OS.MF_ENABLED;
     if (!enabled) flags = OS.MF_DISABLED | OS.MF_GRAYED;
     OS.EnableMenuItem (hMenu, cmd, OS.MF_BYCOMMAND | flags);
@@ -1469,7 +1467,7 @@
     checkWidget ();
     if ((style & DWT.NO_TRIM) is 0) return;
     if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
-    int hRegion = 0;
+    HRGN hRegion;
     if (region !is null) {
         hRegion = OS.CreateRectRgn (0, 0, 0, 0);
         OS.CombineRgn (hRegion, region.handle, hRegion, OS.RGN_OR);
@@ -1478,27 +1476,27 @@
     this.region = region;
 }
 
-void setToolTipText (int hwnd, String text) {
+void setToolTipText (HWND hwnd, char[] text) {
     if (OS.IsWinCE) return;
-    TOOLINFO lpti = new TOOLINFO ();
+    TOOLINFO lpti;
     lpti.cbSize = TOOLINFO.sizeof;
     lpti.hwnd = handle;
-    lpti.uId = hwnd;
-    int hwndToolTip = toolTipHandle ();
+    lpti.uId = cast(uint) hwnd;
+    auto hwndToolTip = toolTipHandle ();
     if (text is null) {
-        OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, lpti);
+        OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, cast(int)&lpti);
     } else {
-        if (OS.SendMessage (hwndToolTip, OS.TTM_GETTOOLINFO, 0, lpti) !is 0) {
+        if (OS.SendMessage (hwndToolTip, OS.TTM_GETTOOLINFO, 0, cast(int)&lpti) !is 0) {
             OS.SendMessage (hwndToolTip, OS.TTM_UPDATE, 0, 0);
         } else {
             lpti.uFlags = OS.TTF_IDISHWND | OS.TTF_SUBCLASS;
             lpti.lpszText = OS.LPSTR_TEXTCALLBACK;
-            OS.SendMessage (hwndToolTip, OS.TTM_ADDTOOL, 0, lpti);
+            OS.SendMessage (hwndToolTip, OS.TTM_ADDTOOL, 0, cast(int)&lpti);
         }
     }
 }
 
-void setToolTipText (NMTTDISPINFO lpnmtdi, byte [] buffer) {
+void setToolTipText (NMTTDISPINFO* lpnmtdi, byte [] buffer) {
     /*
     * Ensure that the current position of the mouse
     * is inside the client area of the shell.  This
@@ -1506,11 +1504,12 @@
     * shell trimmings.
     */
     if (!hasCursor ()) return;
-    int hHeap = OS.GetProcessHeap ();
-    if (lpstrTip !is 0) OS.HeapFree (hHeap, 0, lpstrTip);
+    auto hHeap = OS.GetProcessHeap ();
+    if (lpstrTip !is null) OS.HeapFree (hHeap, 0, lpstrTip);
     int byteCount = buffer.length;
-    lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-    OS.MoveMemory (lpstrTip, buffer, byteCount);
+    lpstrTip = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+    (cast(byte*)lpstrTip)[ 0 .. byteCount ] = buffer;
+    //OS.MoveMemory (lpstrTip, buffer, byteCount);
     lpnmtdi.lpszText = lpstrTip;
 }
 
@@ -1522,15 +1521,16 @@
     * shell trimmings.
     */
     if (!hasCursor ()) return;
-    int hHeap = OS.GetProcessHeap ();
-    if (lpstrTip !is 0) OS.HeapFree (hHeap, 0, lpstrTip);
+    auto hHeap = OS.GetProcessHeap ();
+    if (lpstrTip !is null) OS.HeapFree (hHeap, 0, lpstrTip);
     int byteCount = buffer.length * 2;
-    lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-    OS.MoveMemory (lpstrTip, buffer, byteCount);
+    lpstrTip = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+    (cast(char*)lpstrTip)[ 0 .. byteCount ] = buffer;
+    //OS.MoveMemory (lpstrTip, buffer, byteCount);
     lpnmtdi.lpszText = lpstrTip;
 }
 
-void setToolTipTitle (int hwndToolTip, String text, int icon) {
+void setToolTipTitle (HWND hwndToolTip, char[] text, HICON icon) {
     /*
     * Bug in Windows.  For some reason, when TTM_SETTITLE
     * is used to set the title of a tool tip, Windows leaks
@@ -1547,18 +1547,18 @@
     *
     * NOTE:  This only happens on Vista.
     */
-    if (hwndToolTip !is toolTipHandle && hwndToolTip !is balloonTipHandle) {
+    if (hwndToolTip !is toolTipHandle_ && hwndToolTip !is balloonTipHandle_) {
         return;
     }
-    if (hwndToolTip is toolTipHandle) {
-        if (text is toolTitle || (toolTitle !is null && toolTitle.equals (text))) {
+    if (hwndToolTip is toolTipHandle_) {
+        if (text is toolTitle || (toolTitle !is null && toolTitle ==/*eq*/text )) {
             if (icon is toolIcon) return;
         }
         toolTitle = text;
         toolIcon = icon;
     } else {
-        if (hwndToolTip is balloonTipHandle) {
-            if (text is balloonTitle || (balloonTitle !is null && balloonTitle.equals (text))) {
+        if (hwndToolTip is balloonTipHandle_) {
+            if (text is balloonTitle || (balloonTitle !is null && balloonTitle==/*eq*/text)) {
                 if (icon is toolIcon) return;
             }
             balloonTitle = text;
@@ -1566,8 +1566,13 @@
         }
     }
     if (text !is null) {
-        TCHAR pszTitle = new TCHAR (getCodePage (), text, true);
-        OS.SendMessage (hwndToolTip, OS.TTM_SETTITLE, icon, pszTitle);
+        static if( OS.IsUnicode ){
+            TCHAR* pszTitle = StrToTCHARz( text);
+        }
+        else {
+            TCHAR* pszTitle = StrToTCHARz( text, getCodePage ());
+        }
+        OS.SendMessage (hwndToolTip, OS.TTM_SETTITLE, icon, cast(int)pszTitle);
     } else {
         OS.SendMessage (hwndToolTip, OS.TTM_SETTITLE, 0, 0);
     }
@@ -1599,11 +1604,11 @@
                 bringToTop ();
                 if (isDisposed ()) return;
             }
-            int hwndShell = OS.GetActiveWindow ();
-            if (hwndShell is 0) {
+            auto hwndShell = OS.GetActiveWindow ();
+            if (hwndShell is null) {
                 if (parent !is null) hwndShell = parent.handle;
             }
-            if (hwndShell !is 0) {
+            if (hwndShell !is null) {
                 OS.SendMessage (hwndShell, OS.WM_CANCELMODE, 0, 0);
             }
             OS.ReleaseCapture ();
@@ -1635,23 +1640,23 @@
 
 void subclass () {
     super.subclass ();
-    if (ToolTipProc !is 0) {
+    if (ToolTipProc !is null) {
         int newProc = display.windowProc;
-        if (toolTipHandle !is 0) {
-            OS.SetWindowLong (toolTipHandle, OS.GWL_WNDPROC, newProc);
+        if (toolTipHandle_ !is null) {
+            OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, newProc);
         }
-        if (balloonTipHandle !is 0) {
-            OS.SetWindowLong (balloonTipHandle, OS.GWL_WNDPROC, newProc);
+        if (balloonTipHandle_ !is null) {
+            OS.SetWindowLong (balloonTipHandle_, OS.GWL_WNDPROC, newProc);
         }
     }
 }
 
-int toolTipHandle () {
-    if (toolTipHandle is 0) createToolTipHandle ();
-    return toolTipHandle;
+HANDLE toolTipHandle () {
+    if (toolTipHandle_ is null) createToolTipHandle ();
+    return toolTipHandle_;
 }
 
-bool translateAccelerator (MSG msg) {
+bool translateAccelerator (MSG* msg) {
     if (!isEnabled () || !isActive ()) return false;
     if (menuBar !is null && !menuBar.isEnabled ()) return false;
     return translateMDIAccelerator (msg) || translateMenuAccelerator (msg);
@@ -1666,12 +1671,12 @@
 
 void unsubclass () {
     super.unsubclass ();
-    if (ToolTipProc !is 0) {
-        if (toolTipHandle !is 0) {
-            OS.SetWindowLong (toolTipHandle, OS.GWL_WNDPROC, ToolTipProc);
+    if (ToolTipProc !is null) {
+        if (toolTipHandle_ !is null) {
+            OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, cast(int)ToolTipProc);
         }
-        if (toolTipHandle !is 0) {
-            OS.SetWindowLong (toolTipHandle, OS.GWL_WNDPROC, ToolTipProc);
+        if (toolTipHandle_ !is null) {
+            OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, cast(int)ToolTipProc);
         }
     }
 }
@@ -1684,13 +1689,13 @@
     }
 }
 
-CREATESTRUCT widgetCreateStruct () {
+CREATESTRUCT* widgetCreateStruct () {
     return null;
 }
 
-int widgetParent () {
-    if (handle !is 0) return handle;
-    return parent !is null ? parent.handle : 0;
+HWND widgetParent () {
+    if (handle !is null) return handle;
+    return parent !is null ? parent.handle : null;
 }
 
 int widgetExtStyle () {
@@ -1736,28 +1741,28 @@
     return bits;
 }
 
-TCHAR windowClass () {
-    if (OS.IsSP) return DialogClass;
+char[] windowClass () {
+    static if (OS.IsSP_) return DialogClass;
     if ((style & DWT.TOOL) !is 0) {
         int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX | DWT.BORDER | DWT.RESIZE;
-        if ((style & trim) is 0) return display.windowShadowClass;
+        if ((style & trim) is 0) return TCHARzToStr( display.windowShadowClass );
     }
-    return parent !is null ? DialogClass : super.windowClass ();
+    return parent !is null ? TCHARzToStr(DialogClass.ptr) : super.windowClass ();
 }
 
-int windowProc () {
-    if (windowProc !is 0) return windowProc;
-    if (OS.IsSP) return DialogProc;
+override int windowProc () {
+    if (windowProc_ !is null) return cast(int) windowProc_;
+    static if (OS.IsSP_) return cast(int) DialogProc;
     if ((style & DWT.TOOL) !is 0) {
         int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX | DWT.BORDER | DWT.RESIZE;
         if ((style & trim) is 0) super.windowProc ();
     }
-    return parent !is null ? DialogProc : super.windowProc ();
+    return parent !is null ? cast(int) DialogProc : super.windowProc ();
 }
 
-int windowProc (int hwnd, int msg, int wParam, int lParam) {
-    if (handle is 0) return 0;
-    if (hwnd is toolTipHandle || hwnd is balloonTipHandle) {
+override int windowProc (HWND hwnd, int msg, int wParam, int lParam) {
+    if (handle is null) return 0;
+    if (hwnd is toolTipHandle_ || hwnd is balloonTipHandle_) {
         switch (msg) {
             case OS.WM_TIMER: {
                 if (wParam !is ToolTip.TIMER_ID) break;
@@ -1783,7 +1788,7 @@
 
 int widgetStyle () {
     int bits = super.widgetStyle ();
-    if (handle !is 0) return bits | OS.WS_CHILD;
+    if (handle !is null) return bits | OS.WS_CHILD;
     bits &= ~OS.WS_CHILD;
     /*
     * Feature in WinCE.  Calling CreateWindowEx () with WS_OVERLAPPED
@@ -1799,7 +1804,7 @@
     * NOTE: WS_POPUP causes CreateWindowEx () to ignore CW_USEDEFAULT
     * and causes the default window location and size to be zero.
     */
-    if (OS.IsWinCE) {
+    static if (OS.IsWinCE) {
         if (OS.IsSP) return bits | OS.WS_POPUP;
         return parent is null ? bits : bits | OS.WS_POPUP;
     }
@@ -1821,7 +1826,7 @@
 }
 
 LRESULT WM_ACTIVATE (int wParam, int lParam) {
-    if (OS.IsPPC) {
+    static if (OS.IsPPC_) {
         /*
         * Note: this does not work when we get WM_ACTIVATE prior
         * to adding a listener.
@@ -1830,7 +1835,7 @@
             int fActive = wParam & 0xFFFF;
             int hwnd = fActive !is 0 ? handle : 0;
             for (int bVk=OS.VK_APP1; bVk<=OS.VK_APP6; bVk++) {
-                OS.SHSetAppKeyWndAssoc ((byte) bVk, hwnd);
+                OS.SHSetAppKeyWndAssoc (cast(byte) bVk, hwnd);
             }
         }
         /* Restore SIP state when window is activated */
@@ -1849,7 +1854,7 @@
     * the input method status.
     */
     if (OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
-        if ((wParam & 0xFFFF) is 0 && OS.IsDBLocale && hIMC !is 0) {
+        if ((wParam & 0xFFFF) is 0 && OS.IsDBLocale && hIMC !is null) {
             if (OS.ImmGetOpenStatus(hIMC)) {
                 OS.ImmSetOpenStatus (hIMC, false);
                 OS.ImmSetOpenStatus (hIMC, true);
@@ -1860,7 +1865,7 @@
     /* Process WM_ACTIVATE */
     LRESULT result = super.WM_ACTIVATE (wParam, lParam);
     if ((wParam & 0xFFFF) is 0) {
-        if (lParam is 0 || (lParam !is toolTipHandle && lParam !is balloonTipHandle)) {
+        if (lParam is 0 || (cast(HANDLE)lParam !is toolTipHandle_ && cast(HANDLE)lParam !is balloonTipHandle_)) {
             ToolTip tip = getCurrentToolTip ();
             if (tip !is null) tip.setVisible (false);
         }
@@ -1869,7 +1874,7 @@
 }
 
 LRESULT WM_COMMAND (int wParam, int lParam) {
-    if (OS.IsPPC) {
+    static if (OS.IsPPC_) {
         /*
         * Note in WinCE PPC:  Close the Shell when the "Done Button" has
         * been pressed. lParam is either 0 (PocketPC 2002) or the handle
@@ -1891,10 +1896,10 @@
     * of the WM_COMMAND and set lParam to zero to pretend that the message
     * came from a real Windows menu, not a tool bar.
     */
-    if (OS.IsPPC || OS.IsSP) {
+    static if (OS.IsPPC_ || OS.IsSP_) {
         if (menuBar !is null) {
-            int hwndCB = menuBar.hwndCB;
-            if (lParam !is 0 && hwndCB !is 0) {
+            auto hwndCB = menuBar.hwndCB;
+            if (lParam !is 0 && hwndCB !is null) {
                 if (lParam is hwndCB) {
                     return super.WM_COMMAND (wParam, 0);
                 } else {
@@ -1925,7 +1930,7 @@
 
 LRESULT WM_ERASEBKGND (int wParam, int lParam) {
     LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     /*
     * Feature in Windows.  When a shell is resized by dragging
     * the resize handles, Windows temporarily fills in black
@@ -1935,7 +1940,7 @@
     * NOTE: This only happens on Vista.
     */
     if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
-        drawBackground (wParam);
+        drawBackground (cast(HDC)wParam);
         return LRESULT.ONE;
     }
     return result;
@@ -1943,7 +1948,7 @@
 
 LRESULT WM_ENTERIDLE (int wParam, int lParam) {
     LRESULT result = super.WM_ENTERIDLE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     if (OS.IsWinCE && display.runMessages) {
         if (display.runAsyncMessages (true)) display.wakeThread ();
     }
@@ -1952,13 +1957,13 @@
 
 LRESULT WM_GETMINMAXINFO (int wParam, int lParam) {
     LRESULT result = super.WM_GETMINMAXINFO (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     if (minWidth !is DWT.DEFAULT || minHeight !is DWT.DEFAULT) {
-        MINMAXINFO info = new MINMAXINFO ();
-        OS.MoveMemory (info, lParam, MINMAXINFO.sizeof);
-        if (minWidth !is DWT.DEFAULT) info.ptMinTrackSize_x = minWidth;
-        if (minHeight !is DWT.DEFAULT) info.ptMinTrackSize_y = minHeight;
-        OS.MoveMemory (lParam, info, MINMAXINFO.sizeof);
+        MINMAXINFO* info = cast(MINMAXINFO*)lParam;
+        //OS.MoveMemory (info, lParam, MINMAXINFO.sizeof);
+        if (minWidth !is DWT.DEFAULT) info.ptMinTrackSize.x = minWidth;
+        if (minHeight !is DWT.DEFAULT) info.ptMinTrackSize.y = minHeight;
+        //OS.MoveMemory (lParam, info, MINMAXINFO.sizeof);
         return LRESULT.ZERO;
     }
     return result;
@@ -1966,14 +1971,14 @@
 
 LRESULT WM_MOUSEACTIVATE (int wParam, int lParam) {
     LRESULT result = super.WM_MOUSEACTIVATE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
 
     /*
     * Check for WM_MOUSEACTIVATE when an MDI shell is active
     * and stop the normal shell activation but allow the mouse
     * down to be delivered.
     */
-    int hittest = (short) (lParam & 0xFFFF);
+    int hittest = cast(short) (lParam & 0xFFFF);
     switch (hittest) {
         case OS.HTERROR:
         case OS.HTTRANSPARENT:
@@ -1989,17 +1994,17 @@
                     display.lastHittestControl = null;
                     if (hittest is OS.HTMENU || hittest is OS.HTSYSMENU) {
                         display.lastHittestControl = control;
-                        return null;
+                        return LRESULT.NULL;
                     }
                     if (OS.IsWin95 && hittest is OS.HTCAPTION) {
                         display.lastHittestControl = control;
                     }
-                    return new LRESULT (OS.MA_NOACTIVATE);
+                    return cast( LRESULT )(OS.MA_NOACTIVATE);
                 }
             }
         }
     }
-    if (hittest is OS.HTMENU) return null;
+    if (hittest is OS.HTMENU) return LRESULT.NULL;
 
     /*
     * Get the current location of the cursor,
@@ -2013,14 +2018,14 @@
     * is the one for our event loop, not the
     * embedded widget's event loop.
     */
-    POINT pt = new POINT ();
-    if (!OS.GetCursorPos (pt)) {
+    POINT pt;
+    if (!OS.GetCursorPos (&pt)) {
         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);
     }
-    int hwnd = OS.WindowFromPoint (pt);
-    if (hwnd is 0) return null;
+    auto hwnd = OS.WindowFromPoint (pt);
+    if (hwnd is null) return LRESULT.NULL;
     Control control = display.findControl (hwnd);
 
     /*
@@ -2034,19 +2039,19 @@
             int bits = DWT.ON_TOP | DWT.NO_FOCUS;
             if ((style & bits) is bits) {
                 if (hittest is OS.HTBORDER || hittest is OS.HTCLIENT) {
-                    return new LRESULT (OS.MA_NOACTIVATE);
+                    return cast( LRESULT )(OS.MA_NOACTIVATE);
                 }
             }
         }
     }
 
     setActiveControl (control);
-    return null;
+    return LRESULT.NULL;
 }
 
 LRESULT WM_MOVE (int wParam, int lParam) {
     LRESULT result = super.WM_MOVE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     ToolTip tip = getCurrentToolTip ();
     if (tip !is null) tip.setVisible (false);
     return result;
@@ -2069,24 +2074,24 @@
 }
 
 LRESULT WM_NCHITTEST (int wParam, int lParam) {
-    if (!OS.IsWindowEnabled (handle)) return null;
+    if (!OS.IsWindowEnabled (handle)) return LRESULT.NULL;
     if (!isEnabled () || !isActive ()) {
-        if (!Display.TrimEnabled) return new LRESULT (OS.HTNOWHERE);
+        if (!Display.TrimEnabled) return cast( LRESULT )(OS.HTNOWHERE);
         int hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
         if (hittest is OS.HTCLIENT || hittest is OS.HTMENU) hittest = OS.HTBORDER;
-        return new LRESULT (hittest);
+        return cast( LRESULT )(hittest);
     }
     if (menuBar !is null && !menuBar.getEnabled ()) {
         int hittest = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
         if (hittest is OS.HTMENU) hittest = OS.HTBORDER;
-        return new LRESULT (hittest);
+        return cast( LRESULT )(hittest);
     }
-    return null;
+    return LRESULT.NULL;
 }
 
 LRESULT WM_NCLBUTTONDOWN (int wParam, int lParam) {
     LRESULT result = super.WM_NCLBUTTONDOWN (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     /*
     * When the normal activation was interrupted in WM_MOUSEACTIVATE
     * because the active shell was an MDI shell, set the active window
@@ -2096,7 +2101,7 @@
     */
     if (!display.ignoreRestoreFocus) return result;
     Display display = this.display;
-    int hwndActive = 0;
+    HWND hwndActive;
     bool fixActive = OS.IsWin95 && display.lastHittest is OS.HTCAPTION;
     if (fixActive) hwndActive = OS.SetActiveWindow (handle);
     display.lockActiveWindow = true;
@@ -2109,20 +2114,20 @@
     }
     display.lastHittestControl = null;
     display.ignoreRestoreFocus = false;
-    return new LRESULT (code);
+    return cast( LRESULT )(code);
 }
 
 LRESULT WM_PALETTECHANGED (int wParam, int lParam) {
-    if (wParam !is handle) {
-        int hPalette = display.hPalette;
-        if (hPalette !is 0) return selectPalette (hPalette);
+    if ( cast(HANDLE)wParam !is handle) {
+        auto hPalette = display.hPalette;
+        if (hPalette !is null) return selectPalette (hPalette);
     }
     return super.WM_PALETTECHANGED (wParam, lParam);
 }
 
 LRESULT WM_QUERYNEWPALETTE (int wParam, int lParam) {
-    int hPalette = display.hPalette;
-    if (hPalette !is 0) return selectPalette (hPalette);
+    auto hPalette = display.hPalette;
+    if (hPalette !is null) return selectPalette (hPalette);
     return super.WM_QUERYNEWPALETTE (wParam, lParam);
 }
 
@@ -2135,21 +2140,21 @@
     * fix is to detect this case and bring the shell
     * forward.
     */
-    int msg = (short) (lParam >> 16);
+    int msg = cast(short) (lParam >> 16);
     if (msg is OS.WM_LBUTTONDOWN) {
         if (!Display.TrimEnabled) {
             Shell modalShell = display.getModalShell ();
             if (modalShell !is null && !isActive ()) {
-                int hwndModal = modalShell.handle;
+                auto hwndModal = modalShell.handle;
                 if (OS.IsWindowEnabled (hwndModal)) {
                     OS.SetActiveWindow (hwndModal);
                 }
             }
         }
         if (!OS.IsWindowEnabled (handle)) {
-            if (!OS.IsWinCE) {
-                int hwndPopup = OS.GetLastActivePopup (handle);
-                if (hwndPopup !is 0 && hwndPopup !is handle) {
+            static if (!OS.IsWinCE) {
+                auto hwndPopup = OS.GetLastActivePopup (handle);
+                if (hwndPopup !is null && hwndPopup !is handle) {
                     if (display.getControl (hwndPopup) is null) {
                         if (OS.IsWindowEnabled (hwndPopup)) {
                             OS.SetActiveWindow (hwndPopup);
@@ -2170,19 +2175,19 @@
     * with HTERROR to set the cursor but only when the
     * mouse is in the client area of the shell.
     */
-    int hitTest = (short) (lParam & 0xFFFF);
+    int hitTest = cast(short) (lParam & 0xFFFF);
     if (hitTest is OS.HTERROR) {
         if (!getEnabled ()) {
-            Control control = display.getControl (wParam);
+            Control control = display.getControl (cast(HANDLE)wParam);
             if (control is this && cursor !is null) {
-                POINT pt = new POINT ();
+                POINT pt;
                 int pos = OS.GetMessagePos ();
-                pt.x = (short) (pos & 0xFFFF);
-                pt.y = (short) (pos >> 16);
-                OS.ScreenToClient (handle, pt);
-                RECT rect = new RECT ();
-                OS.GetClientRect (handle, rect);
-                if (OS.PtInRect (rect, pt)) {
+                pt.x = cast(short) (pos & 0xFFFF);
+                pt.y = cast(short) (pos >> 16);
+                OS.ScreenToClient (handle, &pt);
+                RECT rect;
+                OS.GetClientRect (handle, &rect);
+                if (OS.PtInRect (&rect, pt)) {
                     OS.SetCursor (cursor.handle);
                     switch (msg) {
                         case OS.WM_LBUTTONDOWN:
@@ -2201,8 +2206,8 @@
 
 LRESULT WM_SETTINGCHANGE (int wParam, int lParam) {
     LRESULT result = super.WM_SETTINGCHANGE (wParam, lParam);
-    if (result !is null) return result;
-    if (OS.IsPPC) {
+    if (result !is LRESULT.NULL) return result;
+    static if (OS.IsPPC_) {
         if (wParam is OS.SPI_SETSIPINFO) {
             /*
             * The SIP is in a new state.  Cache its new value.
@@ -2214,9 +2219,9 @@
                 OS.SHHandleWMSettingChange (handle, wParam, lParam, psai);
                 return LRESULT.ZERO;
             } else {
-                SIPINFO pSipInfo = new SIPINFO ();
+                SIPINFO pSipInfo;
                 pSipInfo.cbSize = SIPINFO.sizeof;
-                OS.SipGetInfo (pSipInfo);
+                OS.SipGetInfo (&pSipInfo);
                 psai.fSipUp = pSipInfo.fdwFlags & OS.SIPF_ON;
             }
         }
@@ -2226,7 +2231,7 @@
 
 LRESULT WM_SHOWWINDOW (int wParam, int lParam) {
     LRESULT result = super.WM_SHOWWINDOW (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     /*
     * Bug in Windows.  If the shell is hidden while the parent
     * is iconic,  Windows shows the shell when the parent is
@@ -2248,7 +2253,7 @@
 
 LRESULT WM_SYSCOMMAND (int wParam, int lParam) {
     LRESULT result = super.WM_SYSCOMMAND (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     /*
     * Feature in Windows.  When the last visible window in
     * a process minimized, Windows swaps out the memory for
@@ -2270,7 +2275,7 @@
         int cmd = wParam & 0xFFF0;
         switch (cmd) {
             case OS.SC_MINIMIZE:
-                long memory = Runtime.getRuntime ().totalMemory ();
+                long memory = RuntimeTotalMemory ();
                 if (memory >= 32 * 1024 * 1024) {
                     OS.ShowWindow (handle, OS.SW_SHOWMINIMIZED);
                     return LRESULT.ZERO;
@@ -2282,9 +2287,9 @@
 
 LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
     LRESULT result = super.WM_WINDOWPOSCHANGING (wParam,lParam);
-    if (result !is null) return result;
-    WINDOWPOS lpwp = new WINDOWPOS ();
-    OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
+    if (result !is LRESULT.NULL) return result;
+    auto lpwp = cast(WINDOWPOS*)lParam;
+    //OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
     if ((lpwp.flags & OS.SWP_NOSIZE) is 0) {
         lpwp.cx = Math.max (lpwp.cx, minWidth);
         int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX;
@@ -2296,16 +2301,16 @@
             if ((style & DWT.RESIZE) !is 0) {
                 lpwp.cy = Math.max (lpwp.cy, OS.GetSystemMetrics (OS.SM_CYMINTRACK));
             } else {
-                RECT rect = new RECT ();
+                RECT rect;
                 int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
                 int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
-                OS.AdjustWindowRectEx (rect, bits1, false, bits2);
+                OS.AdjustWindowRectEx (&rect, bits1, false, bits2);
                 lpwp.cy = Math.max (lpwp.cy, rect.bottom - rect.top);
             }
         }
-        OS.MoveMemory (lParam, lpwp, WINDOWPOS.sizeof);
+        //OS.MoveMemory (lParam, lpwp, WINDOWPOS.sizeof);
     }
     return result;
 }
 }
-++/
+
--- a/dwt/widgets/ToolTip.d	Fri Feb 01 17:45:36 2008 +0100
+++ b/dwt/widgets/ToolTip.d	Fri Feb 01 20:19:46 2008 +0100
@@ -11,14 +11,17 @@
 module dwt.widgets.ToolTip;
 
 import dwt.widgets.Widget;
+import dwt.internal.win32.OS;
 class ToolTip : Widget {
     //Shell parent;
     //TrayItem item;
     char[] text = "", message = "";
     int id, x, y;
-    //bool autoHide = true, hasLocation, visible;
+    bool autoHide = true, hasLocation, visible;
     static const int TIMER_ID = 100;
     this( Widget, int );
+HWND hwndToolTip () ;
+public void setVisible (bool visible) ;
 }
 /++
 
@@ -27,15 +30,7 @@
 import dwt.events.SelectionEvent;
 import dwt.events.SelectionListener;
 import dwt.graphics.Point;
-import dwt.internal.win32.MONITORINFO;
-import dwt.internal.win32.NOTIFYICONDATA;
-import dwt.internal.win32.NOTIFYICONDATAA;
-import dwt.internal.win32.NOTIFYICONDATAW;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.POINT;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.TOOLINFO;
 
 /**
  * Instances of this class represent popup windows that are used
--- a/dwt/widgets/Widget.d	Fri Feb 01 17:45:36 2008 +0100
+++ b/dwt/widgets/Widget.d	Fri Feb 01 20:19:46 2008 +0100
@@ -10,22 +10,6 @@
  *******************************************************************************/
 module dwt.widgets.Widget;
 
-/++
-class Widget {
-    Display display;
-    void checkWidget();
-    void releaseWidget();
-    void releaseChildren(bool);
-    void release(bool);
-    void releaseParent();
-    bool isDisposed();
-    void dispose();
-    void error(int);
-    this () ;
-    this (Widget parent, int style) ;
-}
-++/
-
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.events.DisposeListener;
@@ -356,7 +340,7 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-protected void checkWidget () {
+void checkWidget () {
     Display display = this.display;
     if (display is null) error (DWT.ERROR_WIDGET_DISPOSED);
     if (display.thread !is Thread.getThis ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);