changeset 37:e3a5d61b33cd

Composite
author Frank Benoit <benoit@tionex.de>
date Fri, 01 Feb 2008 14:26:47 +0100
parents ceb20ad6c0f8
children 4d6511d2441f
files dwt/internal/win32/OS.d dwt/internal/win32/WINAPI.d dwt/widgets/Composite.d dwt/widgets/Display.d dwt/widgets/ScrollBar.d dwt/widgets/Shell.d dwt/widgets/ToolTip.d
diffstat 7 files changed, 218 insertions(+), 191 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/win32/OS.d	Tue Jan 29 00:52:45 2008 +0100
+++ b/dwt/internal/win32/OS.d	Fri Feb 01 14:26:47 2008 +0100
@@ -41,6 +41,14 @@
 
 public class OS : C {
 
+    public static HINSTANCE GetLibraryHandle(){
+        //PORTING_FIXME: GetLibraryHandle
+        // is the hInstance of the DLL or null, if not a DLL.
+        // At the moment DWT is statically linked but this needs to be fixed
+        return null;
+    }
+
+
     private static int getNOTIFYICONDATAA_V2_SIZE (){
         // hm, NOTIFYICONDATAA.dwInfoFlags.offsetof did not compile
         return IsWinCE ? NOTIFYICONDATAA.sizeof : cast(int)(&(cast(NOTIFYICONDATAA*)null).dwInfoFlags) + int.sizeof;
@@ -4040,6 +4048,7 @@
 alias WINAPI.AdjustWindowRectEx AdjustWindowRectEx;
 alias WINAPI.AlphaBlend AlphaBlend;
 alias WINAPI.Arc Arc;
+alias WINAPI.BeginBufferedPaint BeginBufferedPaint;
 alias WINAPI.BeginDeferWindowPos BeginDeferWindowPos;
 alias WINAPI.BeginPaint BeginPaint;
 alias STDWIN.BeginPath BeginPath;
@@ -4145,6 +4154,7 @@
 alias WINAPI.EnableScrollBar EnableScrollBar;
 alias WINAPI.EnableWindow EnableWindow;
 alias WINAPI.EndDeferWindowPos EndDeferWindowPos;
+alias WINAPI.EndBufferedPaint EndBufferedPaint;
 alias WINAPI.EndDoc EndDoc;
 alias WINAPI.EndPage EndPage;
 alias WINAPI.EndPaint EndPaint;
@@ -4286,6 +4296,7 @@
 alias WINAPI.GetVersionExA GetVersionExA;
 alias WINAPI.GetVersionExW GetVersionExW;
 alias WINAPI.GetWindow GetWindow;
+alias STDWIN.GetWindowDC GetWindowDC;
 alias STDWIN.GetWindowOrgEx GetWindowOrgEx;
 alias WINAPI.GetWindowLongA GetWindowLongA;
 alias WINAPI.GetWindowLongW GetWindowLongW;
--- a/dwt/internal/win32/WINAPI.d	Tue Jan 29 00:52:45 2008 +0100
+++ b/dwt/internal/win32/WINAPI.d	Fri Feb 01 14:26:47 2008 +0100
@@ -10,6 +10,8 @@
 import tango_sys_win32.Types;
 import STDWIN = tango_sys_win32.UserGdi;
 
+alias HANDLE HPAINTBUFFER;
+
 extern (Windows){
 int AddFontResourceExA(char* lpszFilename, int fl, void* pdv);
 int AddFontResourceExW(wchar* lpszFilename, int fl, void* pdv);
@@ -119,8 +121,19 @@
 BOOL IsHungAppWindow(
     HWND hWnd
 );
+HPAINTBUFFER BeginBufferedPaint(
+    HDC hdcTarget,
+    RECT *prcTarget,
+    uint/+BP_BUFFERFORMAT+/ dwFormat,
+    void*/+BP_PAINTPARAMS+/ pPaintParams,
+    HDC *phdc
+);
+HRESULT EndBufferedPaint(
+    HPAINTBUFFER hBufferedPaint,
+    BOOL fUpdateTarget
+);
 }
-
+//--------------------------------------------------------------------------------------
 
 // Windows API
 extern (Windows){
--- a/dwt/widgets/Composite.d	Tue Jan 29 00:52:45 2008 +0100
+++ b/dwt/widgets/Composite.d	Fri Feb 01 14:26:47 2008 +0100
@@ -12,30 +12,7 @@
  *******************************************************************************/
 module dwt.widgets.Composite;
 
-import dwt.widgets.Scrollable;
-import dwt.widgets.Control;
-import dwt.widgets.Layout;
-import dwt.graphics.Font;
-import dwt.internal.win32.OS;
 
-class Composite : Scrollable {
-    Layout layout_;
-    int font;
-    WINDOWPOS* [] lpwp;
-    Control [] tabList;
-    int layoutCount, backgroundMode;
-
-public Control [] getChildren () ;
-void updateFont (Font oldFont, Font newFont) ;
-public void layout () ;
-public void layout (bool ) ;
-public void layout (bool , bool ) ;
-public void layout (Control[]) ;
-Control [] _getTabList () ;
-void removeControl (Control control) ;
-Control [] _getChildren () ;
-}
-/++
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.graphics.Font;
@@ -45,6 +22,18 @@
 import dwt.graphics.Point;
 import dwt.graphics.Rectangle;
 import dwt.internal.win32.OS;
+import dwt.widgets.Scrollable;
+import dwt.widgets.Control;
+import dwt.widgets.Layout;
+import dwt.widgets.Menu;
+import dwt.widgets.Shell;
+import dwt.widgets.Decorations;
+import dwt.widgets.Event;
+import dwt.widgets.ToolTip;
+import dwt.widgets.Display;
+
+import dwt.dwthelper.System;
+import dwt.dwthelper.utils;
 
 /**
  * Instances of this class are controls which are capable
@@ -76,9 +65,9 @@
  * @see Canvas
  */
 
-public class Composite extends Scrollable {
-    Layout layout;
-    int font;
+public class Composite : Scrollable {
+    Layout layout_;
+    HFONT font;
     WINDOWPOS* [] lpwp;
     Control [] tabList;
     int layoutCount, backgroundMode;
@@ -86,7 +75,7 @@
 /**
  * Prevents uninitialized instances from being created outside the package.
  */
-Composite () {
+this () {
 }
 
 /**
@@ -119,22 +108,22 @@
  * @see DWT#NO_RADIO_GROUP
  * @see Widget#getStyle
  */
-public Composite (Composite parent, int style) {
+public this (Composite parent, int style) {
     super (parent, style);
 }
 
 Control [] _getChildren () {
     int count = 0;
-    int hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
-    if (hwndChild is 0) return new Control [0];
-    while (hwndChild !is 0) {
+    auto hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+    if (hwndChild is null) return new Control [0];
+    while (hwndChild !is null) {
         count++;
         hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
     }
     Control [] children = new Control [count];
     int index = 0;
     hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
-    while (hwndChild !is 0) {
+    while (hwndChild !is null) {
         Control control = display.getControl (hwndChild);
         if (control !is null && control !is this) {
             children [index++] = control;
@@ -203,7 +192,7 @@
         Control child = changed [i];
         Composite composite = child.parent;
         while (child !is this) {
-            if (composite.layout is null || !composite.layout.flushCache (child)) {
+            if (composite.layout_ is null || !composite.layout_.flushCache (child)) {
                 composite.state |= LAYOUT_CHANGED;
             }
             child = composite;
@@ -242,11 +231,11 @@
 public Point computeSize (int wHint, int hHint, bool changed) {
     checkWidget ();
     Point size;
-    if (layout !is null) {
+    if (layout_ !is null) {
         if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) {
             changed |= (state & LAYOUT_CHANGED) !is 0;
             state &= ~LAYOUT_CHANGED;
-            size = layout.computeSize (this, wHint, hHint, changed);
+            size = layout_.computeSize (this, wHint, hHint, changed);
         } else {
             size = new Point (wHint, hHint);
         }
@@ -374,8 +363,8 @@
     * non-registered children.
     */
     int count = 0;
-    int hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
-    while (hwndChild !is 0) {
+    auto hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+    while (hwndChild !is null) {
         count++;
         hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
     }
@@ -395,7 +384,7 @@
  */
 public Layout getLayout () {
     checkWidget ();
-    return layout;
+    return layout_;
 }
 
 /**
@@ -535,7 +524,7 @@
  */
 public void layout (bool changed) {
     checkWidget ();
-    if (layout is null) return;
+    if (layout_ is null) return;
     layout (changed, false);
 }
 
@@ -576,7 +565,7 @@
  */
 public void layout (bool changed, bool all) {
     checkWidget ();
-    if (layout is null && !all) return;
+    if (layout_ is null && !all) return;
     markLayout (changed, all);
     updateLayout (true, all);
 }
@@ -631,9 +620,9 @@
         Control child = changed [i];
         Composite composite = child.parent;
         while (child !is this) {
-            if (composite.layout !is null) {
+            if (composite.layout_ !is null) {
                 composite.state |= LAYOUT_NEEDED;
-                if (!composite.layout.flushCache (child)) {
+                if (!composite.layout_.flushCache (child)) {
                     composite.state |= LAYOUT_CHANGED;
                 }
             }
@@ -652,7 +641,7 @@
 }
 
 void markLayout (bool changed, bool all) {
-    if (layout !is null) {
+    if (layout_ !is null) {
         state |= LAYOUT_NEEDED;
         if (changed) state |= LAYOUT_CHANGED;
     }
@@ -698,16 +687,16 @@
 void releaseWidget () {
     super.releaseWidget ();
     if ((state & CANVAS) !is 0 && (style & DWT.EMBEDDED) !is 0) {
-        int hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
-        if (hwndChild !is 0) {
+        auto hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+        if (hwndChild !is null) {
             int threadId = OS.GetWindowThreadProcessId (hwndChild, null);
             if (threadId !is OS.GetCurrentThreadId ()) {
                 OS.ShowWindow (hwndChild, OS.SW_HIDE);
-                OS.SetParent (hwndChild, 0);
+                OS.SetParent (hwndChild, null);
             }
         }
     }
-    layout = null;
+    layout_ = null;
     tabList = null;
     lpwp = null;
 }
@@ -720,7 +709,7 @@
 void resizeChildren () {
     if (lpwp is null) return;
     do {
-        WINDOWPOS [] currentLpwp = lpwp;
+        WINDOWPOS* [] currentLpwp = lpwp;
         lpwp = null;
         if (!resizeChildren (true, currentLpwp)) {
             resizeChildren (false, currentLpwp);
@@ -728,15 +717,15 @@
     } while (lpwp !is null);
 }
 
-bool resizeChildren (bool defer, WINDOWPOS [] pwp) {
+bool resizeChildren (bool defer, WINDOWPOS* [] pwp) {
     if (pwp is null) return true;
-    int hdwp = 0;
+    HDWP hdwp;
     if (defer) {
         hdwp = OS.BeginDeferWindowPos (pwp.length);
-        if (hdwp is 0) return false;
+        if (hdwp is null) return false;
     }
     for (int i=0; i<pwp.length; i++) {
-        WINDOWPOS wp = pwp [i];
+        WINDOWPOS* wp = pwp [i];
         if (wp !is null) {
             /*
             * This code is intentionally commented.  All widgets that
@@ -749,35 +738,35 @@
 //              if ((bits & OS.WS_CLIPSIBLINGS) is 0) wp.flags |= OS.SWP_NOCOPYBITS;
 //          }
             if (defer) {
-                hdwp = DeferWindowPos (hdwp, wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
-                if (hdwp is 0) return false;
+                hdwp = DeferWindowPos (hdwp, wp.hwnd, null, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
+                if (hdwp is null) return false;
             } else {
-                SetWindowPos (wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
+                SetWindowPos (wp.hwnd, null, wp.x, wp.y, wp.cx, wp.cy, wp.flags);
             }
         }
     }
-    if (defer) return OS.EndDeferWindowPos (hdwp);
+    if (defer) return cast(bool)OS.EndDeferWindowPos (hdwp);
     return true;
 }
 
-void resizeEmbeddedHandle(int embeddedHandle, int width, int height) {
-    if (embeddedHandle is 0) return;
-    int [] processID = new int [1];
-    int threadId = OS.GetWindowThreadProcessId (embeddedHandle, processID);
+void resizeEmbeddedHandle(HANDLE embeddedHandle, int width, int height) {
+    if (embeddedHandle is null) return;
+    uint processID;
+    int threadId = OS.GetWindowThreadProcessId (embeddedHandle, &processID);
     if (threadId !is OS.GetCurrentThreadId ()) {
-        if (processID [0] is OS.GetCurrentProcessId ()) {
-            if (display.msgHook is 0) {
+        if (processID is OS.GetCurrentProcessId ()) {
+            if (display.msgHook is null) {
                 if (!OS.IsWinCE) {
-                    display.getMsgCallback = new Callback (display, "getMsgProc", 3);
-                    display.getMsgProc = display.getMsgCallback.getAddress ();
-                    if (display.getMsgProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
-                    display.msgHook = OS.SetWindowsHookEx (OS.WH_GETMESSAGE, display.getMsgProc, OS.GetLibraryHandle(), threadId);
+                    //display.getMsgCallback = new Callback (display, "getMsgProc", 3);
+                    //display.getMsgProc = display.getMsgCallback.getAddress ();
+                    //if (display.getMsgProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+                    display.msgHook = OS.SetWindowsHookEx (OS.WH_GETMESSAGE, &Display.getMsgFunc, OS.GetLibraryHandle(), threadId);
                     OS.PostThreadMessage (threadId, OS.WM_NULL, 0, 0);
                 }
             }
         }
         int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE | OS.SWP_ASYNCWINDOWPOS;
-        OS.SetWindowPos (embeddedHandle, 0, 0, 0, width, height, flags);
+        OS.SetWindowPos (embeddedHandle, null, 0, 0, width, height, flags);
     }
 }
 
@@ -785,7 +774,7 @@
     setResizeChildren (false);
     sendEvent (DWT.Resize);
     if (isDisposed ()) return;
-    if (layout !is null) {
+    if (layout_ !is null) {
         markLayout (false, false);
         updateLayout (false, false);
     }
@@ -857,9 +846,9 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
  * </ul>
  */
-public void setLayout (Layout layout) {
+public void setLayout (Layout layout_) {
     checkWidget ();
-    this.layout = layout;
+    this.layout_ = layout_;
 }
 
 /**
@@ -932,7 +921,7 @@
     } else {
         int count = getChildrenCount ();
         if (count > 1 && lpwp is null) {
-            lpwp = new WINDOWPOS [count];
+            lpwp = new WINDOWPOS* [count];
         }
     }
 }
@@ -957,21 +946,21 @@
     return false;
 }
 
-String toolTipText (NMTTDISPINFO hdr) {
+char[] toolTipText (NMTTDISPINFO* hdr) {
     Shell shell = getShell ();
     if ((hdr.uFlags & OS.TTF_IDISHWND) is 0) {
-        String string = null;
-        ToolTip toolTip = shell.findToolTip (hdr.idFrom);
+        char[] string = null;
+        ToolTip toolTip = shell.findToolTip (hdr.hdr.idFrom);
         if (toolTip !is null) {
             string = toolTip.message;
-            if (string is null || string.length () is 0) string = " ";
+            if (string is null || string.length is 0) string = " ";
         }
         return string;
     }
-    shell.setToolTipTitle (hdr.hwndFrom, null, 0);
-    OS.SendMessage (hdr.hwndFrom, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
-    Control control = display.getControl (hdr.idFrom);
-    return control !is null ? control.toolTipText : null;
+    shell.setToolTipTitle (hdr.hdr.hwndFrom, null, null);
+    OS.SendMessage (hdr.hdr.hwndFrom, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF);
+    Control control = display.getControl ( cast(HANDLE) hdr.hdr.idFrom);
+    return control !is null ? control.toolTipText_ : null;
 }
 
 bool translateMnemonic (Event event, Control control) {
@@ -986,7 +975,7 @@
     return false;
 }
 
-bool translateTraversal (MSG msg) {
+bool translateTraversal (MSG* msg) {
     if ((state & CANVAS) !is 0 ) {
         if ((style & DWT.EMBEDDED) !is 0) return false;
         switch (msg.wParam) {
@@ -1052,7 +1041,7 @@
         bool changed = (state & LAYOUT_CHANGED) !is 0;
         state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED);
         if (resize) setResizeChildren (false);
-        layout.layout (this, changed);
+        layout_.layout (this, changed);
         if (resize) setResizeChildren (true);
     }
     if (all) {
@@ -1071,7 +1060,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;
     if ((state & CANVAS) !is 0) {
         /* Return zero to indicate that the background was not erased */
         if ((style & DWT.NO_BACKGROUND) !is 0) return LRESULT.ZERO;
@@ -1081,26 +1070,26 @@
 
 LRESULT WM_GETDLGCODE (int wParam, int lParam) {
     LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     if ((state & CANVAS) !is 0) {
         int flags = 0;
         if (hooksKeys ()) {
             flags |= OS.DLGC_WANTALLKEYS | OS.DLGC_WANTARROWS | OS.DLGC_WANTTAB;
         }
         if ((style & DWT.NO_FOCUS) !is 0) flags |= OS.DLGC_STATIC;
-        if (OS.GetWindow (handle, OS.GW_CHILD) !is 0) flags |= OS.DLGC_STATIC;
-        if (flags !is 0) return new LRESULT (flags);
+        if (OS.GetWindow (handle, OS.GW_CHILD) !is null) flags |= OS.DLGC_STATIC;
+        if (flags !is 0) return cast(LRESULT)flags;
     }
     return result;
 }
 
 LRESULT WM_GETFONT (int wParam, int lParam) {
     LRESULT result = super.WM_GETFONT (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     int code = callWindowProc (handle, OS.WM_GETFONT, wParam, lParam);
-    if (code !is 0) return new LRESULT (code);
-    if (font is 0) font = defaultFont ();
-    return new LRESULT (font);
+    if (code !is 0) return cast( LRESULT )(code);
+    if (font is null) font = defaultFont ();
+    return cast( LRESULT )(font);
 }
 
 LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
@@ -1110,7 +1099,7 @@
     /* Set focus for a canvas with no children */
     if ((state & CANVAS) !is 0) {
         if ((style & DWT.NO_FOCUS) is 0 && hooksKeys ()) {
-            if (OS.GetWindow (handle, OS.GW_CHILD) is 0) setFocus ();
+            if (OS.GetWindow (handle, OS.GW_CHILD) is null) setFocus ();
         }
     }
     return result;
@@ -1118,7 +1107,7 @@
 
 LRESULT WM_NCPAINT (int wParam, int lParam) {
     LRESULT result = super.WM_NCPAINT (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     if ((state & CANVAS) !is 0) {
         result = wmNCPaint (handle, wParam, lParam);
     }
@@ -1128,9 +1117,9 @@
 LRESULT WM_PARENTNOTIFY (int wParam, int lParam) {
     if ((state & CANVAS) !is 0 && (style & DWT.EMBEDDED) !is 0) {
         if ((wParam & 0xFFFF) is OS.WM_CREATE) {
-            RECT rect = new RECT ();
-            OS.GetClientRect (handle, rect);
-            resizeEmbeddedHandle (lParam, rect.right - rect.left, rect.bottom - rect.top);
+            RECT rect;
+            OS.GetClientRect (handle, &rect);
+            resizeEmbeddedHandle ( cast(HANDLE)lParam, rect.right - rect.left, rect.bottom - rect.top);
         }
     }
     return super.WM_PARENTNOTIFY (wParam, lParam);
@@ -1150,7 +1139,7 @@
     }
 
     /* Paint the control and the background */
-    PAINTSTRUCT ps = new PAINTSTRUCT ();
+    PAINTSTRUCT ps;
     if (hooks (DWT.Paint)) {
 
         /* Use the buffered paint when possible */
@@ -1163,15 +1152,15 @@
             }
         }
         if (bufferedPaint) {
-            int hDC = OS.BeginPaint (handle, ps);
-            int width = ps.right - ps.left;
-            int height = ps.bottom - ps.top;
+            auto hDC = OS.BeginPaint (handle, &ps);
+            int width = ps.rcPaint.right - ps.rcPaint.left;
+            int height = ps.rcPaint.bottom - ps.rcPaint.top;
             if (width !is 0 && height !is 0) {
-                int [] phdc = new int [1];
+                HDC phdc;
                 int flags = OS.BPBF_COMPATIBLEBITMAP;
-                RECT prcTarget = new RECT ();
-                OS.SetRect (prcTarget, ps.left, ps.top, ps.right, ps.bottom);
-                int hBufferedPaint = OS.BeginBufferedPaint (hDC, prcTarget, flags, null, phdc);
+                RECT prcTarget;
+                OS.SetRect (&prcTarget, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
+                auto hBufferedPaint = OS.BeginBufferedPaint (hDC, &prcTarget, flags, null, &phdc);
                 GCData data = new GCData ();
                 if ((OS.GetLayout (hDC) & OS.LAYOUT_RTL) !is 0) {
                     data.style = DWT.RIGHT_TO_LEFT | DWT.MIRRORED;
@@ -1183,38 +1172,38 @@
                 Control control = findBackgroundControl ();
                 if (control is null) control = this;
                 data.background = control.getBackgroundPixel ();
-                data.hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+                data.hFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
                 data.uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
                 if ((style & DWT.NO_BACKGROUND) !is 0) {
                     /* This code is intentionally commented because it may be slow to copy bits from the screen */
                     //paintGC.copyArea (image, ps.left, ps.top);
                 } else {
-                    RECT rect = new RECT ();
-                    OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
-                    drawBackground (phdc [0], rect);
+                    RECT rect;
+                    OS.SetRect (&rect, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
+                    drawBackground (phdc, &rect);
                 }
-                GC gc = GC.win32_new (phdc [0], data);
+                GC gc = GC.win32_new (phdc, data);
                 Event event = new Event ();
                 event.gc = gc;
-                event.x = ps.left;
-                event.y = ps.top;
+                event.x = ps.rcPaint.left;
+                event.y = ps.rcPaint.top;
                 event.width = width;
                 event.height = height;
                 sendEvent (DWT.Paint, event);
                 gc.dispose ();
                 OS.EndBufferedPaint (hBufferedPaint, true);
             }
-            OS.EndPaint (handle, ps);
+            OS.EndPaint (handle, &ps);
         } else {
 
             /* Create the paint GC */
             GCData data = new GCData ();
-            data.ps = ps;
+            data.ps = &ps;
             data.hwnd = handle;
             GC gc = GC.win32_new (this, data);
 
             /* Get the system region for the paint HDC */
-            int sysRgn = 0;
+            HRGN sysRgn;
             if ((style & (DWT.NO_MERGE_PAINTS | DWT.DOUBLE_BUFFERED)) !is 0) {
                 sysRgn = OS.CreateRectRgn (0, 0, 0, 0);
                 if (OS.GetRandomRgn (gc.handle, sysRgn, OS.SYSRGN) is 1) {
@@ -1222,23 +1211,23 @@
                         if ((OS.GetLayout (gc.handle) & OS.LAYOUT_RTL) !is 0) {
                             int nBytes = OS.GetRegionData (sysRgn, 0, null);
                             int [] lpRgnData = new int [nBytes / 4];
-                            OS.GetRegionData (sysRgn, nBytes, lpRgnData);
-                            int newSysRgn = OS.ExtCreateRegion (new float [] {-1, 0, 0, 1, 0, 0}, nBytes, lpRgnData);
+                            OS.GetRegionData (sysRgn, nBytes, cast(RGNDATA*)lpRgnData.ptr);
+                            HRGN newSysRgn = OS.ExtCreateRegion ( cast(XFORM*) [-1.0f, 0, 0, 1, 0, 0].ptr, nBytes, cast(RGNDATA*)lpRgnData.ptr);
                             OS.DeleteObject (sysRgn);
                             sysRgn = newSysRgn;
                         }
                     }
                     if (OS.IsWinNT) {
-                        POINT pt = new POINT();
-                        OS.MapWindowPoints (0, handle, pt, 1);
+                        POINT pt;
+                        OS.MapWindowPoints (null, handle, &pt, 1);
                         OS.OffsetRgn (sysRgn, pt.x, pt.y);
                     }
                 }
             }
 
             /* Send the paint event */
-            int width = ps.right - ps.left;
-            int height = ps.bottom - ps.top;
+            int width = ps.rcPaint.right - ps.rcPaint.left;
+            int height = ps.rcPaint.bottom - ps.rcPaint.top;
             if (width !is 0 && height !is 0) {
                 GC paintGC = null;
                 Image image = null;
@@ -1251,34 +1240,34 @@
                     gc.setForeground (getForeground ());
                     gc.setBackground (getBackground ());
                     gc.setFont (getFont ());
-                    OS.OffsetRgn (sysRgn, -ps.left, -ps.top);
+                    OS.OffsetRgn (sysRgn, -ps.rcPaint.left, -ps.rcPaint.top);
                     OS.SelectClipRgn (gc.handle, sysRgn);
-                    OS.OffsetRgn (sysRgn, ps.left, ps.top);
+                    OS.OffsetRgn (sysRgn, ps.rcPaint.left, ps.rcPaint.top);
                     OS.SetMetaRgn (gc.handle);
-                    OS.SetWindowOrgEx (gc.handle, ps.left, ps.top, null);
-                    OS.SetBrushOrgEx (gc.handle, ps.left, ps.top, null);
+                    OS.SetWindowOrgEx (gc.handle, ps.rcPaint.left, ps.rcPaint.top, null);
+                    OS.SetBrushOrgEx (gc.handle, ps.rcPaint.left, ps.rcPaint.top, null);
                     if ((style & DWT.NO_BACKGROUND) !is 0) {
                         /* This code is intentionally commented because it may be slow to copy bits from the screen */
                         //paintGC.copyArea (image, ps.left, ps.top);
                     } else {
-                        RECT rect = new RECT ();
-                        OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
-                        drawBackground (gc.handle, rect);
+                        RECT rect;
+                        OS.SetRect (&rect, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
+                        drawBackground (gc.handle, &rect);
                     }
                 }
                 Event event = new Event ();
                 event.gc = gc;
-                RECT rect = null;
-                if ((style & DWT.NO_MERGE_PAINTS) !is 0 && OS.GetRgnBox (sysRgn, rect = new RECT ()) is OS.COMPLEXREGION) {
+                RECT rect;
+                if ((style & DWT.NO_MERGE_PAINTS) !is 0 && OS.GetRgnBox (sysRgn, &rect) is OS.COMPLEXREGION) {
                     int nBytes = OS.GetRegionData (sysRgn, 0, null);
                     int [] lpRgnData = new int [nBytes / 4];
-                    OS.GetRegionData (sysRgn, nBytes, lpRgnData);
+                    OS.GetRegionData (sysRgn, nBytes, cast(RGNDATA*)lpRgnData.ptr);
                     int count = lpRgnData [2];
                     for (int i=0; i<count; i++) {
                         int offset = 8 + (i << 2);
-                        OS.SetRect (rect, lpRgnData [offset], lpRgnData [offset + 1], lpRgnData [offset + 2], lpRgnData [offset + 3]);
+                        OS.SetRect (&rect, lpRgnData [offset], lpRgnData [offset + 1], lpRgnData [offset + 2], lpRgnData [offset + 3]);
                         if ((style & (DWT.DOUBLE_BUFFERED | DWT.NO_BACKGROUND)) is 0) {
-                            drawBackground (gc.handle, rect);
+                            drawBackground (gc.handle, &rect);
                         }
                         event.x = rect.left;
                         event.y = rect.top;
@@ -1289,12 +1278,11 @@
                     }
                 } else {
                     if ((style & (DWT.DOUBLE_BUFFERED | DWT.NO_BACKGROUND)) is 0) {
-                        if (rect is null) rect = new RECT ();
-                        OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
-                        drawBackground (gc.handle, rect);
+                        OS.SetRect (&rect, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
+                        drawBackground (gc.handle, &rect);
                     }
-                    event.x = ps.left;
-                    event.y = ps.top;
+                    event.x = ps.rcPaint.left;
+                    event.y = ps.rcPaint.top;
                     event.width = width;
                     event.height = height;
                     sendEvent (DWT.Paint, event);
@@ -1303,24 +1291,24 @@
                 event.gc = null;
                 if ((style & DWT.DOUBLE_BUFFERED) !is 0) {
                     gc.dispose();
-                    if (!isDisposed ()) paintGC.drawImage (image, ps.left, ps.top);
+                    if (!isDisposed ()) paintGC.drawImage (image, ps.rcPaint.left, ps.rcPaint.top);
                     image.dispose ();
                     gc = paintGC;
                 }
             }
-            if (sysRgn !is 0) OS.DeleteObject (sysRgn);
+            if (sysRgn !is null) OS.DeleteObject (sysRgn);
 
             /* Dispose the paint GC */
             gc.dispose ();
         }
     } else {
-        int hDC = OS.BeginPaint (handle, ps);
+        auto hDC = OS.BeginPaint (handle, &ps);
         if ((style & DWT.NO_BACKGROUND) is 0) {
-            RECT rect = new RECT ();
-            OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
-            drawBackground (hDC, rect);
+            RECT rect;
+            OS.SetRect (&rect, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom);
+            drawBackground (hDC, &rect);
         }
-        OS.EndPaint (handle, ps);
+        OS.EndPaint (handle, &ps);
     }
 
     /* Restore the clipping bits */
@@ -1342,14 +1330,14 @@
 
 LRESULT WM_PRINTCLIENT (int wParam, int lParam) {
     LRESULT result = super.WM_PRINTCLIENT (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     if ((state & CANVAS) !is 0) {
         forceResize ();
-        int nSavedDC = OS.SaveDC (wParam);
-        RECT rect = new RECT ();
-        OS.GetClientRect (handle, rect);
+        auto nSavedDC = OS.SaveDC (cast(HDC)wParam);
+        RECT rect;
+        OS.GetClientRect (handle, &rect);
         if ((style & DWT.NO_BACKGROUND) is 0) {
-            drawBackground (wParam, rect);
+            drawBackground ( cast(HDC)wParam, &rect);
         }
         if (hooks (DWT.Paint) || filters (DWT.Paint)) {
             GCData data = new GCData ();
@@ -1358,9 +1346,9 @@
             Control control = findBackgroundControl ();
             if (control is null) control = this;
             data.background = control.getBackgroundPixel ();
-            data.hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+            data.hFont = cast(HFONT)OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
             data.uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0);
-            GC gc = GC.win32_new (wParam, data);
+            GC gc = GC.win32_new (cast(HDC)wParam, data);
             Event event = new Event ();
             event.gc = gc;
             event.x = rect.left;
@@ -1371,14 +1359,15 @@
             event.gc = null;
             gc.dispose ();
         }
-        OS.RestoreDC (wParam, nSavedDC);
+        OS.RestoreDC (cast(HDC)wParam, nSavedDC);
     }
     return result;
 }
 
 LRESULT WM_SETFONT (int wParam, int lParam) {
     if (lParam !is 0) OS.InvalidateRect (handle, null, true);
-    return super.WM_SETFONT (font = wParam, lParam);
+    font = cast(HFONT)wParam;
+    return super.WM_SETFONT (wParam, lParam);
 }
 
 LRESULT WM_SIZE (int wParam, int lParam) {
@@ -1396,7 +1385,7 @@
     * WM_SIZE message.
     */
     if (isDisposed ()) return result;
-    if (layout !is null) {
+    if (layout_ !is null) {
         markLayout (false, false);
         updateLayout (false, false);
     }
@@ -1427,9 +1416,9 @@
 
 LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
     LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
-    if (result !is null) return result;
-    int hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
-    while (hwndChild !is 0) {
+    if (result !is LRESULT.NULL) return result;
+    auto hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+    while (hwndChild !is null) {
         OS.SendMessage (hwndChild, OS.WM_SYSCOLORCHANGE, 0, 0);
         hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
     }
@@ -1438,7 +1427,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;
 
     /*
     * Check to see if the command is a system command or
@@ -1464,10 +1453,10 @@
                 if ((showHBar !is (horizontalBar !is null && horizontalBar.getVisible ())) ||
                     (showVBar !is (verticalBar !is null && verticalBar.getVisible ()))) {
                         int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_UPDATENOW;
-                        OS.RedrawWindow (handle, null, 0, flags);
+                        OS.RedrawWindow (handle, null, null, flags);
                     }
                 if (code is 0) return LRESULT.ZERO;
-                return new LRESULT (code);
+                return cast( LRESULT )(code);
         }
     }
     /* Return the result */
@@ -1476,12 +1465,12 @@
 
 LRESULT WM_UPDATEUISTATE (int wParam, int lParam) {
     LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam);
-    if (result !is null) return result;
+    if (result !is LRESULT.NULL) return result;
     if ((state & CANVAS) !is 0) OS.InvalidateRect (handle, null, false);
     return result;
 }
 
-LRESULT wmNCPaint (int hwnd, int wParam, int lParam) {
+LRESULT wmNCPaint (HWND hwnd, int wParam, int lParam) {
     if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
         int bits1 = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
         if ((bits1 & OS.WS_EX_CLIENTEDGE) !is 0) {
@@ -1490,23 +1479,23 @@
             if ((bits2 & (OS.WS_HSCROLL | OS.WS_VSCROLL)) !is 0) {
                 code = callWindowProc (hwnd, OS.WM_NCPAINT, wParam, lParam);
             }
-            int hDC = OS.GetWindowDC (hwnd);
-            RECT rect = new RECT ();
-            OS.GetWindowRect (hwnd, rect);
+            auto hDC = OS.GetWindowDC (hwnd);
+            RECT rect;
+            OS.GetWindowRect (hwnd, &rect);
             rect.right -= rect.left;
             rect.bottom -= rect.top;
             rect.left = rect.top = 0;
             int border = OS.GetSystemMetrics (OS.SM_CXEDGE);
             OS.ExcludeClipRect (hDC, border, border, rect.right - border, rect.bottom - border);
-            OS.DrawThemeBackground (display.hEditTheme (), hDC, OS.EP_EDITTEXT, OS.ETS_NORMAL, rect, null);
+            OS.DrawThemeBackground (display.hEditTheme (), hDC, OS.EP_EDITTEXT, OS.ETS_NORMAL, &rect, null);
             OS.ReleaseDC (hwnd, hDC);
-            return new LRESULT (code);
+            return cast(LRESULT )(code);
         }
     }
-    return null;
+    return LRESULT.NULL;
 }
 
-LRESULT wmNotify (NMHDR hdr, int wParam, int lParam) {
+LRESULT wmNotify (NMHDR* hdr, int wParam, int lParam) {
     if (!OS.IsWinCE) {
         switch (hdr.code) {
             /*
@@ -1532,17 +1521,17 @@
                 * check if the parent is already on top and neither set or clear
                 * the topmost status of the tool tip.
                 */
-                int hwndParent = hdr.hwndFrom;
+                auto hwndParent = hdr.hwndFrom;
                 do {
                     hwndParent = OS.GetParent (hwndParent);
-                    if (hwndParent is 0) break;
+                    if (hwndParent is null) break;
                     int bits = OS.GetWindowLong (hwndParent, OS.GWL_EXSTYLE);
                     if ((bits & OS.WS_EX_TOPMOST) !is 0) break;
                 } while (true);
-                if (hwndParent !is 0) break;
+                if (hwndParent !is null) break;
                 display.lockActiveWindow = true;
                 int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOSIZE;
-                int hwndInsertAfter = hdr.code is OS.TTN_SHOW ? OS.HWND_TOPMOST : OS.HWND_NOTOPMOST;
+                HWND hwndInsertAfter = cast(HWND)( hdr.code is OS.TTN_SHOW ? OS.HWND_TOPMOST : OS.HWND_NOTOPMOST);
                 SetWindowPos (hdr.hwndFrom, hwndInsertAfter, 0, 0, 0, 0, flags);
                 display.lockActiveWindow = false;
                 break;
@@ -1561,28 +1550,28 @@
             */
             case OS.TTN_GETDISPINFOA:
             case OS.TTN_GETDISPINFOW: {
-                NMTTDISPINFO lpnmtdi;
-                if (hdr.code is OS.TTN_GETDISPINFOA) {
-                    lpnmtdi = new NMTTDISPINFOA ();
-                    OS.MoveMemory ((NMTTDISPINFOA)lpnmtdi, lParam, NMTTDISPINFOA.sizeof);
-                } else {
-                    lpnmtdi = new NMTTDISPINFOW ();
-                    OS.MoveMemory ((NMTTDISPINFOW)lpnmtdi, lParam, NMTTDISPINFOW.sizeof);
-                }
-                String string = toolTipText (lpnmtdi);
+                NMTTDISPINFO* lpnmtdi = cast(NMTTDISPINFO*)lParam;
+//                 if (hdr.code is OS.TTN_GETDISPINFOA) {
+//                     lpnmtdi = new NMTTDISPINFOA ();
+//                     OS.MoveMemory (cast(NMTTDISPINFOA)lpnmtdi, lParam, NMTTDISPINFOA.sizeof);
+//                 } else {
+//                     lpnmtdi = new NMTTDISPINFOW ();
+//                     OS.MoveMemory (cast(NMTTDISPINFOW)lpnmtdi, lParam, NMTTDISPINFOW.sizeof);
+//                 }
+                char[] string = toolTipText (lpnmtdi);
                 if (string !is null) {
                     Shell shell = getShell ();
                     string = Display.withCrLf (string);
-                    int length = string.length ();
-                    char [] chars = new char [length + 1];
-                    string.getChars (0, length, chars, 0);
+                    int length_ = string.length;
+                    char [] chars = new char [length_ + 1];
+                    string.getChars (0, length_, chars, 0);
 
                     /*
                     * Ensure that the orientation of the tool tip matches
                     * the orientation of the control.
                     */
-                    int hwnd = hdr.idFrom;
-                    if (hwnd !is 0 && ((lpnmtdi.uFlags & OS.TTF_IDISHWND) !is 0)) {
+                    HWND hwnd = cast(HWND)hdr.idFrom;
+                    if (hwnd !is null && ((lpnmtdi.uFlags & OS.TTF_IDISHWND) !is 0)) {
                         Control control = display.getControl (hwnd);
                         if (control !is null) {
                             if ((control.getStyle () & DWT.RIGHT_TO_LEFT) !is 0) {
@@ -1594,13 +1583,14 @@
                     }
 
                     if (hdr.code is OS.TTN_GETDISPINFOA) {
-                        byte [] bytes = new byte [chars.length * 2];
-                        OS.WideCharToMultiByte (getCodePage (), 0, chars, chars.length, bytes, bytes.length, null, null);
+                        auto bytes = MBCSsToStr( chars, getCodePage () );
+                        //byte [] bytes = new byte [chars.length * 2];
+                        //OS.WideCharToMultiByte (getCodePage (), 0, chars.ptr, chars.length, bytes, bytes.length, null, null);
                         shell.setToolTipText (lpnmtdi, bytes);
-                        OS.MoveMemory (lParam, (NMTTDISPINFOA)lpnmtdi, NMTTDISPINFOA.sizeof);
+                        //OS.MoveMemory (lParam, cast(NMTTDISPINFOA)lpnmtdi, NMTTDISPINFOA.sizeof);
                     } else {
                         shell.setToolTipText (lpnmtdi, chars);
-                        OS.MoveMemory (lParam, (NMTTDISPINFOW)lpnmtdi, NMTTDISPINFOW.sizeof);
+                        //OS.MoveMemory (lParam, cast(NMTTDISPINFOW)lpnmtdi, NMTTDISPINFOW.sizeof);
                     }
                     return LRESULT.ZERO;
                 }
@@ -1612,4 +1602,3 @@
 }
 
 }
-++/
\ No newline at end of file
--- a/dwt/widgets/Display.d	Tue Jan 29 00:52:45 2008 +0100
+++ b/dwt/widgets/Display.d	Fri Feb 01 14:26:47 2008 +0100
@@ -2001,6 +2001,10 @@
     return result;
 }
 
+static extern(Windows) int getMsgFunc (int code, int wParam, int lParam) {
+    return Display.getCurrent().getMsgProc( code, wParam, lParam );
+}
+
 int getMsgProc (int code, int wParam, int lParam) {
     if (embeddedHwnd is null) {
         auto hInstance = OS.GetModuleHandle (null);
--- a/dwt/widgets/ScrollBar.d	Tue Jan 29 00:52:45 2008 +0100
+++ b/dwt/widgets/ScrollBar.d	Fri Feb 01 14:26:47 2008 +0100
@@ -21,6 +21,7 @@
 public int getIncrement () ;
 public int getPageIncrement () ;
 LRESULT wmScrollChild (int wParam, int lParam) ;
+public bool getVisible () ;
 }
 /++
 import dwt.DWT;
--- a/dwt/widgets/Shell.d	Tue Jan 29 00:52:45 2008 +0100
+++ b/dwt/widgets/Shell.d	Fri Feb 01 14:26:47 2008 +0100
@@ -13,6 +13,7 @@
 import dwt.widgets.Decorations;
 import dwt.widgets.Control;
 import dwt.widgets.Menu;
+import dwt.widgets.ToolTip;
 import dwt.internal.win32.OS;
 
 class Shell : Decorations {
@@ -26,6 +27,8 @@
     void releaseChildren (bool destroy) ;
     void setToolTipText (HWND hwnd, char[] text) ;
     void fixToolTip () ;
+    ToolTip findToolTip (int id) ;
+void setToolTipTitle (HWND hwndToolTip, char[] text, HICON icon) ;
 }
 /++
 import dwt.DWT;
--- a/dwt/widgets/ToolTip.d	Tue Jan 29 00:52:45 2008 +0100
+++ b/dwt/widgets/ToolTip.d	Fri Feb 01 14:26:47 2008 +0100
@@ -12,6 +12,12 @@
 
 import dwt.widgets.Widget;
 class ToolTip : Widget {
+    //Shell parent;
+    //TrayItem item;
+    char[] text = "", message = "";
+    int id, x, y;
+    //bool autoHide = true, hasLocation, visible;
+    static const int TIMER_ID = 100;
     this( Widget, int );
 }
 /++