changeset 33:39a9959ef14d

Display + ImageList
author Frank Benoit <benoit@tionex.de>
date Mon, 28 Jan 2008 21:05:39 +0100
parents 2985239119a3
children 943a86053d88
files dwt/dwthelper/System.d dwt/dwthelper/utils.d dwt/internal/ImageList.d dwt/internal/win32/OS.d dwt/internal/win32/WINAPI.d dwt/internal/win32/WINTYPES.d dwt/widgets/Composite.d dwt/widgets/Control.d dwt/widgets/Decorations.d dwt/widgets/Display.d dwt/widgets/Menu.d dwt/widgets/MenuItem.d dwt/widgets/Monitor.d dwt/widgets/Shell.d dwt/widgets/TrayItem.d tango_sys_win32/Types.di
diffstat 16 files changed, 1347 insertions(+), 747 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/dwthelper/System.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/dwthelper/System.d	Mon Jan 28 21:05:39 2008 +0100
@@ -4,6 +4,7 @@
 module dwt.dwthelper.System;
 
 import tango.core.Exception;
+import tango.stdc.stdlib : exit;
 
 template SimpleType(T) {
     debug{
@@ -124,5 +125,9 @@
         return 0;
     }
 
+    static void exit( int code ){
+        .exit(code);
+    }
+
 }
 
--- a/dwt/dwthelper/utils.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/dwthelper/utils.d	Mon Jan 28 21:05:39 2008 +0100
@@ -22,6 +22,8 @@
 
 abstract class ArrayWrapper{
 }
+abstract class ValueWrapper{
+}
 
 class ArrayWrapperT(T) : ArrayWrapper {
     public T[] array;
@@ -30,6 +32,14 @@
     }
 }
 
+class ValueWrapperT(T) : ValueWrapper {
+    public T value;
+    public this( T data ){
+        value = data;
+    }
+}
+
+alias ValueWrapperT!(bool)    ValueWrapperBool;
 alias ArrayWrapperT!(byte)    ArrayWrapperByte;
 alias ArrayWrapperT!(int)     ArrayWrapperInt;
 alias ArrayWrapperT!(Object)  ArrayWrapperObject;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/internal/ImageList.d	Mon Jan 28 21:05:39 2008 +0100
@@ -0,0 +1,474 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ * Port to the D programming language:
+ *     Frank Benoit <benoit@tionex.de>
+ *******************************************************************************/
+module dwt.internal.ImageList;
+
+
+import dwt.DWT;
+import dwt.graphics.Color;
+import dwt.graphics.Image;
+import dwt.graphics.ImageData;
+import dwt.graphics.PaletteData;
+import dwt.graphics.Point;
+import dwt.graphics.RGB;
+import dwt.graphics.Rectangle;
+import dwt.internal.win32.OS;
+
+import dwt.dwthelper.utils;
+import dwt.dwthelper.System;
+
+public class ImageList {
+    HIMAGELIST handle;
+    int style, refCount;
+    Image [] images;
+
+public this (int style) {
+    this.style = style;
+    int flags = OS.ILC_MASK;
+    if (OS.IsWinCE) {
+        flags |= OS.ILC_COLOR;
+    } else {
+        if (OS.COMCTL32_MAJOR >= 6) {
+            flags |= OS.ILC_COLOR32;
+        } else {
+            auto hDC = OS.GetDC (null);
+            auto bits = OS.GetDeviceCaps (hDC, OS.BITSPIXEL);
+            auto planes = OS.GetDeviceCaps (hDC, OS.PLANES);
+            OS.ReleaseDC (null, hDC);
+            int depth = bits * planes;
+            switch (depth) {
+                case 4: flags |= OS.ILC_COLOR4; break;
+                case 8: flags |= OS.ILC_COLOR8; break;
+                case 16: flags |= OS.ILC_COLOR16; break;
+                case 24: flags |= OS.ILC_COLOR24; break;
+                case 32: flags |= OS.ILC_COLOR32; break;
+                default: flags |= OS.ILC_COLOR; break;
+            }
+        }
+    }
+    if ((style & DWT.RIGHT_TO_LEFT) !is 0) flags |= OS.ILC_MIRROR;
+    handle = OS.ImageList_Create (32, 32, flags, 16, 16);
+    images = new Image [4];
+}
+
+public int add (Image image) {
+    int count = OS.ImageList_GetImageCount (handle);
+    int index = 0;
+    while (index < count) {
+        if (images [index] !is null) {
+            if (images [index].isDisposed ()) images [index] = null;
+        }
+        if (images [index] is null) break;
+        index++;
+    }
+    if (count is 0) {
+        Rectangle rect = image.getBounds ();
+        OS.ImageList_SetIconSize (handle, rect.width, rect.height);
+    }
+    set (index, image, count);
+    if (index is images.length) {
+        Image [] newImages = new Image [images.length + 4];
+        System.arraycopy (images, 0, newImages, 0, images.length);
+        images = newImages;
+    }
+    images [index] = image;
+    return index;
+}
+
+public int addRef() {
+    return ++refCount;
+}
+
+HBITMAP copyBitmap (HBITMAP hImage, int width, int height) {
+    BITMAP bm;
+    OS.GetObject (hImage, BITMAP.sizeof, &bm);
+    auto hDC = OS.GetDC (null);
+    auto hdc1 = OS.CreateCompatibleDC (hDC);
+    OS.SelectObject (hdc1, hImage);
+    auto hdc2 = OS.CreateCompatibleDC (hDC);
+    /*
+    * Feature in Windows.  If a bitmap has a 32-bit depth and any
+    * pixel has an alpha value different than zero, common controls
+    * version 6.0 assumes that the bitmap should be alpha blended.
+    * AlphaBlend() composes the alpha channel of a destination 32-bit
+    * depth image with the alpha channel of the source image. This
+    * may cause opaque images to draw transparently.  The fix is
+    * remove the alpha channel of opaque images by down sampling
+    * it to 24-bit depth.
+    */
+    HBITMAP hBitmap;
+    if (bm.bmBitsPixel is 32 && OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
+        BITMAPINFOHEADER bmiHeader;
+        bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+        bmiHeader.biWidth = width;
+        bmiHeader.biHeight = -height;
+        bmiHeader.biPlanes = 1;
+        bmiHeader.biBitCount = cast(short)24;
+        static if (OS.IsWinCE) bmiHeader.biCompression = OS.BI_BITFIELDS;
+        else bmiHeader.biCompression = OS.BI_RGB;
+        byte[] bmi = new byte[BITMAPINFOHEADER.sizeof + (OS.IsWinCE ? 12 : 0)];
+        *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader;
+        //OS.MoveMemory(bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+        /* Set the rgb colors into the bitmap info */
+        if (OS.IsWinCE) {
+            int redMask = 0xFF00;
+            int greenMask = 0xFF0000;
+            int blueMask = 0xFF000000;
+            /* big endian */
+            int offset = BITMAPINFOHEADER.sizeof;
+            bmi[offset] = cast(byte)((redMask & 0xFF000000) >> 24);
+            bmi[offset + 1] = cast(byte)((redMask & 0xFF0000) >> 16);
+            bmi[offset + 2] = cast(byte)((redMask & 0xFF00) >> 8);
+            bmi[offset + 3] = cast(byte)((redMask & 0xFF) >> 0);
+            bmi[offset + 4] = cast(byte)((greenMask & 0xFF000000) >> 24);
+            bmi[offset + 5] = cast(byte)((greenMask & 0xFF0000) >> 16);
+            bmi[offset + 6] = cast(byte)((greenMask & 0xFF00) >> 8);
+            bmi[offset + 7] = cast(byte)((greenMask & 0xFF) >> 0);
+            bmi[offset + 8] = cast(byte)((blueMask & 0xFF000000) >> 24);
+            bmi[offset + 9] = cast(byte)((blueMask & 0xFF0000) >> 16);
+            bmi[offset + 10] = cast(byte)((blueMask & 0xFF00) >> 8);
+            bmi[offset + 11] = cast(byte)((blueMask & 0xFF) >> 0);
+        }
+        int[1] pBits;
+        hBitmap = OS.CreateDIBSection(null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, pBits.ptr, null, 0);
+    } else {
+        hBitmap = OS.CreateCompatibleBitmap (hDC, width, height);
+    }
+    OS.SelectObject (hdc2, hBitmap);
+    if (width !is bm.bmWidth || height !is bm.bmHeight) {
+        if (!OS.IsWinCE) OS.SetStretchBltMode(hdc2, OS.COLORONCOLOR);
+        OS.StretchBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, bm.bmWidth, bm.bmHeight, OS.SRCCOPY);
+    } else {
+        OS.BitBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, OS.SRCCOPY);
+    }
+    OS.DeleteDC (hdc1);
+    OS.DeleteDC (hdc2);
+    OS.ReleaseDC (null, hDC);
+    return hBitmap;
+}
+
+HBITMAP copyIcon (HBITMAP hImage, int width, int height) {
+    static if (OS.IsWinCE) DWT.error(DWT.ERROR_NOT_IMPLEMENTED);
+    auto hIcon = OS.CopyImage (hImage, OS.IMAGE_ICON, width, height, 0);
+    return hIcon !is null ? hIcon : hImage;
+}
+
+HBITMAP copyWithAlpha (HBITMAP hBitmap, int background, byte[] alphaData, int destWidth, int destHeight) {
+    BITMAP bm;
+    OS.GetObject (hBitmap, BITMAP.sizeof, &bm);
+    int srcWidth = bm.bmWidth;
+    int srcHeight = bm.bmHeight;
+
+    /* Create resources */
+    auto hdc = OS.GetDC (null);
+    auto srcHdc = OS.CreateCompatibleDC (hdc);
+    auto oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
+    auto memHdc = OS.CreateCompatibleDC (hdc);
+    BITMAPINFOHEADER bmiHeader;
+    bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
+    bmiHeader.biWidth = srcWidth;
+    bmiHeader.biHeight = -srcHeight;
+    bmiHeader.biPlanes = 1;
+    bmiHeader.biBitCount = 32;
+    bmiHeader.biCompression = OS.BI_RGB;
+    byte [] bmi = new byte[BITMAPINFOHEADER.sizeof];
+    *cast(BITMAPINFOHEADER*)bmi.ptr = bmiHeader;
+    //OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
+    int [1] pBits;
+    auto memDib = OS.CreateDIBSection (null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, pBits.ptr, null, 0);
+    if (memDib is null) DWT.error (DWT.ERROR_NO_HANDLES);
+    auto oldMemBitmap = OS.SelectObject (memHdc, memDib);
+
+    BITMAP dibBM;
+    OS.GetObject (memDib, BITMAP.sizeof, &dibBM);
+    int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
+
+    /* Get the foreground pixels */
+    OS.BitBlt (memHdc, 0, 0, srcWidth, srcHeight, srcHdc, 0, 0, OS.SRCCOPY);
+    byte[] srcData = (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes].dup;
+    //OS.MoveMemory (srcData, dibBM.bmBits, sizeInBytes);
+
+    /* Merge the alpha channel in place */
+    if (alphaData !is null) {
+        int spinc = dibBM.bmWidthBytes - srcWidth * 4;
+        int ap = 0, sp = 3;
+        for (int y = 0; y < srcHeight; ++y) {
+            for (int x = 0; x < srcWidth; ++x) {
+                srcData [sp] = alphaData [ap++];
+                sp += 4;
+            }
+            sp += spinc;
+        }
+    } else {
+        byte transRed = cast(byte)(background & 0xFF);
+        byte transGreen = cast(byte)((background >> 8) & 0xFF);
+        byte transBlue = cast(byte)((background >> 16) & 0xFF);
+        final int spinc = dibBM.bmWidthBytes - srcWidth * 4;
+        int sp = 3;
+        for (int y = 0; y < srcHeight; ++y) {
+            for (int x = 0; x < srcWidth; ++x) {
+                srcData [sp] = (srcData[sp-1] is transRed && srcData[sp-2] is transGreen && srcData[sp-3] is transBlue) ? 0 : cast(byte)255;
+                sp += 4;
+            }
+            sp += spinc;
+        }
+    }
+    (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes] = srcData;
+    //OS.MoveMemory (dibBM.bmBits, srcData, sizeInBytes);
+
+    /* Stretch and free resources */
+    if (srcWidth !is destWidth || srcHeight !is destHeight) {
+        BITMAPINFOHEADER bmiHeader2;
+        bmiHeader2.biSize = BITMAPINFOHEADER.sizeof;
+        bmiHeader2.biWidth = destWidth;
+        bmiHeader2.biHeight = -destHeight;
+        bmiHeader2.biPlanes = 1;
+        bmiHeader2.biBitCount = 32;
+        bmiHeader2.biCompression = OS.BI_RGB;
+        byte [] bmi2 = new byte[BITMAPINFOHEADER.sizeof];
+        *cast(BITMAPINFOHEADER*)bmi2.ptr = bmiHeader2;
+        //OS.MoveMemory (bmi2, bmiHeader2, BITMAPINFOHEADER.sizeof);
+        int [1] pBits2;
+        auto memDib2 = OS.CreateDIBSection (null, cast(BITMAPINFO*)bmi2.ptr, OS.DIB_RGB_COLORS, pBits2.ptr, null, 0);
+        auto memHdc2 = OS.CreateCompatibleDC (hdc);
+        auto oldMemBitmap2 = OS.SelectObject (memHdc2, memDib2);
+        if (!OS.IsWinCE) OS.SetStretchBltMode(memHdc2, OS.COLORONCOLOR);
+        OS.StretchBlt (memHdc2, 0, 0, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, OS.SRCCOPY);
+        OS.SelectObject (memHdc2, oldMemBitmap2);
+        OS.DeleteDC (memHdc2);
+        OS.SelectObject (memHdc, oldMemBitmap);
+        OS.DeleteDC (memHdc);
+        OS.DeleteObject (memDib);
+        memDib = memDib2;
+    } else {
+        OS.SelectObject (memHdc, oldMemBitmap);
+        OS.DeleteDC (memHdc);
+    }
+    OS.SelectObject (srcHdc, oldSrcBitmap);
+    OS.DeleteDC (srcHdc);
+    OS.ReleaseDC (null, hdc);
+    return memDib;
+}
+
+HBITMAP createMaskFromAlpha (ImageData data, int destWidth, int destHeight) {
+    int srcWidth = data.width;
+    int srcHeight = data.height;
+    ImageData mask = ImageData.internal_new (srcWidth, srcHeight, 1,
+            new PaletteData([new RGB (0, 0, 0), new RGB (0xff, 0xff, 0xff)]),
+            2, null, 1, null, null, -1, -1, -1, 0, 0, 0, 0);
+    int ap = 0;
+    for (int y = 0; y < mask.height; y++) {
+        for (int x = 0; x < mask.width; x++) {
+            mask.setPixel (x, y, (data.alphaData [ap++] & 0xff) <= 127 ? 1 : 0);
+        }
+    }
+    auto hMask = OS.CreateBitmap (srcWidth, srcHeight, 1, 1, mask.data.ptr);
+    if (srcWidth !is destWidth || srcHeight !is destHeight) {
+        auto hdc = OS.GetDC (null);
+        auto hdc1 = OS.CreateCompatibleDC (hdc);
+        OS.SelectObject (hdc1, hMask);
+        auto hdc2 = OS.CreateCompatibleDC (hdc);
+        auto hMask2 = OS.CreateBitmap (destWidth, destHeight, 1, 1, null);
+        OS.SelectObject (hdc2, hMask2);
+        if (!OS.IsWinCE) OS.SetStretchBltMode(hdc2, OS.COLORONCOLOR);
+        OS.StretchBlt (hdc2, 0, 0, destWidth, destHeight, hdc1, 0, 0, srcWidth, srcHeight, OS.SRCCOPY);
+        OS.DeleteDC (hdc1);
+        OS.DeleteDC (hdc2);
+        OS.ReleaseDC (null, hdc);
+        OS.DeleteObject(hMask);
+        hMask = hMask2;
+    }
+    return hMask;
+}
+
+HBITMAP createMask (HBITMAP hBitmap, int destWidth, int destHeight, int background, int transparentPixel) {
+    BITMAP bm;
+    OS.GetObject (hBitmap, BITMAP.sizeof, &bm);
+    int srcWidth = bm.bmWidth;
+    int srcHeight = bm.bmHeight;
+    auto hMask = OS.CreateBitmap (destWidth, destHeight, 1, 1, null);
+    auto hDC = OS.GetDC (null);
+    auto hdc1 = OS.CreateCompatibleDC (hDC);
+    if (background !is -1) {
+        OS.SelectObject (hdc1, hBitmap);
+
+        /*
+        * If the image has a palette with multiple entries having
+        * the same color and one of those entries is the transparentPixel,
+        * only the first entry becomes transparent. To avoid this
+        * problem, temporarily change the image palette to a palette
+        * where the transparentPixel is white and everything else is
+        * black.
+        */
+        bool isDib = bm.bmBits !is null;
+        byte[] originalColors = null;
+        if (!OS.IsWinCE && transparentPixel !is -1 && isDib && bm.bmBitsPixel <= 8) {
+            int maxColors = 1 << bm.bmBitsPixel;
+            byte[] oldColors = new byte[maxColors * 4];
+            OS.GetDIBColorTable(hdc1, 0, maxColors, cast(RGBQUAD*)oldColors.ptr);
+            int offset = transparentPixel * 4;
+            byte[] newColors = new byte[oldColors.length];
+            newColors[offset] = cast(byte)0xFF;
+            newColors[offset+1] = cast(byte)0xFF;
+            newColors[offset+2] = cast(byte)0xFF;
+            OS.SetDIBColorTable(hdc1, 0, maxColors, cast(RGBQUAD*)newColors.ptr);
+            originalColors = oldColors;
+            OS.SetBkColor (hdc1, 0xFFFFFF);
+        } else {
+            OS.SetBkColor (hdc1, background);
+        }
+
+        auto hdc2 = OS.CreateCompatibleDC (hDC);
+        OS.SelectObject (hdc2, hMask);
+        if (destWidth !is srcWidth || destHeight !is srcHeight) {
+            if (!OS.IsWinCE) OS.SetStretchBltMode (hdc2, OS.COLORONCOLOR);
+            OS.StretchBlt (hdc2, 0, 0, destWidth, destHeight, hdc1, 0, 0, srcWidth, srcHeight, OS.SRCCOPY);
+        } else {
+            OS.BitBlt (hdc2, 0, 0, destWidth, destHeight, hdc1, 0, 0, OS.SRCCOPY);
+        }
+        OS.DeleteDC (hdc2);
+
+        /* Put back the original palette */
+        if (originalColors !is null) OS.SetDIBColorTable(hdc1, 0, 1 << bm.bmBitsPixel, cast(RGBQUAD*)originalColors.ptr);
+    } else {
+        auto hOldBitmap = OS.SelectObject (hdc1, hMask);
+        OS.PatBlt (hdc1, 0, 0, destWidth, destHeight, OS.BLACKNESS);
+        OS.SelectObject (hdc1, hOldBitmap);
+    }
+    OS.ReleaseDC (null, hDC);
+    OS.DeleteDC (hdc1);
+    return hMask;
+}
+
+public void dispose () {
+    if (handle !is null) OS.ImageList_Destroy (handle);
+    handle = null;
+    images = null;
+}
+
+public Image get (int index) {
+    return images [index];
+}
+
+public int getStyle () {
+    return style;
+}
+
+public HIMAGELIST getHandle () {
+    return handle;
+}
+
+public Point getImageSize() {
+    int cx, cy;
+    OS.ImageList_GetIconSize (handle, &cx, &cy);
+    return new Point (cx, cy);
+}
+
+public int indexOf (Image image) {
+    int count = OS.ImageList_GetImageCount (handle);
+    for (int i=0; i<count; i++) {
+        if (images [i] !is null) {
+            if (images [i].isDisposed ()) images [i] = null;
+            if (images [i] !is null && images [i]==/*eq*/image) return i;
+        }
+    }
+    return -1;
+}
+
+public void put (int index, Image image) {
+    int count = OS.ImageList_GetImageCount (handle);
+    if (!(0 <= index && index < count)) return;
+    if (image !is null) set(index, image, count);
+    images [index] = image;
+}
+
+public void remove (int index) {
+    int count = OS.ImageList_GetImageCount (handle);
+    if (!(0 <= index && index < count)) return;
+    OS.ImageList_Remove (handle, index);
+    System.arraycopy (images, index + 1, images, index, --count - index);
+    images [index] = null;
+}
+
+public int removeRef() {
+    return --refCount;
+}
+
+void set (int index, Image image, int count) {
+    auto hImage = image.handle;
+    int cx , cy ;
+    OS.ImageList_GetIconSize (handle, &cx, &cy);
+    switch (image.type) {
+        case DWT.BITMAP: {
+            /*
+            * Note that the image size has to match the image list icon size.
+            */
+            HBITMAP hBitmap, hMask;
+            ImageData data = image.getImageData ();
+            switch (data.getTransparencyType ()) {
+                case DWT.TRANSPARENCY_ALPHA:
+                    if (OS.COMCTL32_MAJOR >= 6) {
+                        hBitmap = copyWithAlpha (hImage, -1, data.alphaData, cx, cy);
+                    } else {
+                        hBitmap = copyBitmap (hImage, cx, cy);
+                        hMask = createMaskFromAlpha (data, cx, cy);
+                    }
+                    break;
+                case DWT.TRANSPARENCY_PIXEL:
+                    int background = -1;
+                    Color color = image.getBackground ();
+                    if (color !is null) background = color.handle;
+                    hBitmap = copyBitmap (hImage, cx, cy);
+                    hMask = createMask (hImage, cx, cy, background, data.transparentPixel);
+                    break;
+                case DWT.TRANSPARENCY_NONE:
+                default:
+                    hBitmap = copyBitmap (hImage, cx, cy);
+                    if (index !is count) hMask = createMask (hImage, cx, cy, -1, -1);
+                    break;
+            }
+            if (index is count) {
+                OS.ImageList_Add (handle, hBitmap, hMask);
+            } else {
+                /* Note that the mask must always be replaced even for TRANSPARENCY_NONE */
+                OS.ImageList_Replace (handle, index, hBitmap, hMask);
+            }
+            if (hMask !is null) OS.DeleteObject (hMask);
+            if (hBitmap !is hImage) OS.DeleteObject (hBitmap);
+            break;
+        }
+        case DWT.ICON: {
+            if (OS.IsWinCE) {
+                OS.ImageList_ReplaceIcon (handle, index is count ? -1 : index, hImage);
+            } else {
+                auto hIcon = copyIcon (hImage, cx, cy);
+                OS.ImageList_ReplaceIcon (handle, index is count ? -1 : index, hIcon);
+                OS.DestroyIcon (hIcon);
+            }
+            break;
+        }
+    }
+}
+
+public int size () {
+    int result = 0;
+    int count = OS.ImageList_GetImageCount (handle);
+    for (int i=0; i<count; i++) {
+        if (images [i] !is null) {
+            if (images [i].isDisposed ()) images [i] = null;
+            if (images [i] !is null) result++;
+        }
+    }
+    return result;
+}
+
+}
--- a/dwt/internal/win32/OS.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/internal/win32/OS.d	Mon Jan 28 21:05:39 2008 +0100
@@ -3879,13 +3879,16 @@
     alias WINAPI.GetObjectA GetObject;
     alias WINAPI.GetOpenFileNameA GetOpenFileName;
     alias WINAPI.GetProfileStringA _GetProfileString;
+    alias STDWIN.GetPropA GetProp;
     alias WINAPI.GetSaveFileNameA GetSaveFileName;
+    alias STDWIN.GetStartupInfoA GetStartupInfo;
     alias WINAPI.GetTextExtentPoint32A GetTextExtentPoint32;
     alias WINAPI.GetTextMetricsA GetTextMetrics;
     alias WINAPI.GetVersionExA GetVersionEx;
     alias WINAPI.GetWindowLongA GetWindowLong;
     alias WINAPI.GetWindowTextA _GetWindowText;
     alias WINAPI.GetWindowTextLengthA GetWindowTextLength;
+    alias STDWIN.GlobalAddAtomA GlobalAddAtom;
     alias WINAPI.ImmGetCompositionFontA ImmGetCompositionFont;
     alias WINAPI.ImmGetCompositionStringA ImmGetCompositionString;
     alias WINAPI.ImmSetCompositionFontA ImmSetCompositionFont;
@@ -3911,10 +3914,12 @@
     alias WINAPI.RegisterClassA RegisterClass;
     alias WINAPI.RegisterClipboardFormatA RegisterClipboardFormat;
     alias WINAPI.RegisterWindowMessageA RegisterWindowMessage;
+    alias STDWIN.RemovePropA RemoveProp;
     alias WINAPI.SHBrowseForFolderA SHBrowseForFolder;
     alias WINAPI.SHGetPathFromIDListA SHGetPathFromIDList;
     alias WINAPI.SendMessageA SendMessage;
     alias WINAPI.SetMenuItemInfoA SetMenuItemInfo;
+    alias STDWIN.SetPropA SetProp;
     alias WINAPI.SetWindowLongA SetWindowLong;
     alias WINAPI.SetWindowTextA SetWindowText;
     alias WINAPI.SetWindowsHookExA SetWindowsHookEx;
@@ -3971,13 +3976,16 @@
     alias WINAPI.GetObjectW GetObject;
     alias WINAPI.GetOpenFileNameW GetOpenFileName;
     alias WINAPI.GetProfileStringW _GetProfileString;
+    alias STDWIN.GetPropW GetProp;
     alias WINAPI.GetSaveFileNameW GetSaveFileName;
+    alias STDWIN.GetStartupInfoW GetStartupInfo;
     alias WINAPI.GetTextExtentPoint32W GetTextExtentPoint32;
     alias WINAPI.GetTextMetricsW GetTextMetrics;
     alias WINAPI.GetVersionExW GetVersionEx;
     alias WINAPI.GetWindowLongW GetWindowLong;
     alias WINAPI.GetWindowTextW _GetWindowText;
     alias WINAPI.GetWindowTextLengthW GetWindowTextLength;
+    alias STDWIN.GlobalAddAtomW GlobalAddAtom;
     alias WINAPI.ImmGetCompositionFontW ImmGetCompositionFont;
     alias WINAPI.ImmGetCompositionStringW ImmGetCompositionString;
     alias WINAPI.ImmSetCompositionFontW ImmSetCompositionFont;
@@ -4003,6 +4011,7 @@
     alias WINAPI.RegisterClassW RegisterClass;
     alias WINAPI.RegisterClipboardFormatW RegisterClipboardFormat;
     alias WINAPI.RegisterWindowMessageW RegisterWindowMessage;
+    alias STDWIN.RemovePropW RemoveProp;
     alias WINAPI.SHBrowseForFolderW SHBrowseForFolder;
     alias WINAPI.SHGetPathFromIDListW SHGetPathFromIDList;
     alias WINAPI.SendMessageW SendMessage;
@@ -4010,6 +4019,7 @@
     alias WINAPI.SetWindowLongW SetWindowLong;
     alias WINAPI.SetWindowTextW SetWindowText;
     alias WINAPI.SetWindowsHookExW SetWindowsHookEx;
+    alias STDWIN.SetPropW SetProp;
     alias WINAPI.ShellExecuteExW ShellExecuteEx;
     alias WINAPI.Shell_NotifyIconW Shell_NotifyIcon;
     alias WINAPI.StartDocW StartDoc;
@@ -4035,6 +4045,8 @@
 alias STDWIN.BeginPath BeginPath;
 alias WINAPI.BitBlt BitBlt;
 alias WINAPI.BringWindowToTop BringWindowToTop;
+alias WINAPI.BufferedPaintInit BufferedPaintInit;
+alias WINAPI.BufferedPaintUnInit BufferedPaintUnInit;
 alias WINAPI.CallNextHookEx CallNextHookEx;
 alias WINAPI.CallWindowProcA CallWindowProcA;
 alias WINAPI.CallWindowProcW CallWindowProcW;
@@ -4049,6 +4061,7 @@
 alias WINAPI.ChooseFontW ChooseFontW;
 alias WINAPI.ClientToScreen ClientToScreen;
 alias WINAPI.CloseHandle CloseHandle;
+alias WINAPI.CloseThemeData CloseThemeData;
 alias WINAPI.CloseClipboard CloseClipboard;
 alias WINAPI.CombineRgn CombineRgn;
 alias WINAPI.CommDlgExtendedError CommDlgExtendedError;
@@ -4335,6 +4348,7 @@
 alias WINAPI.InvalidateRgn InvalidateRgn;
 alias WINAPI.IsAppThemed IsAppThemed;
 alias WINAPI.IsDBCSLeadByte IsDBCSLeadByte;
+alias WINAPI.IsHungAppWindow IsHungAppWindow;
 alias WINAPI.IsIconic IsIconic;
 alias WINAPI.IsWindow IsWindow;
 alias WINAPI.IsWindowEnabled IsWindowEnabled;
@@ -4372,6 +4386,7 @@
 //alias WINAPI.OleInitialize OleInitialize;
 //alias WINAPI.OleUninitialize OleUninitialize;
 alias WINAPI.OpenClipboard OpenClipboard;
+alias WINAPI.OpenThemeData OpenThemeData;
 alias WINAPI.OutputDebugStringA OutputDebugStringA;
 alias WINAPI.OutputDebugStringW OutputDebugStringW;
 alias WINAPI.PatBlt PatBlt;
@@ -4777,7 +4792,7 @@
     return ret;
 }
 
-public wchar* StrToWCHARz(char[] sc) {
+public wchar* StrToWCHARz(char[] sc, uint* length = null ) {
     return toString16z( StrToWCHARs(sc));
 }
 
--- a/dwt/internal/win32/WINAPI.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/internal/win32/WINAPI.d	Mon Jan 28 21:05:39 2008 +0100
@@ -107,8 +107,18 @@
     LPCRECT pRect
 );
 
-
-
+HTHEME OpenThemeData(
+    HWND hwnd,
+    LPCWSTR pszClassList
+);
+HRESULT BufferedPaintInit();
+HRESULT CloseThemeData(
+    HTHEME hTheme
+);
+HRESULT BufferedPaintUnInit();
+BOOL IsHungAppWindow(
+    HWND hWnd
+);
 }
 
 
--- a/dwt/internal/win32/WINTYPES.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/internal/win32/WINTYPES.d	Mon Jan 28 21:05:39 2008 +0100
@@ -12,8 +12,7 @@
 alias char CHAR;
 alias OPENFILENAME OPENFILENAMEW;
 alias OPENFILENAME OPENFILENAMEA;
-alias WNDCLASS   WNDCLASSA;
-alias WNDCLASSA* LPWNDCLASSA;
+alias WNDCLASS_T   WNDCLASS;
 
 alias TCLSID *REFCLSID;
 
@@ -700,11 +699,11 @@
 struct INPUT {
     // Note: <Shawn> sizeof = 28
     int type;
-//  union {
+  union {
         MOUSEINPUT mi;
-//        KEYBOARDINPUT ki;
+        KEYBDINPUT ki;
 //        HARDWAREINPUT hi;
-//    }
+    }
 }alias INPUT* PINPUT, LPINPUT;
 
 //struct ITEMIDLIST {
@@ -2062,25 +2061,25 @@
 }
 
 // WNDCLASSA is declared in phobos
-struct WNDCLASSW {
-    UINT        style;
-    WNDPROC_I     lpfnWndProc;
-    int         cbClsExtra;
-    int         cbWndExtra;
-    HINSTANCE   hInstance;
-    HICON       hIcon;
-    HCURSOR     hCursor;
-    HBRUSH      hbrBackground;
-    LPCWSTR     lpszMenuName;
-    LPCWSTR     lpszClassName;
-}alias WNDCLASSW* PWNDCLASSW, LPWNDCLASSW;
-
-// since phobos has alias WNDCLASSA to WNDCLASS, we have to alias it another name
-version(ANSI){
-    alias WNDCLASSA WNDCLASS_T;
-}else{
-    alias WNDCLASSW WNDCLASS_T;
-}
+// struct WNDCLASSW {
+//     UINT        style;
+//     WNDPROC_I     lpfnWndProc;
+//     int         cbClsExtra;
+//     int         cbWndExtra;
+//     HINSTANCE   hInstance;
+//     HICON       hIcon;
+//     HCURSOR     hCursor;
+//     HBRUSH      hbrBackground;
+//     LPCWSTR     lpszMenuName;
+//     LPCWSTR     lpszClassName;
+// }alias WNDCLASSW* PWNDCLASSW, LPWNDCLASSW;
+//
+// // since phobos has alias WNDCLASSA to WNDCLASS, we have to alias it another name
+// version(ANSI){
+//     alias WNDCLASSA WNDCLASS_T;
+// }else{
+//     alias WNDCLASSW WNDCLASS_T;
+// }
 
 }   // end of extern(Windows)
 
--- a/dwt/widgets/Composite.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/widgets/Composite.d	Mon Jan 28 21:05:39 2008 +0100
@@ -14,9 +14,15 @@
 
 import dwt.widgets.Scrollable;
 import dwt.widgets.Control;
+import dwt.graphics.Font;
 
 class Composite : Scrollable {
 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[]) ;
 }
 /++
 import dwt.DWT;
--- a/dwt/widgets/Control.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/widgets/Control.d	Mon Jan 28 21:05:39 2008 +0100
@@ -14,6 +14,8 @@
 
 import dwt.widgets.Widget;
 import dwt.widgets.Composite;
+import dwt.widgets.Event;
+import dwt.widgets.Shell;
 import dwt.graphics.Drawable;
 import dwt.graphics.Rectangle;
 import dwt.graphics.Point;
@@ -21,6 +23,7 @@
 import dwt.internal.win32.OS;
 
 class Control : Widget, Drawable {
+    public HANDLE handle;
     this();
     this( Widget, int );
 public HDC internal_new_GC (GCData data) ;
@@ -35,6 +38,17 @@
 void setBounds (int x, int y, int width, int height, int flags) ;
 void setBounds (int x, int y, int width, int height, int flags, bool defer) ;
 public void setBounds (Rectangle rect) ;
+Shell getShell();
+bool checkHandle (HWND hwnd) ;
+bool translateAccelerator (MSG* msg) ;
+bool translateMnemonic (Event event, Control control) ;
+bool translateMnemonic (MSG* msg) ;
+bool translateTraversal (MSG* msg) ;
+public void update () ;
+void update (bool all) ;
+void updateImages () ;
+int windowProc (HWND hwnd, int msg, int wParam, int lParam) ;
+
 }
 /++
 import dwt.DWT;
@@ -3281,7 +3295,7 @@
     return handle;
 }
 
-bool translateAccelerator (MSG msg) {
+bool translateAccelerator (MSG* msg) {
     return menuShell ().translateAccelerator (msg);
 }
 
@@ -3292,7 +3306,7 @@
     return traverse (event);
 }
 
-bool translateMnemonic (MSG msg) {
+bool translateMnemonic (MSG* msg) {
     if (msg.wParam < 0x20) return false;
     int hwnd = msg.hwnd;
     if (OS.GetKeyState (OS.VK_MENU) >= 0) {
@@ -3313,7 +3327,7 @@
     return false;
 }
 
-bool translateTraversal (MSG msg) {
+bool translateTraversal (MSG* msg) {
     int hwnd = msg.hwnd;
     int key = msg.wParam;
     if (key is OS.VK_MENU) {
--- a/dwt/widgets/Decorations.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/widgets/Decorations.d	Mon Jan 28 21:05:39 2008 +0100
@@ -14,6 +14,7 @@
 
 import dwt.widgets.Canvas;
 class Decorations : Canvas {
+void bringToTop () ;
 }
 /++
 import dwt.DWT;
--- a/dwt/widgets/Display.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/widgets/Display.d	Mon Jan 28 21:05:39 2008 +0100
@@ -12,14 +12,7 @@
  *******************************************************************************/
 module dwt.widgets.Display;
 
-import dwt.graphics.Device;
-import dwt.widgets.Control;
-import dwt.widgets.Tray;
-import dwt.widgets.Event;
-import dwt.internal.win32.OS;
-
-import tango.core.Thread;
-
+/+
 class Display : Device {
     RECT clickRect;
     int clickCount, lastTime, lastButton, lastClickHwnd;
@@ -52,7 +45,7 @@
 int controlKey (int key) ;
 HTHEME hEditTheme () ;
 }
-/++
++/
 import dwt.DWT;
 import dwt.DWTError;
 import dwt.DWTException;
@@ -70,29 +63,32 @@
 import dwt.graphics.RGB;
 import dwt.graphics.Rectangle;
 import dwt.graphics.Resource;
-import dwt.internal.Callback;
 import dwt.internal.ImageList;
-import dwt.internal.win32.BITMAP;
-import dwt.internal.win32.BITMAPINFOHEADER;
-import dwt.internal.win32.HIGHCONTRAST;
-import dwt.internal.win32.ICONINFO;
-import dwt.internal.win32.INPUT;
-import dwt.internal.win32.KEYBDINPUT;
-import dwt.internal.win32.LOGFONT;
-import dwt.internal.win32.LOGFONTA;
-import dwt.internal.win32.LOGFONTW;
-import dwt.internal.win32.MONITORINFO;
-import dwt.internal.win32.MOUSEINPUT;
-import dwt.internal.win32.MSG;
-import dwt.internal.win32.NONCLIENTMETRICS;
-import dwt.internal.win32.NONCLIENTMETRICSA;
-import dwt.internal.win32.NONCLIENTMETRICSW;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.POINT;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.STARTUPINFO;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.WNDCLASS;
+
+import dwt.widgets.Control;
+import dwt.widgets.Tray;
+import dwt.widgets.Event;
+import dwt.widgets.EventTable;
+import dwt.widgets.Menu;
+import dwt.widgets.MenuItem;
+import dwt.widgets.Synchronizer;
+import dwt.widgets.Monitor;
+import dwt.widgets.Shell;
+import dwt.widgets.Listener;
+import dwt.widgets.Widget;
+import dwt.widgets.TrayItem;
+
+import dwt.dwthelper.utils;
+import dwt.dwthelper.Runnable;
+import dwt.dwthelper.System;
+import dwt.dwthelper.Integer;
+import tango.core.Thread;
+import tango.stdc.stringz;
+import tango.util.Convert;
+static import tango.text.convert.Utf;
+static import tango.text.Text;
+alias tango.text.Text.Text!(char) StringBuffer;
 
 /**
  * Instances of this class are responsible for managing the
@@ -170,7 +166,7 @@
  * @see Device#dispose
  */
 
-public class Display extends Device {
+public class Display : Device {
 
     /**
      * the handle to the OS message queue
@@ -182,29 +178,32 @@
      * platforms and should never be accessed from application code.
      * </p>
      */
-    public MSG msg = new MSG ();
+    public MSG msg;
 
     /* Windows and Events */
     Event [] eventQueue;
-    Callback windowCallback;
-    int windowProc, threadId;
-    TCHAR windowClass, windowShadowClass;
+    //Callback windowCallback;
+    //int windowProc_;
+    int threadId;
+    TCHAR* windowClass, windowShadowClass;
     static int WindowClassCount;
-    static final String WindowName = "SWT_Window"; //$NON-NLS-1$
-    static final String WindowShadowName = "SWT_WindowShadow"; //$NON-NLS-1$
+    static const char[] WindowName = "SWT_Window"; //$NON-NLS-1$
+    static const char[] WindowShadowName = "SWT_WindowShadow"; //$NON-NLS-1$
     EventTable eventTable, filterTable;
 
     /* Widget Table */
     int [] indexTable;
     Control lastControl, lastGetControl;
-    int freeSlot, lastHwnd, lastGetHwnd;
+    int freeSlot;
+    HANDLE lastHwnd;
+    HWND lastGetHwnd;
     Control [] controlTable;
-    static final int GROW_SIZE = 1024;
-    static final int SWT_OBJECT_INDEX;
-    static final bool USE_PROPERTY = !OS.IsWinCE;
-    static {
-        if (USE_PROPERTY) {
-            SWT_OBJECT_INDEX = OS.GlobalAddAtom (new TCHAR (0, "SWT_OBJECT_INDEX", true)); //$NON-NLS-1$
+    static const int GROW_SIZE = 1024;
+    static const int SWT_OBJECT_INDEX;
+    static const bool USE_PROPERTY = !OS.IsWinCE;
+    static this() {
+        static if (USE_PROPERTY) {
+            SWT_OBJECT_INDEX = OS.GlobalAddAtom (StrToTCHARz( "SWT_OBJECT_INDEX")); //$NON-NLS-1$
         } else {
             SWT_OBJECT_INDEX = 0;
         }
@@ -212,24 +211,24 @@
 
     /* Startup info */
     static STARTUPINFO lpStartupInfo;
-    static {
-        if (!OS.IsWinCE) {
-            lpStartupInfo = new STARTUPINFO ();
+    static this() {
+        static if (!OS.IsWinCE) {
+            //lpStartupInfo = new STARTUPINFO ();
             lpStartupInfo.cb = STARTUPINFO.sizeof;
-            OS.GetStartupInfo (lpStartupInfo);
+            OS.GetStartupInfo (&lpStartupInfo);
         }
     }
 
     /* XP Themes */
-    int hButtonTheme, hEditTheme, hExplorerBarTheme, hScrollBarTheme, hTabTheme;
-    static final char [] BUTTON = new char [] {'B', 'U', 'T', 'T', 'O', 'N', 0};
-    static final char [] EDIT = new char [] {'E', 'D', 'I', 'T', 0};
-    static final char [] EXPLORER = new char [] {'E', 'X', 'P', 'L', 'O', 'R', 'E', 'R', 0};
-    static final char [] EXPLORERBAR = new char [] {'E', 'X', 'P', 'L', 'O', 'R', 'E', 'R', 'B', 'A', 'R', 0};
-    static final char [] SCROLLBAR = new char [] {'S', 'C', 'R', 'O', 'L', 'L', 'B', 'A', 'R', 0};
-    static final char [] LISTVIEW = new char [] {'L', 'I', 'S', 'T', 'V', 'I', 'E', 'W', 0};
-    static final char [] TAB = new char [] {'T', 'A', 'B', 0};
-    static final char [] TREEVIEW = new char [] {'T', 'R', 'E', 'E', 'V', 'I', 'E', 'W', 0};
+    HTHEME hButtonTheme_, hEditTheme_, hExplorerBarTheme_, hScrollBarTheme_, hTabTheme_;
+    static const wchar [] BUTTON = "BUTTON\0"w;
+    static const wchar [] EDIT = "EDIT\0"w;
+    static const wchar [] EXPLORER = "EXPLORER\0"w;
+    static const wchar [] EXPLORERBAR = "EXPLORERBAR\0"w;
+    static const wchar [] SCROLLBAR = "SCROLLBAR\0"w;
+    static const wchar [] LISTVIEW = "LISTVIEW\0"w;
+    static const wchar [] TAB = "TAB\0"w;
+    static const wchar [] TREEVIEW = "TREEVIEW\0"w;
 
     /* Focus */
     int focusEvent;
@@ -246,29 +245,34 @@
     * The SmartPhone DWT resource file reserves
     * the values 101..107.
     */
-    static final int ID_START = 108;
+    static const int ID_START = 108;
 
     /* Filter Hook */
-    Callback msgFilterCallback;
-    int msgFilterProc, filterHook;
-    MSG hookMsg = new MSG ();
+    //Callback msgFilterCallback;
+    //int msgFilterProc_,
+    HHOOK filterHook;
+    MSG hookMsg;
     bool runDragDrop = true;
 
     /* Idle Hook */
-    Callback foregroundIdleCallback;
-    int foregroundIdleProc, idleHook;
+    //Callback foregroundIdleCallback;
+    //int foregroundIdleProc_;
+    HHOOK idleHook;
 
     /* Message Hook and Embedding */
     bool ignoreNextKey;
-    Callback getMsgCallback, embeddedCallback;
-    int getMsgProc, msgHook, embeddedHwnd, embeddedProc;
-    static final String AWT_WINDOW_CLASS = "SunAwtWindow";
-    static final short [] ACCENTS = new short [] {'~', '`', '\'', '^', '"'};
+    //Callback getMsgCallback, embeddedCallback;
+    int getMsgProc_;
+    HHOOK msgHook;
+    HWND embeddedHwnd;
+    int embeddedProc_;
+    static const char[] AWT_WINDOW_CLASS = "SunAwtWindow";
+    static const short [] ACCENTS = [ cast(short) '~', '`', '\'', '^', '"'];
 
     /* Sync/Async Widget Communication */
-    Synchronizer synchronizer = new Synchronizer (this);
+    Synchronizer synchronizer;
     bool runMessages = true, runMessagesInIdle = false;
-    static final String RUN_MESSAGES_IN_IDLE_KEY = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$
+    static const char[] RUN_MESSAGES_IN_IDLE_KEY = "org.eclipse.swt.internal.win32.runMessagesInIdle"; //$NON-NLS-1$
     Thread thread;
 
     /* Display Shutdown */
@@ -282,15 +286,16 @@
     int [] timerIds;
     Runnable [] timerList;
     int nextTimerId = SETTINGS_ID + 1;
-    static final int SETTINGS_ID = 100;
-    static final int SETTINGS_DELAY = 2000;
+    static const int SETTINGS_ID = 100;
+    static const int SETTINGS_DELAY = 2000;
 
     /* Keyboard and Mouse */
     RECT clickRect;
-    int clickCount, lastTime, lastButton, lastClickHwnd;
+    int clickCount, lastTime, lastButton;
+    HWND lastClickHwnd;
     int lastKey, lastAscii, lastMouse;
     bool lastVirtual, lastNull, lastDead;
-    byte [] keyboard = new byte [256];
+    ubyte [256] keyboard;
     bool accelKeyHit, mnemonicKeyHit;
     bool lockActiveWindow, captureChanged, xMouse;
 
@@ -303,22 +308,23 @@
     int lastHittest;
 
     /* Message Only Window */
-    Callback messageCallback;
-    int hwndMessage, messageProc;
+    //Callback messageCallback;
+    HWND hwndMessage;
+    int messageProc_;
 
     /* System Resources */
-    LOGFONT lfSystemFont;
+    LOGFONT* lfSystemFont;
     Font systemFont;
     Image errorImage, infoImage, questionImage, warningIcon;
-    Cursor [] cursors = new Cursor [DWT.CURSOR_HAND + 1];
+    Cursor [] cursors;
     Resource [] resources;
-    static final int RESOURCE_SIZE = 1 + 4 + DWT.CURSOR_HAND + 1;
+    static const int RESOURCE_SIZE = 1 + 4 + DWT.CURSOR_HAND + 1;
 
     /* ImageList Cache */
     ImageList[] imageList, toolImageList, toolHotImageList, toolDisabledImageList;
 
     /* Custom Colors for ChooseColor */
-    int lpCustColors;
+    COLORREF* lpCustColors;
 
     /* Sort Indicators */
     Image upArrow, downArrow;
@@ -328,95 +334,95 @@
 
     /* Display Data */
     Object data;
-    String [] keys;
+    char[] [] keys;
     Object [] values;
 
     /* Key Mappings */
-    static final int [] [] KeyTable = {
+    static const int [] [] KeyTable = [
 
         /* Keyboard and Mouse Masks */
-        {OS.VK_MENU,    DWT.ALT},
-        {OS.VK_SHIFT,   DWT.SHIFT},
-        {OS.VK_CONTROL, DWT.CONTROL},
-//      {OS.VK_????,    DWT.COMMAND},
+        [OS.VK_MENU,    DWT.ALT],
+        [OS.VK_SHIFT,   DWT.SHIFT],
+        [OS.VK_CONTROL, DWT.CONTROL],
+//      [OS.VK_????,    DWT.COMMAND],
 
         /* NOT CURRENTLY USED */
-//      {OS.VK_LBUTTON, DWT.BUTTON1},
-//      {OS.VK_MBUTTON, DWT.BUTTON3},
-//      {OS.VK_RBUTTON, DWT.BUTTON2},
+//      [OS.VK_LBUTTON, DWT.BUTTON1],
+//      [OS.VK_MBUTTON, DWT.BUTTON3],
+//      [OS.VK_RBUTTON, DWT.BUTTON2],
 
         /* Non-Numeric Keypad Keys */
-        {OS.VK_UP,      DWT.ARROW_UP},
-        {OS.VK_DOWN,    DWT.ARROW_DOWN},
-        {OS.VK_LEFT,    DWT.ARROW_LEFT},
-        {OS.VK_RIGHT,   DWT.ARROW_RIGHT},
-        {OS.VK_PRIOR,   DWT.PAGE_UP},
-        {OS.VK_NEXT,    DWT.PAGE_DOWN},
-        {OS.VK_HOME,    DWT.HOME},
-        {OS.VK_END,     DWT.END},
-        {OS.VK_INSERT,  DWT.INSERT},
+        [OS.VK_UP,      DWT.ARROW_UP],
+        [OS.VK_DOWN,    DWT.ARROW_DOWN],
+        [OS.VK_LEFT,    DWT.ARROW_LEFT],
+        [OS.VK_RIGHT,   DWT.ARROW_RIGHT],
+        [OS.VK_PRIOR,   DWT.PAGE_UP],
+        [OS.VK_NEXT,    DWT.PAGE_DOWN],
+        [OS.VK_HOME,    DWT.HOME],
+        [OS.VK_END,     DWT.END],
+        [OS.VK_INSERT,  DWT.INSERT],
 
         /* Virtual and Ascii Keys */
-        {OS.VK_BACK,    DWT.BS},
-        {OS.VK_RETURN,  DWT.CR},
-        {OS.VK_DELETE,  DWT.DEL},
-        {OS.VK_ESCAPE,  DWT.ESC},
-        {OS.VK_RETURN,  DWT.LF},
-        {OS.VK_TAB,     DWT.TAB},
+        [OS.VK_BACK,    DWT.BS],
+        [OS.VK_RETURN,  DWT.CR],
+        [OS.VK_DELETE,  DWT.DEL],
+        [OS.VK_ESCAPE,  DWT.ESC],
+        [OS.VK_RETURN,  DWT.LF],
+        [OS.VK_TAB,     DWT.TAB],
 
         /* Functions Keys */
-        {OS.VK_F1,  DWT.F1},
-        {OS.VK_F2,  DWT.F2},
-        {OS.VK_F3,  DWT.F3},
-        {OS.VK_F4,  DWT.F4},
-        {OS.VK_F5,  DWT.F5},
-        {OS.VK_F6,  DWT.F6},
-        {OS.VK_F7,  DWT.F7},
-        {OS.VK_F8,  DWT.F8},
-        {OS.VK_F9,  DWT.F9},
-        {OS.VK_F10, DWT.F10},
-        {OS.VK_F11, DWT.F11},
-        {OS.VK_F12, DWT.F12},
-        {OS.VK_F13, DWT.F13},
-        {OS.VK_F14, DWT.F14},
-        {OS.VK_F15, DWT.F15},
+        [OS.VK_F1,  DWT.F1],
+        [OS.VK_F2,  DWT.F2],
+        [OS.VK_F3,  DWT.F3],
+        [OS.VK_F4,  DWT.F4],
+        [OS.VK_F5,  DWT.F5],
+        [OS.VK_F6,  DWT.F6],
+        [OS.VK_F7,  DWT.F7],
+        [OS.VK_F8,  DWT.F8],
+        [OS.VK_F9,  DWT.F9],
+        [OS.VK_F10, DWT.F10],
+        [OS.VK_F11, DWT.F11],
+        [OS.VK_F12, DWT.F12],
+        [OS.VK_F13, DWT.F13],
+        [OS.VK_F14, DWT.F14],
+        [OS.VK_F15, DWT.F15],
 
         /* Numeric Keypad Keys */
-        {OS.VK_MULTIPLY,    DWT.KEYPAD_MULTIPLY},
-        {OS.VK_ADD,         DWT.KEYPAD_ADD},
-        {OS.VK_RETURN,      DWT.KEYPAD_CR},
-        {OS.VK_SUBTRACT,    DWT.KEYPAD_SUBTRACT},
-        {OS.VK_DECIMAL,     DWT.KEYPAD_DECIMAL},
-        {OS.VK_DIVIDE,      DWT.KEYPAD_DIVIDE},
-        {OS.VK_NUMPAD0,     DWT.KEYPAD_0},
-        {OS.VK_NUMPAD1,     DWT.KEYPAD_1},
-        {OS.VK_NUMPAD2,     DWT.KEYPAD_2},
-        {OS.VK_NUMPAD3,     DWT.KEYPAD_3},
-        {OS.VK_NUMPAD4,     DWT.KEYPAD_4},
-        {OS.VK_NUMPAD5,     DWT.KEYPAD_5},
-        {OS.VK_NUMPAD6,     DWT.KEYPAD_6},
-        {OS.VK_NUMPAD7,     DWT.KEYPAD_7},
-        {OS.VK_NUMPAD8,     DWT.KEYPAD_8},
-        {OS.VK_NUMPAD9,     DWT.KEYPAD_9},
-//      {OS.VK_????,        DWT.KEYPAD_EQUAL},
+        [OS.VK_MULTIPLY,    DWT.KEYPAD_MULTIPLY],
+        [OS.VK_ADD,         DWT.KEYPAD_ADD],
+        [OS.VK_RETURN,      DWT.KEYPAD_CR],
+        [OS.VK_SUBTRACT,    DWT.KEYPAD_SUBTRACT],
+        [OS.VK_DECIMAL,     DWT.KEYPAD_DECIMAL],
+        [OS.VK_DIVIDE,      DWT.KEYPAD_DIVIDE],
+        [OS.VK_NUMPAD0,     DWT.KEYPAD_0],
+        [OS.VK_NUMPAD1,     DWT.KEYPAD_1],
+        [OS.VK_NUMPAD2,     DWT.KEYPAD_2],
+        [OS.VK_NUMPAD3,     DWT.KEYPAD_3],
+        [OS.VK_NUMPAD4,     DWT.KEYPAD_4],
+        [OS.VK_NUMPAD5,     DWT.KEYPAD_5],
+        [OS.VK_NUMPAD6,     DWT.KEYPAD_6],
+        [OS.VK_NUMPAD7,     DWT.KEYPAD_7],
+        [OS.VK_NUMPAD8,     DWT.KEYPAD_8],
+        [OS.VK_NUMPAD9,     DWT.KEYPAD_9],
+//      [OS.VK_????,        DWT.KEYPAD_EQUAL],
 
         /* Other keys */
-        {OS.VK_CAPITAL,     DWT.CAPS_LOCK},
-        {OS.VK_NUMLOCK,     DWT.NUM_LOCK},
-        {OS.VK_SCROLL,      DWT.SCROLL_LOCK},
-        {OS.VK_PAUSE,       DWT.PAUSE},
-        {OS.VK_CANCEL,      DWT.BREAK},
-        {OS.VK_SNAPSHOT,    DWT.PRINT_SCREEN},
-//      {OS.VK_????,        DWT.HELP},
-
-    };
+        [OS.VK_CAPITAL,     DWT.CAPS_LOCK],
+        [OS.VK_NUMLOCK,     DWT.NUM_LOCK],
+        [OS.VK_SCROLL,      DWT.SCROLL_LOCK],
+        [OS.VK_PAUSE,       DWT.PAUSE],
+        [OS.VK_CANCEL,      DWT.BREAK],
+        [OS.VK_SNAPSHOT,    DWT.PRINT_SCREEN],
+//      [OS.VK_????,        DWT.HELP],
+
+    ];
 
     /* Multiple Displays */
     static Display Default;
-    static Display [] Displays = new Display [4];
+    static Display [] Displays;
 
     /* Multiple Monitors */
-    Monitor[] monitors = null;
+    dwt.widgets.Monitor.Monitor[] monitors = null;
     int monitorCount = 0;
 
     /* Modality */
@@ -425,13 +431,13 @@
     static bool TrimEnabled = false;
 
     /* Private DWT Window Messages */
-    static final int SWT_GETACCELCOUNT  = OS.WM_APP;
-    static final int SWT_GETACCEL       = OS.WM_APP + 1;
-    static final int SWT_KEYMSG         = OS.WM_APP + 2;
-    static final int SWT_DESTROY        = OS.WM_APP + 3;
-    static final int SWT_TRAYICONMSG    = OS.WM_APP + 4;
-    static final int SWT_NULL           = OS.WM_APP + 5;
-    static final int SWT_RUNASYNC       = OS.WM_APP + 6;
+    static const int SWT_GETACCELCOUNT  = OS.WM_APP;
+    static const int SWT_GETACCEL       = OS.WM_APP + 1;
+    static const int SWT_KEYMSG         = OS.WM_APP + 2;
+    static const int SWT_DESTROY        = OS.WM_APP + 3;
+    static const int SWT_TRAYICONMSG    = OS.WM_APP + 4;
+    static const int SWT_NULL           = OS.WM_APP + 5;
+    static const int SWT_RUNASYNC       = OS.WM_APP + 6;
     static int SWT_TASKBARCREATED;
     static int SWT_RESTORECARET;
 
@@ -439,7 +445,7 @@
     int hitCount;
 
     /* Package Name */
-    static final String PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
+    static const char[] PACKAGE_PREFIX = "org.eclipse.swt.widgets."; //$NON-NLS-1$
     /*
     * This code is intentionally commented.  In order
     * to support CLDC, .class cannot be used because
@@ -447,7 +453,7 @@
     * they are targeted for CLDC.
     */
 //  static {
-//      String name = Display.class.getName ();
+//      char[] name = Display.class.getName ();
 //      int index = name.lastIndexOf ('.');
 //      PACKAGE_PREFIX = name.substring (0, index + 1);
 //  }
@@ -457,8 +463,8 @@
     * gets the current display. This code will
     * be removed in the future.
     */
-    static {
-        DeviceFinder = new Runnable () {
+    static this () {
+        DeviceFinder = new class() Runnable {
             public void run () {
                 Device device = getCurrent ();
                 if (device is null) {
@@ -495,7 +501,7 @@
  * @see Widget#checkSubclass
  * @see Shell
  */
-public Display () {
+public this () {
     this (null);
 }
 
@@ -504,8 +510,10 @@
  *
  * @param data the device data
  */
-public Display (DeviceData data) {
+public this (DeviceData data) {
     super (data);
+    synchronizer = new Synchronizer (this);
+    cursors = new Cursor [DWT.CURSOR_HAND + 1];
 }
 
 Control _getFocusControl () {
@@ -514,38 +522,38 @@
 
 void addBar (Menu menu) {
     if (bars is null) bars = new Menu [4];
-    int length = bars.length;
-    for (int i=0; i<length; i++) {
+    int length_ = bars.length;
+    for (int i=0; i<length_; i++) {
         if (bars [i] is menu) return;
     }
     int index = 0;
-    while (index < length) {
+    while (index < length_) {
         if (bars [index] is null) break;
         index++;
     }
-    if (index is length) {
-        Menu [] newBars = new Menu [length + 4];
-        System.arraycopy (bars, 0, newBars, 0, length);
+    if (index is length_) {
+        Menu [] newBars = new Menu [length_ + 4];
+        System.arraycopy (bars, 0, newBars, 0, length_);
         bars = newBars;
     }
     bars [index] = menu;
 }
 
-void addControl (int handle, Control control) {
-    if (handle is 0) return;
+void addControl (HANDLE handle, Control control) {
+    if (handle is null) return;
     if (freeSlot is -1) {
-        int length = (freeSlot = indexTable.length) + GROW_SIZE;
-        int [] newIndexTable = new int [length];
-        Control [] newControlTable = new Control [length];
+        int length_ = (freeSlot = indexTable.length) + GROW_SIZE;
+        int [] newIndexTable = new int [length_];
+        Control [] newControlTable = new Control [length_];
         System.arraycopy (indexTable, 0, newIndexTable, 0, freeSlot);
         System.arraycopy (controlTable, 0, newControlTable, 0, freeSlot);
-        for (int i=freeSlot; i<length-1; i++) newIndexTable [i] = i + 1;
-        newIndexTable [length - 1] = -1;
+        for (int i=freeSlot; i<length_-1; i++) newIndexTable [i] = i + 1;
+        newIndexTable [length_ - 1] = -1;
         indexTable = newIndexTable;
         controlTable = newControlTable;
     }
-    if (USE_PROPERTY) {
-        OS.SetProp (handle, SWT_OBJECT_INDEX, freeSlot + 1);
+    static if (USE_PROPERTY) {
+        OS.SetProp (handle, cast(wchar*)SWT_OBJECT_INDEX, cast(void*) freeSlot + 1);
     } else {
         OS.SetWindowLong (handle, OS.GWL_USERDATA, freeSlot + 1);
     }
@@ -647,18 +655,18 @@
 
 void addPopup (Menu menu) {
     if (popups is null) popups = new Menu [4];
-    int length = popups.length;
-    for (int i=0; i<length; i++) {
+    int length_ = popups.length;
+    for (int i=0; i<length_; i++) {
         if (popups [i] is menu) return;
     }
     int index = 0;
-    while (index < length) {
+    while (index < length_) {
         if (popups [index] is null) break;
         index++;
     }
-    if (index is length) {
-        Menu [] newPopups = new Menu [length + 4];
-        System.arraycopy (popups, 0, newPopups, 0, length);
+    if (index is length_) {
+        Menu [] newPopups = new Menu [length_ + 4];
+        System.arraycopy (popups, 0, newPopups, 0, length_);
         popups = newPopups;
     }
     popups [index] = menu;
@@ -669,12 +677,12 @@
 
     /* Get the current keyboard. */
     for (int i=0; i<keyboard.length; i++) keyboard [i] = 0;
-    if (!OS.GetKeyboardState (keyboard)) return 0;
+    if (!OS.GetKeyboardState (keyboard.ptr)) return 0;
 
     /* Translate the key to ASCII or UNICODE using the virtual keyboard */
-    if (OS.IsUnicode) {
-        char [] result = new char [1];
-        if (OS.ToUnicode (key, key, keyboard, result, 1, 0) is 1) return result [0];
+    static if (OS.IsUnicode) {
+        wchar result;
+        if (OS.ToUnicode (key, key, keyboard.ptr, &result, 1, 0) is 1) return result;
     } else {
         short [] result = new short [1];
         if (OS.ToAscii (key, key, keyboard, result, 0) is 1) return result [0];
@@ -736,12 +744,12 @@
  * @see Widget#checkSubclass
  */
 protected void checkSubclass () {
-    if (!isValidClass (getClass ())) error (DWT.ERROR_INVALID_SUBCLASS);
+    //if (!isValidClass (getClass ())) error (DWT.ERROR_INVALID_SUBCLASS);
 }
 
 protected void checkDevice () {
     if (thread is null) error (DWT.ERROR_WIDGET_DISPOSED);
-    if (thread !is Thread.currentThread ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
+    if (thread !is Thread.getThis ()) error (DWT.ERROR_THREAD_INVALID_ACCESS);
     if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
 }
 
@@ -756,22 +764,22 @@
 
 void clearModal (Shell shell) {
     if (modalShells is null) return;
-    int index = 0, length = modalShells.length;
-    while (index < length) {
+    int index = 0, length_ = modalShells.length;
+    while (index < length_) {
         if (modalShells [index] is shell) break;
         if (modalShells [index] is null) return;
         index++;
     }
-    if (index is length) return;
-    System.arraycopy (modalShells, index + 1, modalShells, index, --length - index);
-    modalShells [length] = null;
+    if (index is length_) return;
+    System.arraycopy (modalShells, index + 1, modalShells, index, --length_ - index);
+    modalShells [length_] = null;
     if (index is 0 && modalShells [0] is null) modalShells = null;
     Shell [] shells = getShells ();
     for (int i=0; i<shells.length; i++) shells [i].updateModal ();
 }
 
 int controlKey (int key) {
-    int upper = OS.CharUpper ((short) key);
+    int upper = cast(int)OS.CharUpper (cast(wchar*) key);
     if (64 <= upper && upper <= 95) return upper & 0xBF;
     return key;
 }
@@ -810,7 +818,7 @@
  */
 protected void create (DeviceData data) {
     checkSubclass ();
-    checkDisplay (thread = Thread.currentThread (), true);
+    checkDisplay (thread = Thread.getThis (), true);
     createDisplay (data);
     register (this);
     if (Default is null) Default = this;
@@ -819,13 +827,15 @@
 void createDisplay (DeviceData data) {
 }
 
-static int create32bitDIB (Image image) {
-    int transparentPixel = -1, alpha = -1, hMask = 0, hBitmap = 0;
+static HBITMAP create32bitDIB (Image image) {
+    int transparentPixel = -1, alpha = -1;
+    HBITMAP hMask;
+    HBITMAP hBitmap;
     byte[] alphaData = null;
     switch (image.type) {
         case DWT.ICON:
-            ICONINFO info = new ICONINFO ();
-            OS.GetIconInfo (image.handle, info);
+            ICONINFO info;
+            OS.GetIconInfo (image.handle, &info);
             hBitmap = info.hbmColor;
             hMask = info.hbmMask;
             break;
@@ -837,69 +847,68 @@
             transparentPixel = data.transparentPixel;
             break;
     }
-    BITMAP bm = new BITMAP ();
-    OS.GetObject (hBitmap, BITMAP.sizeof, bm);
+    BITMAP bm;
+    OS.GetObject (hBitmap, BITMAP.sizeof, &bm);
     int imgWidth = bm.bmWidth;
     int imgHeight = bm.bmHeight;
-    int hDC = OS.GetDC (0);
-    int srcHdc = OS.CreateCompatibleDC (hDC);
-    int oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
-    int memHdc = OS.CreateCompatibleDC (hDC);
-    BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER ();
+    auto hDC = OS.GetDC (null);
+    auto srcHdc = OS.CreateCompatibleDC (hDC);
+    auto oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
+    auto memHdc = OS.CreateCompatibleDC (hDC);
+    BITMAPINFOHEADER bmiHeader;
     bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
     bmiHeader.biWidth = imgWidth;
     bmiHeader.biHeight = -imgHeight;
     bmiHeader.biPlanes = 1;
-    bmiHeader.biBitCount = (short)32;
+    bmiHeader.biBitCount = cast(short)32;
     bmiHeader.biCompression = OS.BI_RGB;
     byte [] bmi = new byte [BITMAPINFOHEADER.sizeof];
-    OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
-    int [] pBits = new int [1];
-    int memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
-    if (memDib is 0) DWT.error (DWT.ERROR_NO_HANDLES);
-    int oldMemBitmap = OS.SelectObject (memHdc, memDib);
-    BITMAP dibBM = new BITMAP ();
-    OS.GetObject (memDib, BITMAP.sizeof, dibBM);
+    bmi[ 0 .. BITMAPINFOHEADER.sizeof ] = (cast(byte*)&bmiHeader)[ 0 .. BITMAPINFOHEADER.sizeof ];
+    int[1] pBits;
+    auto memDib = OS.CreateDIBSection (null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, pBits.ptr, null, 0);
+    if (memDib is null) DWT.error (DWT.ERROR_NO_HANDLES);
+    auto oldMemBitmap = OS.SelectObject (memHdc, memDib);
+    BITMAP dibBM;
+    OS.GetObject (memDib, BITMAP.sizeof, &dibBM);
     int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
     OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
     byte red = 0, green = 0, blue = 0;
     if (transparentPixel !is -1) {
         if (bm.bmBitsPixel <= 8) {
-            byte [] color = new byte [4];
-            OS.GetDIBColorTable (srcHdc, transparentPixel, 1, color);
+            byte [4] color;
+            OS.GetDIBColorTable (srcHdc, transparentPixel, 1, cast(RGBQUAD*)color.ptr);
             blue = color [0];
             green = color [1];
             red = color [2];
         } else {
             switch (bm.bmBitsPixel) {
                 case 16:
-                    blue = (byte)((transparentPixel & 0x1F) << 3);
-                    green = (byte)((transparentPixel & 0x3E0) >> 2);
-                    red = (byte)((transparentPixel & 0x7C00) >> 7);
+                    blue = cast(byte)((transparentPixel & 0x1F) << 3);
+                    green = cast(byte)((transparentPixel & 0x3E0) >> 2);
+                    red = cast(byte)((transparentPixel & 0x7C00) >> 7);
                     break;
                 case 24:
-                    blue = (byte)((transparentPixel & 0xFF0000) >> 16);
-                    green = (byte)((transparentPixel & 0xFF00) >> 8);
-                    red = (byte)(transparentPixel & 0xFF);
+                    blue = cast(byte)((transparentPixel & 0xFF0000) >> 16);
+                    green = cast(byte)((transparentPixel & 0xFF00) >> 8);
+                    red = cast(byte)(transparentPixel & 0xFF);
                     break;
                 case 32:
-                    blue = (byte)((transparentPixel & 0xFF000000) >>> 24);
-                    green = (byte)((transparentPixel & 0xFF0000) >> 16);
-                    red = (byte)((transparentPixel & 0xFF00) >> 8);
+                    blue = cast(byte)((transparentPixel & 0xFF000000) >>> 24);
+                    green = cast(byte)((transparentPixel & 0xFF0000) >> 16);
+                    red = cast(byte)((transparentPixel & 0xFF00) >> 8);
                     break;
             }
         }
     }
-    byte [] srcData = new byte [sizeInBytes];
-    OS.MoveMemory (srcData, pBits [0], sizeInBytes);
-    if (hMask !is 0) {
+    byte [] srcData = (cast(byte*)pBits [0])[ 0 .. sizeInBytes].dup;
+    if (hMask !is null) {
         OS.SelectObject(srcHdc, hMask);
         for (int y = 0, dp = 0; y < imgHeight; ++y) {
             for (int x = 0; x < imgWidth; ++x) {
                 if (OS.GetPixel(srcHdc, x, y) !is 0) {
-                    srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = srcData[dp + 3] = (byte)0;
+                    srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = srcData[dp + 3] = cast(byte)0;
                 } else {
-                    srcData[dp + 3] = (byte)0xFF;
+                    srcData[dp + 3] = cast(byte)0xFF;
                 }
                 dp += 4;
             }
@@ -907,7 +916,7 @@
     } else if (alpha !is -1) {
         for (int y = 0, dp = 0; y < imgHeight; ++y) {
             for (int x = 0; x < imgWidth; ++x) {
-                srcData [dp + 3] = (byte)alpha;
+                srcData [dp + 3] = cast(byte)alpha;
                 if (srcData [dp + 3] is 0) srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = 0;
                 dp += 4;
             }
@@ -924,9 +933,9 @@
         for (int y = 0, dp = 0; y < imgHeight; ++y) {
             for (int x = 0; x < imgWidth; ++x) {
                 if (srcData [dp] is blue && srcData [dp + 1] is green && srcData [dp + 2] is red) {
-                    srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = srcData [dp + 3] = (byte)0;
+                    srcData [dp + 0] = srcData [dp + 1] = srcData [dp + 2] = srcData [dp + 3] = cast(byte)0;
                 } else {
-                    srcData [dp + 3] = (byte)0xFF;
+                    srcData [dp + 3] = cast(byte)0xFF;
                 }
                 dp += 4;
             }
@@ -934,72 +943,71 @@
     } else {
         for (int y = 0, dp = 0; y < imgHeight; ++y) {
             for (int x = 0; x < imgWidth; ++x) {
-                srcData [dp + 3] = (byte)0xFF;
+                srcData [dp + 3] = cast(byte)0xFF;
                 dp += 4;
             }
         }
     }
-    OS.MoveMemory (pBits [0], srcData, sizeInBytes);
+    (cast(byte*)pBits [0])[ 0 .. sizeInBytes] = srcData[];
     OS.SelectObject (srcHdc, oldSrcBitmap);
     OS.SelectObject (memHdc, oldMemBitmap);
     OS.DeleteObject (srcHdc);
     OS.DeleteObject (memHdc);
-    OS.ReleaseDC (0, hDC);
-    if (hBitmap !is image.handle && hBitmap !is 0) OS.DeleteObject (hBitmap);
-    if (hMask !is 0) OS.DeleteObject (hMask);
+    OS.ReleaseDC (null, hDC);
+    if (hBitmap !is image.handle && hBitmap !is null) OS.DeleteObject (hBitmap);
+    if (hMask !is null) OS.DeleteObject (hMask);
     return memDib;
 }
 
-static int create32bitDIB (int hBitmap, int alpha, byte [] alphaData, int transparentPixel) {
-    BITMAP bm = new BITMAP ();
-    OS.GetObject (hBitmap, BITMAP.sizeof, bm);
+static HBITMAP create32bitDIB (HBITMAP hBitmap, int alpha, byte [] alphaData, int transparentPixel) {
+    BITMAP bm;
+    OS.GetObject (hBitmap, BITMAP.sizeof, &bm);
     int imgWidth = bm.bmWidth;
     int imgHeight = bm.bmHeight;
-    int hDC = OS.GetDC (0);
-    int srcHdc = OS.CreateCompatibleDC (hDC);
-    int oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
-    int memHdc = OS.CreateCompatibleDC (hDC);
-    BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER ();
+    auto hDC = OS.GetDC (null);
+    auto srcHdc = OS.CreateCompatibleDC (hDC);
+    auto oldSrcBitmap = OS.SelectObject (srcHdc, hBitmap);
+    auto memHdc = OS.CreateCompatibleDC (hDC);
+    BITMAPINFOHEADER bmiHeader;
     bmiHeader.biSize = BITMAPINFOHEADER.sizeof;
     bmiHeader.biWidth = imgWidth;
     bmiHeader.biHeight = -imgHeight;
     bmiHeader.biPlanes = 1;
-    bmiHeader.biBitCount = (short)32;
+    bmiHeader.biBitCount = cast(short)32;
     bmiHeader.biCompression = OS.BI_RGB;
-    byte [] bmi = new byte [BITMAPINFOHEADER.sizeof];
-    OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof);
-    int [] pBits = new int [1];
-    int memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
-    if (memDib is 0) DWT.error (DWT.ERROR_NO_HANDLES);
-    int oldMemBitmap = OS.SelectObject (memHdc, memDib);
-    BITMAP dibBM = new BITMAP ();
-    OS.GetObject (memDib, BITMAP.sizeof, dibBM);
+    byte [] bmi = (cast(byte*)&bmiHeader)[ 0 .. BITMAPINFOHEADER.sizeof];
+    int [1] pBits;
+    auto memDib = OS.CreateDIBSection (null, cast(BITMAPINFO*)bmi.ptr, OS.DIB_RGB_COLORS, pBits.ptr, null, 0);
+    if (memDib is null) DWT.error (DWT.ERROR_NO_HANDLES);
+    auto oldMemBitmap = OS.SelectObject (memHdc, memDib);
+    BITMAP dibBM;
+    OS.GetObject (memDib, BITMAP.sizeof, &dibBM);
     int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
     OS.BitBlt (memHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
     byte red = 0, green = 0, blue = 0;
     if (transparentPixel !is -1) {
         if (bm.bmBitsPixel <= 8) {
-            byte [] color = new byte [4];
-            OS.GetDIBColorTable (srcHdc, transparentPixel, 1, color);
+            byte [4] color;
+            OS.GetDIBColorTable (srcHdc, transparentPixel, 1, cast(RGBQUAD*)color.ptr);
             blue = color [0];
             green = color [1];
             red = color [2];
         } else {
             switch (bm.bmBitsPixel) {
                 case 16:
-                    blue = (byte)((transparentPixel & 0x1F) << 3);
-                    green = (byte)((transparentPixel & 0x3E0) >> 2);
-                    red = (byte)((transparentPixel & 0x7C00) >> 7);
+                    blue = cast(byte)((transparentPixel & 0x1F) << 3);
+                    green = cast(byte)((transparentPixel & 0x3E0) >> 2);
+                    red = cast(byte)((transparentPixel & 0x7C00) >> 7);
                     break;
                 case 24:
-                    blue = (byte)((transparentPixel & 0xFF0000) >> 16);
-                    green = (byte)((transparentPixel & 0xFF00) >> 8);
-                    red = (byte)(transparentPixel & 0xFF);
+                    blue = cast(byte)((transparentPixel & 0xFF0000) >> 16);
+                    green = cast(byte)((transparentPixel & 0xFF00) >> 8);
+                    red = cast(byte)(transparentPixel & 0xFF);
                     break;
                 case 32:
-                    blue = (byte)((transparentPixel & 0xFF000000) >>> 24);
-                    green = (byte)((transparentPixel & 0xFF0000) >> 16);
-                    red = (byte)((transparentPixel & 0xFF00) >> 8);
+                    blue = cast(byte)((transparentPixel & 0xFF000000) >>> 24);
+                    green = cast(byte)((transparentPixel & 0xFF0000) >> 16);
+                    red = cast(byte)((transparentPixel & 0xFF00) >> 8);
                     break;
             }
         }
@@ -1008,13 +1016,12 @@
     OS.SelectObject (memHdc, oldMemBitmap);
     OS.DeleteObject (srcHdc);
     OS.DeleteObject (memHdc);
-    OS.ReleaseDC (0, hDC);
-    byte [] srcData = new byte [sizeInBytes];
-    OS.MoveMemory (srcData, pBits [0], sizeInBytes);
+    OS.ReleaseDC (null, hDC);
+    byte [] srcData = (cast(byte*)pBits[0])[ 0 .. sizeInBytes ].dup;
     if (alpha !is -1) {
         for (int y = 0, dp = 0; y < imgHeight; ++y) {
             for (int x = 0; x < imgWidth; ++x) {
-                srcData [dp + 3] = (byte)alpha;
+                srcData [dp + 3] = cast(byte)alpha;
                 dp += 4;
             }
         }
@@ -1029,15 +1036,15 @@
         for (int y = 0, dp = 0; y < imgHeight; ++y) {
             for (int x = 0; x < imgWidth; ++x) {
                 if (srcData [dp] is blue && srcData [dp + 1] is green && srcData [dp + 2] is red) {
-                    srcData [dp + 3] = (byte)0;
+                    srcData [dp + 3] = cast(byte)0;
                 } else {
-                    srcData [dp + 3] = (byte)0xFF;
+                    srcData [dp + 3] = cast(byte)0xFF;
                 }
                 dp += 4;
             }
         }
     }
-    OS.MoveMemory (pBits [0], srcData, sizeInBytes);
+    (cast(byte*)pBits[0])[ 0 .. sizeInBytes ] = srcData[];
     return memDib;
 }
 
@@ -1049,9 +1056,10 @@
         return new Image (device, data, mask);
     }
     int width = data.width, height = data.height;
-    int hMask, hBitmap;
-    int hDC = device.internal_new_GC (null);
-    int dstHdc = OS.CreateCompatibleDC (hDC), oldDstBitmap;
+    HBITMAP hMask, hBitmap;
+    auto hDC = device.internal_new_GC (null);
+    auto dstHdc = OS.CreateCompatibleDC (hDC);
+    HBITMAP oldDstBitmap;
     if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
         hBitmap = Display.create32bitDIB (image.handle, data.alpha, data.alphaData, data.transparentPixel);
         hMask = OS.CreateBitmap (width, height, 1, 1, null);
@@ -1062,8 +1070,8 @@
         /* Icons need black pixels where the mask is transparent */
         hBitmap = OS.CreateCompatibleBitmap (hDC, width, height);
         oldDstBitmap = OS.SelectObject (dstHdc, hBitmap);
-        int srcHdc = OS.CreateCompatibleDC (hDC);
-        int oldSrcBitmap = OS.SelectObject (srcHdc, image.handle);
+        auto srcHdc = OS.CreateCompatibleDC (hDC);
+        auto oldSrcBitmap = OS.SelectObject (srcHdc, image.handle);
         OS.PatBlt (dstHdc, 0, 0, width, height, OS.BLACKNESS);
         OS.BitBlt (dstHdc, 0, 0, width, height, srcHdc, 0, 0, OS.SRCINVERT);
         OS.SelectObject (srcHdc, hMask);
@@ -1076,22 +1084,22 @@
     OS.SelectObject (dstHdc, oldDstBitmap);
     OS.DeleteDC (dstHdc);
     device.internal_dispose_GC (hDC, null);
-    ICONINFO info = new ICONINFO ();
+    ICONINFO info;
     info.fIcon = true;
     info.hbmColor = hBitmap;
     info.hbmMask = hMask;
-    int hIcon = OS.CreateIconIndirect (info);
-    if (hIcon is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    auto hIcon = OS.CreateIconIndirect (&info);
+    if (hIcon is null) DWT.error(DWT.ERROR_NO_HANDLES);
     OS.DeleteObject (hBitmap);
     OS.DeleteObject (hMask);
     return Image.win32_new (device, DWT.ICON, hIcon);
 }
 
-static int createMaskFromAlpha (ImageData data, int destWidth, int destHeight) {
+static HBITMAP createMaskFromAlpha (ImageData data, int destWidth, int destHeight) {
     int srcWidth = data.width;
     int srcHeight = data.height;
     ImageData mask = ImageData.internal_new (srcWidth, srcHeight, 1,
-            new PaletteData(new RGB [] {new RGB (0, 0, 0), new RGB (0xff, 0xff, 0xff)}),
+            new PaletteData([new RGB (0, 0, 0), new RGB (0xff, 0xff, 0xff)]),
             2, null, 1, null, null, -1, -1, -1, 0, 0, 0, 0);
     int ap = 0;
     for (int y = 0; y < mask.height; y++) {
@@ -1099,19 +1107,19 @@
             mask.setPixel (x, y, (data.alphaData [ap++] & 0xff) <= 127 ? 1 : 0);
         }
     }
-    int hMask = OS.CreateBitmap (srcWidth, srcHeight, 1, 1, mask.data);
+    auto hMask = OS.CreateBitmap (srcWidth, srcHeight, 1, 1, mask.data.ptr);
     if (srcWidth !is destWidth || srcHeight !is destHeight) {
-        int hdc = OS.GetDC (0);
-        int hdc1 = OS.CreateCompatibleDC (hdc);
+        auto hdc = OS.GetDC (null);
+        auto hdc1 = OS.CreateCompatibleDC (hdc);
         OS.SelectObject (hdc1, hMask);
-        int hdc2 = OS.CreateCompatibleDC (hdc);
-        int hMask2 = OS.CreateBitmap (destWidth, destHeight, 1, 1, null);
+        auto hdc2 = OS.CreateCompatibleDC (hdc);
+        auto hMask2 = OS.CreateBitmap (destWidth, destHeight, 1, 1, null);
         OS.SelectObject (hdc2, hMask2);
         if (!OS.IsWinCE) OS.SetStretchBltMode(hdc2, OS.COLORONCOLOR);
         OS.StretchBlt (hdc2, 0, 0, destWidth, destHeight, hdc1, 0, 0, srcWidth, srcHeight, OS.SRCCOPY);
         OS.DeleteDC (hdc1);
         OS.DeleteDC (hdc2);
-        OS.ReleaseDC (0, hdc);
+        OS.ReleaseDC (null, hdc);
         OS.DeleteObject(hMask);
         hMask = hMask2;
     }
@@ -1166,7 +1174,7 @@
         }
     }
     Runnable [] newDisposeList = new Runnable [disposeList.length + 4];
-    System.arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
+    SimpleType!(Runnable).arraycopy (disposeList, 0, newDisposeList, 0, disposeList.length);
     newDisposeList [disposeList.length] = runnable;
     disposeList = newDisposeList;
 }
@@ -1180,23 +1188,22 @@
     bars = null;
 }
 
-int embeddedProc (int hwnd, int msg, int wParam, int lParam) {
+private static extern(Windows) int embeddedFunc (HWND hwnd, int msg, int wParam, int lParam) {
     switch (msg) {
         case SWT_KEYMSG: {
-            MSG keyMsg = new MSG ();
-            OS.MoveMemory (keyMsg, lParam, MSG.sizeof);
+            MSG* keyMsg = cast(MSG*)lParam;
             OS.TranslateMessage (keyMsg);
             OS.DispatchMessage (keyMsg);
-            int hHeap = OS.GetProcessHeap ();
-            OS.HeapFree (hHeap, 0, lParam);
+            auto hHeap = OS.GetProcessHeap ();
+            OS.HeapFree (hHeap, 0, cast(void*)lParam);
             break;
         }
         case SWT_DESTROY: {
             OS.DestroyWindow (hwnd);
-            if (embeddedCallback !is null) embeddedCallback.dispose ();
-            if (getMsgCallback !is null) getMsgCallback.dispose ();
-            embeddedCallback = getMsgCallback = null;
-            embeddedProc = getMsgProc = 0;
+            //if (embeddedCallback !is null) embeddedCallback.dispose ();
+            //if (getMsgCallback !is null) getMsgCallback.dispose ();
+            //embeddedCallback = getMsgCallback = null;
+            //embeddedProc_ = getMsgProc_ = 0;
             break;
         }
     }
@@ -1225,7 +1232,7 @@
     return filterTable.hooks (eventType);
 }
 
-bool filterMessage (MSG msg) {
+bool filterMessage (MSG* msg) {
     int message = msg.message;
     if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) {
         Control control = findControl (msg.hwnd);
@@ -1240,15 +1247,15 @@
     return false;
 }
 
-Control findControl (int handle) {
-    if (handle is 0) return null;
-    int hwndOwner = 0;
+Control findControl (HANDLE handle) {
+    if (handle is null) return null;
+    HWND hwndOwner = null;
     do {
         Control control = getControl (handle);
         if (control !is null) return control;
         hwndOwner = OS.GetWindow (handle, OS.GW_OWNER);
         handle = OS.GetParent (handle);
-    } while (handle !is 0 && handle !is hwndOwner);
+    } while (handle !is null && handle !is hwndOwner);
     return null;
 }
 
@@ -1270,7 +1277,7 @@
  *    <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
  * </ul>
  */
-public Widget findWidget (int handle) {
+public Widget findWidget (HANDLE handle) {
     checkDevice ();
     return getControl (handle);
 }
@@ -1297,7 +1304,7 @@
  *
  * @since 3.1
  */
-public Widget findWidget (int handle, int id) {
+public Widget findWidget (HANDLE handle, int id) {
     checkDevice ();
     Control control = getControl (handle);
     return control !is null ? control.findItem (id) : null;
@@ -1322,12 +1329,17 @@
  */
 public Widget findWidget (Widget widget, int id) {
     checkDevice ();
-    if (widget instanceof Control) {
-        return findWidget (((Control) widget).handle, id);
+    if (cast(Control)widget) {
+        return findWidget ((cast(Control) widget).handle, id);
     }
     return null;
 }
 
+private static extern(Windows) int foregroundIdleProcFunc (int code, int wParam, int lParam) {
+    auto d = Display.getCurrent();
+    return d.foregroundIdleProc( code, wParam, lParam );
+}
+
 int foregroundIdleProc (int code, int wParam, int lParam) {
     if (runMessages) {
         if (code >= 0) {
@@ -1412,19 +1424,19 @@
  * @return the current display
  */
 public static synchronized Display getCurrent () {
-    return findDisplay (Thread.currentThread ());
+    return findDisplay (Thread.getThis ());
 }
 
-int getClickCount (int type, int button, int hwnd, int lParam) {
+int getClickCount (int type, int button, HWND hwnd, int lParam) {
     switch (type) {
         case DWT.MouseDown:
             int doubleClick = OS.GetDoubleClickTime ();
-            if (clickRect is null) clickRect = new RECT ();
+            //if (clickRect is null) clickRect = new RECT ();
             int deltaTime = Math.abs (lastTime - getLastEventTime ());
-            POINT pt = new POINT ();
-            pt.x = (short) (lParam & 0xFFFF);
-            pt.y = (short) (lParam >> 16);
-            if (lastClickHwnd is hwnd && lastButton is button && (deltaTime <= doubleClick) && OS.PtInRect (clickRect, pt)) {
+            POINT pt;
+            pt.x = cast(short) (lParam & 0xFFFF);
+            pt.y = cast(short) (lParam >> 16);
+            if (lastClickHwnd is hwnd && lastButton is button && (deltaTime <= doubleClick) && OS.PtInRect (&clickRect, pt)) {
                 clickCount++;
             } else {
                 clickCount = 1;
@@ -1436,8 +1448,8 @@
             lastTime = getLastEventTime ();
             int xInset = OS.GetSystemMetrics (OS.SM_CXDOUBLECLK) / 2;
             int yInset = OS.GetSystemMetrics (OS.SM_CYDOUBLECLK) / 2;
-            int x = (short) (lParam & 0xFFFF), y = (short) (lParam >> 16);
-            OS.SetRect (clickRect, x - xInset, y - yInset, x + xInset, y + yInset);
+            int x = cast(short) (lParam & 0xFFFF), y = cast(short) (lParam >> 16);
+            OS.SetRect (&clickRect, x - xInset, y - yInset, x + xInset, y + yInset);
             //FALL THROUGH
         case DWT.MouseUp:
             return clickCount;
@@ -1461,8 +1473,8 @@
 public Rectangle getClientArea () {
     checkDevice ();
     if (OS.GetSystemMetrics (OS.SM_CMONITORS) < 2) {
-        RECT rect = new RECT ();
-        OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);
+        RECT rect;
+        OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, &rect, 0);
         int width = rect.right - rect.left;
         int height = rect.bottom - rect.top;
         return new Rectangle (rect.left, rect.top, width, height);
@@ -1474,8 +1486,8 @@
     return new Rectangle (x, y, width, height);
 }
 
-Control getControl (int handle) {
-    if (handle is 0) return null;
+Control getControl (HANDLE handle) {
+    if (handle is null) return null;
     if (lastControl !is null && lastHwnd is handle) {
         return lastControl;
     }
@@ -1483,8 +1495,8 @@
         return lastGetControl;
     }
     int index;
-    if (USE_PROPERTY) {
-        index = OS.GetProp (handle, SWT_OBJECT_INDEX) - 1;
+    static if (USE_PROPERTY) {
+        index = cast(int) OS.GetProp (handle, cast(wchar*)SWT_OBJECT_INDEX) - 1;
     } else {
         index = OS.GetWindowLong (handle, OS.GWL_USERDATA) - 1;
     }
@@ -1521,8 +1533,8 @@
  */
 public Control getCursorControl () {
     checkDevice ();
-    POINT pt = new POINT ();
-    if (!OS.GetCursorPos (pt)) return null;
+    POINT pt;
+    if (!OS.GetCursorPos (&pt)) return null;
     return findControl (OS.WindowFromPoint (pt));
 }
 
@@ -1539,8 +1551,8 @@
  */
 public Point getCursorLocation () {
     checkDevice ();
-    POINT pt = new POINT ();
-    OS.GetCursorPos (pt);
+    POINT pt;
+    OS.GetCursorPos (&pt);
     return new Point (pt.x, pt.y);
 }
 
@@ -1558,8 +1570,8 @@
  */
 public Point [] getCursorSizes () {
     checkDevice ();
-    return new Point [] {
-        new Point (OS.GetSystemMetrics (OS.SM_CXCURSOR), OS.GetSystemMetrics (OS.SM_CYCURSOR))};
+    return [
+        new Point (OS.GetSystemMetrics (OS.SM_CXCURSOR), OS.GetSystemMetrics (OS.SM_CYCURSOR))];
 }
 
 /**
@@ -1574,11 +1586,12 @@
     return Default;
 }
 
-static bool isValidClass (Class clazz) {
-    String name = clazz.getName ();
+//PORTING_TODO
+/+static bool isValidClass (Class clazz) {
+    char[] name = clazz.getName ();
     int index = name.lastIndexOf ('.');
     return name.substring (0, index + 1).equals (PACKAGE_PREFIX);
-}
+}+/
 
 /**
  * Returns the application defined property of the receiver
@@ -1605,15 +1618,15 @@
  * @see #setData(String, Object)
  * @see #disposeExec(Runnable)
  */
-public Object getData (String key) {
+public Object getData (char[] key) {
     checkDevice ();
     if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
-    if (key.equals (RUN_MESSAGES_IN_IDLE_KEY)) {
-        return new bool (runMessagesInIdle);
+    if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) {
+        return new ValueWrapperBool(runMessagesInIdle);
     }
-    if (keys is null) return null;
+    if (keys.length is 0) return null;
     for (int i=0; i<keys.length; i++) {
-        if (keys [i].equals (key)) return values [i];
+        if (keys [i] ==/*eq*/key) return values [i];
     }
     return null;
 }
@@ -1707,21 +1720,16 @@
     return _getFocusControl ();
 }
 
-String getFontName (LOGFONT logFont) {
-    char[] chars;
-    if (OS.IsUnicode) {
-        chars = ((LOGFONTW)logFont).lfFaceName;
+char[] getFontName (LOGFONT* logFont) {
+    wchar* chars;
+    static if (OS.IsUnicode) {
+        chars = logFont.lfFaceName.ptr;
     } else {
         chars = new char[OS.LF_FACESIZE];
-        byte[] bytes = ((LOGFONTA)logFont).lfFaceName;
+        byte[] bytes = logFont.lfFaceName;
         OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, bytes, bytes.length, chars, chars.length);
     }
-    int index = 0;
-    while (index < chars.length) {
-        if (chars [index] is 0) break;
-        index++;
-    }
-    return new String (chars, 0, index);
+    return TCHARzToStr( chars );
 }
 
 /**
@@ -1743,11 +1751,15 @@
  */
 public bool getHighContrast () {
     checkDevice ();
-    if (OS.IsWinCE) return false;
-    HIGHCONTRAST pvParam = new HIGHCONTRAST ();
-    pvParam.cbSize = HIGHCONTRAST.sizeof;
-    OS.SystemParametersInfo (OS.SPI_GETHIGHCONTRAST, 0, pvParam, 0);
-    return (pvParam.dwFlags & OS.HCF_HIGHCONTRASTON) !is 0;
+    static if (OS.IsWinCE) {
+        return false;
+    }
+    else {
+        HIGHCONTRAST pvParam;
+        pvParam.cbSize = HIGHCONTRAST.sizeof;
+        OS.SystemParametersInfo (OS.SPI_GETHIGHCONTRAST, 0, &pvParam, 0);
+        return (pvParam.dwFlags & OS.HCF_HIGHCONTRASTON) !is 0;
+    }
 }
 
 /**
@@ -1770,27 +1782,28 @@
     }
 
     /* Use the character encoding for the default locale */
-    TCHAR buffer1 = new TCHAR (0, "Control Panel\\Desktop\\WindowMetrics", true); //$NON-NLS-1$
-
-    int [] phkResult = new int [1];
-    int result = OS.RegOpenKeyEx (OS.HKEY_CURRENT_USER, buffer1, 0, OS.KEY_READ, phkResult);
+    TCHAR* buffer1 = StrToTCHARz( "Control Panel\\Desktop\\WindowMetrics" ); //$NON-NLS-1$
+
+    void* phkResult;
+    int result = OS.RegOpenKeyEx ( cast(void*)OS.HKEY_CURRENT_USER, buffer1, 0, OS.KEY_READ, &phkResult);
     if (result !is 0) return 4;
     int depth = 4;
-    int [] lpcbData = new int [1];
+    uint lpcbData;
 
     /* Use the character encoding for the default locale */
-    TCHAR buffer2 = new TCHAR (0, "Shell Icon BPP", true); //$NON-NLS-1$
-    result = OS.RegQueryValueEx (phkResult [0], buffer2, 0, null, (TCHAR) null, lpcbData);
+    TCHAR* buffer2 = StrToTCHARz( "Shell Icon BPP" ); //$NON-NLS-1$
+    result = OS.RegQueryValueEx (phkResult , buffer2, null, null, null, &lpcbData);
     if (result is 0) {
-        TCHAR lpData = new TCHAR (0, lpcbData [0] / TCHAR.sizeof);
-        result = OS.RegQueryValueEx (phkResult [0], buffer2, 0, null, lpData, lpcbData);
+        ubyte[] lpData = new ubyte[ lpcbData  / TCHAR.sizeof ];
+        lpData[] = 0;
+        result = OS.RegQueryValueEx (phkResult , buffer2, null, null, lpData.ptr, &lpcbData);
         if (result is 0) {
             try {
-                depth = Integer.parseInt (lpData.toString (0, lpData.strlen ()));
+                depth = Integer.parseInt ( cast(char[]) lpData );
             } catch (NumberFormatException e) {}
         }
     }
-    OS.RegCloseKey (phkResult [0]);
+    OS.RegCloseKey (phkResult );
     return depth;
 }
 
@@ -1810,18 +1823,18 @@
  */
 public Point [] getIconSizes () {
     checkDevice ();
-    return new Point [] {
+    return [
         new Point (OS.GetSystemMetrics (OS.SM_CXSMICON), OS.GetSystemMetrics (OS.SM_CYSMICON)),
-        new Point (OS.GetSystemMetrics (OS.SM_CXICON), OS.GetSystemMetrics (OS.SM_CYICON)),
-    };
+        new Point (OS.GetSystemMetrics (OS.SM_CXICON), OS.GetSystemMetrics (OS.SM_CYICON))
+    ];
 }
 
 ImageList getImageList (int style, int width, int height) {
     if (imageList is null) imageList = new ImageList [4];
 
     int i = 0;
-    int length = imageList.length;
-    while (i < length) {
+    int length_ = imageList.length;
+    while (i < length_) {
         ImageList list = imageList [i];
         if (list is null) break;
         Point size = list.getImageSize();
@@ -1834,9 +1847,9 @@
         i++;
     }
 
-    if (i is length) {
-        ImageList [] newList = new ImageList [length + 4];
-        System.arraycopy (imageList, 0, newList, 0, length);
+    if (i is length_) {
+        ImageList [] newList = new ImageList [length_ + 4];
+        System.arraycopy (imageList, 0, newList, 0, length_);
         imageList = newList;
     }
 
@@ -1850,8 +1863,8 @@
     if (toolImageList is null) toolImageList = new ImageList [4];
 
     int i = 0;
-    int length = toolImageList.length;
-    while (i < length) {
+    int length_ = toolImageList.length;
+    while (i < length_) {
         ImageList list = toolImageList [i];
         if (list is null) break;
         Point size = list.getImageSize();
@@ -1864,9 +1877,9 @@
         i++;
     }
 
-    if (i is length) {
-        ImageList [] newList = new ImageList [length + 4];
-        System.arraycopy (toolImageList, 0, newList, 0, length);
+    if (i is length_) {
+        ImageList [] newList = new ImageList [length_ + 4];
+        System.arraycopy (toolImageList, 0, newList, 0, length_);
         toolImageList = newList;
     }
 
@@ -1880,8 +1893,8 @@
     if (toolDisabledImageList is null) toolDisabledImageList = new ImageList [4];
 
     int i = 0;
-    int length = toolDisabledImageList.length;
-    while (i < length) {
+    int length_ = toolDisabledImageList.length;
+    while (i < length_) {
         ImageList list = toolDisabledImageList [i];
         if (list is null) break;
         Point size = list.getImageSize();
@@ -1894,9 +1907,9 @@
         i++;
     }
 
-    if (i is length) {
-        ImageList [] newList = new ImageList [length + 4];
-        System.arraycopy (toolDisabledImageList, 0, newList, 0, length);
+    if (i is length_) {
+        ImageList [] newList = new ImageList [length_ + 4];
+        System.arraycopy (toolDisabledImageList, 0, newList, 0, length_);
         toolDisabledImageList = newList;
     }
 
@@ -1910,8 +1923,8 @@
     if (toolHotImageList is null) toolHotImageList = new ImageList [4];
 
     int i = 0;
-    int length = toolHotImageList.length;
-    while (i < length) {
+    int length_ = toolHotImageList.length;
+    while (i < length_) {
         ImageList list = toolHotImageList [i];
         if (list is null) break;
         Point size = list.getImageSize();
@@ -1924,9 +1937,9 @@
         i++;
     }
 
-    if (i is length) {
-        ImageList [] newList = new ImageList [length + 4];
-        System.arraycopy (toolHotImageList, 0, newList, 0, length);
+    if (i is length_) {
+        ImageList [] newList = new ImageList [length_ + 4];
+        System.arraycopy (toolHotImageList, 0, newList, 0, length_);
         toolHotImageList = newList;
     }
 
@@ -1974,18 +1987,14 @@
  *
  * @since 3.0
  */
-public Monitor [] getMonitors () {
+public dwt.widgets.Monitor.Monitor [] getMonitors () {
     checkDevice ();
     if (OS.IsWinCE || OS.WIN32_VERSION < OS.VERSION (4, 10)) {
-        return new Monitor [] {getPrimaryMonitor ()};
+        return [getPrimaryMonitor ()];
     }
-    monitors = new Monitor [4];
-    Callback callback = new Callback (this, "monitorEnumProc", 4); //$NON-NLS-1$
-    int lpfnEnum = callback.getAddress ();
-    if (lpfnEnum is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
-    OS.EnumDisplayMonitors (0, null, lpfnEnum, 0);
-    callback.dispose ();
-    Monitor [] result = new Monitor [monitorCount];
+    monitors = new dwt.widgets.Monitor.Monitor [4];
+    OS.EnumDisplayMonitors (null, null, &monitorEnumFunc, cast(int)cast(void*)this );
+    dwt.widgets.Monitor.Monitor [] result = new dwt.widgets.Monitor.Monitor [monitorCount];
     System.arraycopy (monitors, 0, result, 0, monitorCount);
     monitors = null;
     monitorCount = 0;
@@ -1993,25 +2002,24 @@
 }
 
 int getMsgProc (int code, int wParam, int lParam) {
-    if (embeddedHwnd is 0) {
-        int hInstance = OS.GetModuleHandle (null);
+    if (embeddedHwnd is null) {
+        auto hInstance = OS.GetModuleHandle (null);
         embeddedHwnd = OS.CreateWindowEx (0,
             windowClass,
             null,
             OS.WS_OVERLAPPED,
             0, 0, 0, 0,
-            0,
-            0,
+            null,
+            null,
             hInstance,
             null);
-        embeddedCallback = new Callback (this, "embeddedProc", 4); //$NON-NLS-1$
-        embeddedProc = embeddedCallback.getAddress ();
-        if (embeddedProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
-        OS.SetWindowLong (embeddedHwnd, OS.GWL_WNDPROC, embeddedProc);
+        //embeddedCallback = new Callback (this, "embeddedProc", 4); //$NON-NLS-1$
+        //embeddedProc_ = embeddedCallback.getAddress ();
+        //if (embeddedProc_ is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+        OS.SetWindowLong (embeddedHwnd, OS.GWL_WNDPROC, cast(int) &embeddedFunc);
     }
     if (code >= 0 && wParam !is OS.PM_NOREMOVE) {
-        MSG msg = new MSG ();
-        OS.MoveMemory (msg, lParam, MSG.sizeof);
+        MSG* msg = cast(MSG*)lParam;
         switch (msg.message) {
             case OS.WM_KEYDOWN:
             case OS.WM_KEYUP:
@@ -2019,12 +2027,12 @@
             case OS.WM_SYSKEYUP: {
                 Control control = findControl (msg.hwnd);
                 if (control !is null) {
-                    int hHeap = OS.GetProcessHeap ();
-                    int keyMsg = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, MSG.sizeof);
-                    OS.MoveMemory (keyMsg, msg, MSG.sizeof);
-                    OS.PostMessage (hwndMessage, SWT_KEYMSG, wParam, keyMsg);
+                    auto hHeap = OS.GetProcessHeap ();
+                    MSG* keyMsg = cast(MSG*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, MSG.sizeof);
+                    *keyMsg = *msg;
+                    OS.PostMessage (hwndMessage, SWT_KEYMSG, wParam, cast(int)keyMsg);
                     msg.message = OS.WM_NULL;
-                    OS.MoveMemory (lParam, msg, MSG.sizeof);
+                    //OS.MoveMemory (lParam, msg, MSG.sizeof);
                 }
             }
         }
@@ -2039,34 +2047,30 @@
  *
  * @since 3.0
  */
-public Monitor getPrimaryMonitor () {
+public dwt.widgets.Monitor.Monitor getPrimaryMonitor () {
     checkDevice ();
     if (OS.IsWinCE || OS.WIN32_VERSION < OS.VERSION (4, 10)) {
-        Monitor monitor = new Monitor();
+        dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor();
         int width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
         int height = OS.GetSystemMetrics (OS.SM_CYSCREEN);
         monitor.width = width;
         monitor.height = height;
-        RECT rect = new RECT ();
-        OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, rect, 0);
+        RECT rect;
+        OS.SystemParametersInfo (OS.SPI_GETWORKAREA, 0, &rect, 0);
         monitor.clientX = rect.left;
         monitor.clientY = rect.top;
         monitor.clientWidth = rect.right - rect.left;
         monitor.clientHeight = rect.bottom - rect.top;
         return monitor;
     }
-    monitors = new Monitor [4];
-    Callback callback = new Callback (this, "monitorEnumProc", 4); //$NON-NLS-1$
-    int lpfnEnum = callback.getAddress ();
-    if (lpfnEnum is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS);
-    OS.EnumDisplayMonitors (0, null, lpfnEnum, 0);
-    callback.dispose ();
-    Monitor result = null;
-    MONITORINFO lpmi = new MONITORINFO ();
+    monitors = new dwt.widgets.Monitor.Monitor [4];
+    OS.EnumDisplayMonitors (null, null, &monitorEnumFunc, cast(int)cast(void*)this);
+    dwt.widgets.Monitor.Monitor result = null;
+    MONITORINFO lpmi;
     lpmi.cbSize = MONITORINFO.sizeof;
     for (int i = 0; i < monitorCount; i++) {
-        Monitor monitor = monitors [i];
-        OS.GetMonitorInfo (monitors [i].handle, lpmi);
+        dwt.widgets.Monitor.Monitor monitor = monitors [i];
+        OS.GetMonitorInfo (monitors [i].handle, &lpmi);
         if ((lpmi.dwFlags & OS.MONITORINFOF_PRIMARY) !is 0) {
             result = monitor;
             break;
@@ -2094,7 +2098,7 @@
     Shell [] result = new Shell [16];
     for (int i = 0; i < controlTable.length; i++) {
         Control control = controlTable [i];
-        if (control !is null && control instanceof Shell) {
+        if (control !is null && (cast(Shell)control)) {
             int j = 0;
             while (j < index) {
                 if (result [j] is control) break;
@@ -2106,7 +2110,7 @@
                     System.arraycopy (result, 0, newResult, 0, index);
                     result = newResult;
                 }
-                result [index++] = (Shell) control;
+                result [index++] = cast(Shell) control;
             }
         }
     }
@@ -2123,7 +2127,7 @@
             Color c1 = getSystemColor (DWT.COLOR_WIDGET_NORMAL_SHADOW);
             Color c2 = getSystemColor (DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
             Color c3 = getSystemColor (DWT.COLOR_WIDGET_BACKGROUND);
-            PaletteData palette = new PaletteData(new RGB [] {c1.getRGB (), c2.getRGB (), c3.getRGB ()});
+            PaletteData palette = new PaletteData([c1.getRGB (), c2.getRGB (), c3.getRGB ()]);
             ImageData imageData = new ImageData (8, 8, 4, palette);
             imageData.transparentPixel = 2;
             upArrow = new Image (this, imageData);
@@ -2131,10 +2135,10 @@
             gc.setBackground (c3);
             gc.fillRectangle (0, 0, 8, 8);
             gc.setForeground (c1);
-            int [] line1 = new int [] {0,6, 1,6, 1,4, 2,4, 2,2, 3,2, 3,1};
+            int [] line1 = [0,6, 1,6, 1,4, 2,4, 2,2, 3,2, 3,1];
             gc.drawPolyline (line1);
             gc.setForeground (c2);
-            int [] line2 = new int [] {0,7, 7,7, 7,6, 6,6, 6,4, 5,4, 5,2, 4,2, 4,1};
+            int [] line2 = [0,7, 7,7, 7,6, 6,6, 6,4, 5,4, 5,2, 4,2, 4,1];
             gc.drawPolyline (line2);
             gc.dispose ();
             return upArrow;
@@ -2144,7 +2148,7 @@
             Color c1 = getSystemColor (DWT.COLOR_WIDGET_NORMAL_SHADOW);
             Color c2 = getSystemColor (DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
             Color c3 = getSystemColor (DWT.COLOR_WIDGET_BACKGROUND);
-            PaletteData palette = new PaletteData (new RGB [] {c1.getRGB (), c2.getRGB (), c3.getRGB ()});
+            PaletteData palette = new PaletteData ([c1.getRGB (), c2.getRGB (), c3.getRGB ()]);
             ImageData imageData = new ImageData (8, 8, 4, palette);
             imageData.transparentPixel = 2;
             downArrow = new Image (this, imageData);
@@ -2152,10 +2156,10 @@
             gc.setBackground (c3);
             gc.fillRectangle (0, 0, 8, 8);
             gc.setForeground (c1);
-            int [] line1 = new int [] {7,0, 0,0, 0,1, 1,1, 1,3, 2,3, 2,5, 3,5, 3,6};
+            int [] line1 = [7,0, 0,0, 0,1, 1,1, 1,3, 2,3, 2,5, 3,5, 3,6];
             gc.drawPolyline (line1);
             gc.setForeground (c2);
-            int [] line2 = new int [] {4,6, 4,5, 5,5, 5,3, 6,3, 6,1, 7,1};
+            int [] line2 = [4,6, 4,5, 5,5, 5,3, 6,3, 6,1, 7,1];
             gc.drawPolyline (line2);
             gc.dispose ();
             return downArrow;
@@ -2313,18 +2317,18 @@
 public Font getSystemFont () {
     checkDevice ();
     if (systemFont !is null) return systemFont;
-    int hFont = 0;
+    HFONT hFont;
     if (!OS.IsWinCE) {
-        NONCLIENTMETRICS info = OS.IsUnicode ? (NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA ();
+        NONCLIENTMETRICS info;
         info.cbSize = NONCLIENTMETRICS.sizeof;
-        if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {
-            LOGFONT logFont = OS.IsUnicode ? (LOGFONT) ((NONCLIENTMETRICSW)info).lfMessageFont : ((NONCLIENTMETRICSA)info).lfMessageFont;
-            hFont = OS.CreateFontIndirect (logFont);
-            lfSystemFont = hFont !is 0 ? logFont : null;
+        if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, &info, 0)) {
+            LOGFONT logFont = info.lfMessageFont;
+            hFont = OS.CreateFontIndirect (&logFont);
+            lfSystemFont = hFont !is null ? &logFont : null;
         }
     }
-    if (hFont is 0) hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
-    if (hFont is 0) hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+    if (hFont is null) hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
+    if (hFont is null) hFont = OS.GetStockObject (OS.SYSTEM_FONT);
     return systemFont = Font.win32_new (this, hFont);
 }
 
@@ -2359,23 +2363,23 @@
     switch (id) {
         case DWT.ICON_ERROR: {
             if (errorImage !is null) return errorImage;
-            int hIcon = OS.LoadImage (0, OS.OIC_HAND, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
+            auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_HAND, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
             return errorImage = Image.win32_new (this, DWT.ICON, hIcon);
         }
         case DWT.ICON_WORKING:
         case DWT.ICON_INFORMATION: {
             if (infoImage !is null) return infoImage;
-            int hIcon = OS.LoadImage (0, OS.OIC_INFORMATION, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
+            auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_INFORMATION, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
             return infoImage = Image.win32_new (this, DWT.ICON, hIcon);
         }
         case DWT.ICON_QUESTION: {
             if (questionImage !is null) return questionImage;
-            int hIcon = OS.LoadImage (0, OS.OIC_QUES, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
+            auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_QUES, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
             return questionImage = Image.win32_new (this, DWT.ICON, hIcon);
         }
         case DWT.ICON_WARNING: {
             if (warningIcon !is null) return warningIcon;
-            int hIcon = OS.LoadImage (0, OS.OIC_BANG, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
+            auto hIcon = OS.LoadImage (null, cast(wchar*)OS.OIC_BANG, OS.IMAGE_ICON, 0, 0, OS.LR_SHARED);
             return warningIcon = Image.win32_new (this, DWT.ICON, hIcon);
         }
     }
@@ -2415,29 +2419,29 @@
     return thread;
 }
 
-int hButtonTheme () {
-    if (hButtonTheme !is 0) return hButtonTheme;
-    return hButtonTheme = OS.OpenThemeData (hwndMessage, BUTTON);
+HTHEME hButtonTheme () {
+    if (hButtonTheme_ !is null) return hButtonTheme_;
+    return hButtonTheme_ = OS.OpenThemeData (hwndMessage, BUTTON.ptr);
 }
 
-int hEditTheme () {
-    if (hEditTheme !is 0) return hEditTheme;
-    return hEditTheme = OS.OpenThemeData (hwndMessage, EDIT);
+HTHEME hEditTheme () {
+    if (hEditTheme_ !is null) return hEditTheme_;
+    return hEditTheme_ = OS.OpenThemeData (hwndMessage, EDIT.ptr);
 }
 
-int hExplorerBarTheme () {
-    if (hExplorerBarTheme !is 0) return hExplorerBarTheme;
-    return hExplorerBarTheme = OS.OpenThemeData (hwndMessage, EXPLORERBAR);
+HTHEME hExplorerBarTheme () {
+    if (hExplorerBarTheme_ !is null) return hExplorerBarTheme_;
+    return hExplorerBarTheme_ = OS.OpenThemeData (hwndMessage, EXPLORERBAR.ptr);
 }
 
-int hScrollBarTheme () {
-    if (hScrollBarTheme !is 0) return hScrollBarTheme;
-    return hScrollBarTheme = OS.OpenThemeData (hwndMessage, SCROLLBAR);
+HTHEME hScrollBarTheme () {
+    if (hScrollBarTheme_ !is null) return hScrollBarTheme_;
+    return hScrollBarTheme_ = OS.OpenThemeData (hwndMessage, SCROLLBAR.ptr);
 }
 
-int hTabTheme () {
-    if (hTabTheme !is 0) return hTabTheme;
-    return hTabTheme = OS.OpenThemeData (hwndMessage, TAB);
+HTHEME hTabTheme () {
+    if (hTabTheme_ !is null) return hTabTheme_;
+    return hTabTheme_ = OS.OpenThemeData (hwndMessage, TAB.ptr);
 }
 
 /**
@@ -2460,10 +2464,10 @@
  *    <li>ERROR_NO_HANDLES if a handle could not be obtained for gc creation</li>
  * </ul>
  */
-public int internal_new_GC (GCData data) {
+public HDC internal_new_GC (GCData data) {
     if (isDisposed()) DWT.error(DWT.ERROR_DEVICE_DISPOSED);
-    int hDC = OS.GetDC (0);
-    if (hDC is 0) DWT.error (DWT.ERROR_NO_HANDLES);
+    auto hDC = OS.GetDC (null);
+    if (hDC is null) DWT.error (DWT.ERROR_NO_HANDLES);
     if (data !is null) {
         int mask = DWT.LEFT_TO_RIGHT | DWT.RIGHT_TO_LEFT;
         if ((data.style & mask) !is 0) {
@@ -2490,38 +2494,40 @@
     super.init ();
 
     /* Create the callbacks */
-    windowCallback = new Callback (this, "windowProc", 4); //$NON-NLS-1$
-    windowProc = windowCallback.getAddress ();
-    if (windowProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    //windowCallback = new Callback (this, "windowProc", 4); //$NON-NLS-1$
+    //windowProc_ = windowCallback.getAddress ();
+    //if (windowProc_ is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
 
     /* Remember the current thread id */
     threadId = OS.GetCurrentThreadId ();
 
     /* Use the character encoding for the default locale */
-    windowClass = new TCHAR (0, WindowName + WindowClassCount, true);
-    windowShadowClass = new TCHAR (0, WindowShadowName + WindowClassCount, true);
+    windowClass = StrToTCHARz ( WindowName ~ to!(char[])(WindowClassCount));
+    windowShadowClass = StrToTCHARz ( WindowShadowName ~ to!(char[])(WindowClassCount));
     WindowClassCount++;
 
     /* Register the DWT window class */
-    int hHeap = OS.GetProcessHeap ();
-    int hInstance = OS.GetModuleHandle (null);
-    WNDCLASS lpWndClass = new WNDCLASS ();
+    auto hHeap = OS.GetProcessHeap ();
+    auto hInstance = OS.GetModuleHandle (null);
+    WNDCLASS lpWndClass;
     lpWndClass.hInstance = hInstance;
-    lpWndClass.lpfnWndProc = windowProc;
+    lpWndClass.lpfnWndProc = &windowProcFunc;
     lpWndClass.style = OS.CS_BYTEALIGNWINDOW | OS.CS_DBLCLKS;
-    lpWndClass.hCursor = OS.LoadCursor (0, OS.IDC_ARROW);
-    int byteCount = windowClass.length () * TCHAR.sizeof;
-    lpWndClass.lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-    OS.MoveMemory (lpWndClass.lpszClassName, windowClass, byteCount);
-    OS.RegisterClass (lpWndClass);
+    lpWndClass.hCursor = OS.LoadCursor (null, cast(wchar*)OS.IDC_ARROW);
+    int len = strlenz( windowClass );
+    int byteCount = len * TCHAR.sizeof;
+    lpWndClass.lpszClassName = cast(wchar*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+    lpWndClass.lpszClassName[ 0 .. len ] = windowClass[ 0 .. len ];
+    OS.RegisterClass (&lpWndClass);
     OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName);
 
     /* Register the DWT drop shadow window class */
     if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) lpWndClass.style |= OS.CS_DROPSHADOW;
-    byteCount = windowShadowClass.length () * TCHAR.sizeof;
-    lpWndClass.lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
-    OS.MoveMemory (lpWndClass.lpszClassName, windowShadowClass, byteCount);
-    OS.RegisterClass (lpWndClass);
+    len = strlenz( windowShadowClass );
+    byteCount = len * TCHAR.sizeof;
+    lpWndClass.lpszClassName = cast(wchar*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount);
+    lpWndClass.lpszClassName[ 0 .. len ] = windowShadowClass[ 0 .. len ];
+    OS.RegisterClass (&lpWndClass);
     OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName);
 
     /* Create the message only HWND */
@@ -2530,37 +2536,37 @@
         null,
         OS.WS_OVERLAPPED,
         0, 0, 0, 0,
-        0,
-        0,
+        null,
+        null,
         hInstance,
         null);
-    messageCallback = new Callback (this, "messageProc", 4); //$NON-NLS-1$
-    messageProc = messageCallback.getAddress ();
-    if (messageProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
-    OS.SetWindowLong (hwndMessage, OS.GWL_WNDPROC, messageProc);
+    //messageCallback = new Callback (this, "messageProc", 4); //$NON-NLS-1$
+    //messageProc_ = messageCallback.getAddress ();
+    //if (messageProc_ is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+    OS.SetWindowLong (hwndMessage, OS.GWL_WNDPROC, cast(int) &messageProcFunc);
 
     /* Create the filter hook */
-    if (!OS.IsWinCE) {
-        msgFilterCallback = new Callback (this, "msgFilterProc", 3); //$NON-NLS-1$
-        msgFilterProc = msgFilterCallback.getAddress ();
-        if (msgFilterProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
-        filterHook = OS.SetWindowsHookEx (OS.WH_MSGFILTER, msgFilterProc, 0, threadId);
+    static if (!OS.IsWinCE) {
+        //msgFilterCallback = new Callback (this, "msgFilterProc", 3); //$NON-NLS-1$
+        //msgFilterProc_ = msgFilterCallback.getAddress ();
+        //if (msgFilterProc_ is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+        filterHook = OS.SetWindowsHookEx (OS.WH_MSGFILTER, &msgFilterProcFunc, null, threadId);
     }
 
     /* Create the idle hook */
-    if (!OS.IsWinCE) {
-        foregroundIdleCallback = new Callback (this, "foregroundIdleProc", 3); //$NON-NLS-1$
-        foregroundIdleProc = foregroundIdleCallback.getAddress ();
-        if (foregroundIdleProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
-        idleHook = OS.SetWindowsHookEx (OS.WH_FOREGROUNDIDLE, foregroundIdleProc, 0, threadId);
+    static if (!OS.IsWinCE) {
+        //foregroundIdleCallback = new Callback (this, "foregroundIdleProc", 3); //$NON-NLS-1$
+        //foregroundIdleProc_ = foregroundIdleCallback.getAddress ();
+        //if (foregroundIdleProc_ is 0) error (DWT.ERROR_NO_MORE_CALLBACKS);
+        idleHook = OS.SetWindowsHookEx (OS.WH_FOREGROUNDIDLE, &foregroundIdleProcFunc, null, threadId);
     }
 
     /* Register custom messages message */
-    SWT_TASKBARCREATED = OS.RegisterWindowMessage (new TCHAR (0, "TaskbarCreated", true));
-    SWT_RESTORECARET = OS.RegisterWindowMessage (new TCHAR (0, "SWT_RESTORECARET", true));
+    SWT_TASKBARCREATED = OS.RegisterWindowMessage (StrToTCHARz ( "TaskbarCreated" ));
+    SWT_RESTORECARET = OS.RegisterWindowMessage (StrToTCHARz ( "SWT_RESTORECARET"));
 
     /* Initialize OLE */
-    if (!OS.IsWinCE) OS.OleInitialize (0);
+    static if (!OS.IsWinCE) OS.OleInitialize (null);
 
     /* Initialize buffered painting */
     if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)){
@@ -2587,8 +2593,8 @@
  * @param hDC the platform specific GC handle
  * @param data the platform specific GC data
  */
-public void internal_dispose_GC (int hDC, GCData data) {
-    OS.ReleaseDC (0, hDC);
+public void internal_dispose_GC (HDC hDC, GCData data) {
+    OS.ReleaseDC (null, hDC);
 }
 
 bool isXMouseActive () {
@@ -2596,21 +2602,22 @@
     * NOTE: X-Mouse is active when bit 1 of the UserPreferencesMask is set.
     */
     bool xMouseActive = false;
-    TCHAR key = new TCHAR (0, "Control Panel\\Desktop", true); //$NON-NLS-1$
-    int [] phKey = new int [1];
-    int result = OS.RegOpenKeyEx (OS.HKEY_CURRENT_USER, key, 0, OS.KEY_READ, phKey);
+    TCHAR* key = StrToTCHARz( "Control Panel\\Desktop" ); //$NON-NLS-1$
+    void* phKey;
+    int result = OS.RegOpenKeyEx (cast(void*)OS.HKEY_CURRENT_USER, key, 0, OS.KEY_READ, &phKey);
     if (result is 0) {
-        TCHAR lpValueName = new TCHAR (0, "UserPreferencesMask", true); //$NON-NLS-1$
-        int [] lpcbData = new int [] {4}, lpData = new int [1];
-        result = OS.RegQueryValueEx (phKey [0], lpValueName, 0, null, lpData, lpcbData);
-        if (result is 0) xMouseActive = (lpData [0] & 0x01) !is 0;
-        OS.RegCloseKey (phKey [0]);
+        TCHAR* lpValueName = StrToTCHARz ( "UserPreferencesMask" ); //$NON-NLS-1$
+        uint[4] lpcbData;
+        uint lpData;
+        result = OS.RegQueryValueEx (phKey, lpValueName, null, null, cast(ubyte*)&lpData, lpcbData.ptr);
+        if (result is 0) xMouseActive = (lpData & 0x01) !is 0;
+        OS.RegCloseKey (phKey);
     }
     return xMouseActive;
 }
 
 bool isValidThread () {
-    return thread is Thread.currentThread ();
+    return thread is Thread.getThis ();
 }
 
 /**
@@ -2696,12 +2703,12 @@
     if (from !is null && from.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
     if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
     if (from is to) return new Point (x, y);
-    int hwndFrom = from !is null ? from.handle : 0;
-    int hwndTo = to !is null ? to.handle : 0;
-    POINT point = new POINT ();
+    auto hwndFrom = from !is null ? from.handle : null;
+    auto hwndTo = to !is null ? to.handle : null;
+    POINT point;
     point.x = x;
     point.y = y;
-    OS.MapWindowPoints (hwndFrom, hwndTo, point, 1);
+    OS.MapWindowPoints (hwndFrom, hwndTo, &point, 1);
     return new Point (point.x, point.y);
 }
 
@@ -2790,14 +2797,14 @@
     if (from !is null && from.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
     if (to !is null && to.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
     if (from is to) return new Rectangle (x, y, width, height);
-    int hwndFrom = from !is null ? from.handle : 0;
-    int hwndTo = to !is null ? to.handle : 0;
-    RECT rect = new RECT ();
+    auto hwndFrom = from !is null ? from.handle : null;
+    auto hwndTo = to !is null ? to.handle : null;
+    RECT rect;
     rect.left = x;
     rect.top  = y;
     rect.right = x + width;
     rect.bottom = y + height;
-    OS.MapWindowPoints (hwndFrom, hwndTo, rect, 2);
+    OS.MapWindowPoints (hwndFrom, hwndTo, cast(POINT*)&rect, 2);
     return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
 }
 
@@ -2822,27 +2829,32 @@
  * @param codePage the code page used to convert the character
  * @return the WCS character
  */
-static char mbcsToWcs (int ch, int codePage) {
-    if (OS.IsUnicode) return (char) ch;
+static wchar mbcsToWcs (int ch, int codePage) {
+    if (OS.IsUnicode) return cast(wchar) ch;
     int key = ch & 0xFFFF;
-    if (key <= 0x7F) return (char) ch;
-    byte [] buffer;
+    if (key <= 0x7F) return cast(wchar) ch;
+    char [] buffer;
     if (key <= 0xFF) {
-        buffer = new byte [1];
-        buffer [0] = (byte) key;
+        buffer = new char [1];
+        buffer [0] = cast(char) key;
     } else {
-        buffer = new byte [2];
-        buffer [0] = (byte) ((key >> 8) & 0xFF);
-        buffer [1] = (byte) (key & 0xFF);
+        buffer = new char [2];
+        buffer [0] = cast(char) ((key >> 8) & 0xFF);
+        buffer [1] = cast(char) (key & 0xFF);
     }
-    char [] unicode = new char [1];
+    wchar [] unicode = new wchar [1];
     int cp = codePage !is 0 ? codePage : OS.CP_ACP;
-    int count = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer, buffer.length, unicode, 1);
+    int count = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer.ptr, buffer.length, unicode.ptr, 1);
     if (count is 0) return 0;
     return unicode [0];
 }
 
-int messageProc (int hwnd, int msg, int wParam, int lParam) {
+private static extern(Windows) int messageProcFunc (HWND hwnd, uint msg, uint wParam, int lParam) {
+    Display d = Display.getCurrent();
+    return d.messageProc( hwnd, msg, wParam, lParam );
+}
+
+int messageProc (HWND hwnd, uint msg, uint wParam, int lParam) {
     switch (msg) {
         case SWT_RUNASYNC: {
             if (runMessagesInIdle) runAsyncMessages (false);
@@ -2850,8 +2862,7 @@
         }
         case SWT_KEYMSG: {
             bool consumed = false;
-            MSG keyMsg = new MSG ();
-            OS.MoveMemory (keyMsg, lParam, MSG.sizeof);
+            MSG* keyMsg = cast(MSG*) lParam;
             Control control = findControl (keyMsg.hwnd);
             if (control !is null) {
                 /*
@@ -2937,8 +2948,8 @@
                 }
             }
             if (consumed) {
-                int hHeap = OS.GetProcessHeap ();
-                OS.HeapFree (hHeap, 0, lParam);
+                auto hHeap = OS.GetProcessHeap ();
+                OS.HeapFree (hHeap, 0, cast(void*)lParam);
             } else {
                 OS.PostMessage (embeddedHwnd, SWT_KEYMSG, wParam, lParam);
             }
@@ -2981,13 +2992,13 @@
                     if (modalDialogShell !is null && modalDialogShell.isDisposed ()) modalDialogShell = null;
                     Shell modal = modalDialogShell !is null ? modalDialogShell : getModalShell ();
                     if (modal !is null) {
-                        int hwndModal = modal.handle;
+                        auto hwndModal = modal.handle;
                         if (OS.IsWindowEnabled (hwndModal)) {
                             modal.bringToTop ();
                             if (modal.isDisposed ()) break;
                         }
-                        int hwndPopup = OS.GetLastActivePopup (hwndModal);
-                        if (hwndPopup !is 0 && hwndPopup !is modal.handle) {
+                        auto hwndPopup = OS.GetLastActivePopup (hwndModal);
+                        if (hwndPopup !is null && hwndPopup !is modal.handle) {
                             if (getControl (hwndPopup) is null) {
                                 if (OS.IsWindowEnabled (hwndPopup)) {
                                     OS.SetActiveWindow (hwndPopup);
@@ -3022,18 +3033,18 @@
                 case 0:
                 case 1:
                 case OS.SPI_SETHIGHCONTRAST:
-                    OS.SetTimer (hwndMessage, SETTINGS_ID, SETTINGS_DELAY, 0);
+                    OS.SetTimer (hwndMessage, SETTINGS_ID, SETTINGS_DELAY, null);
             }
             break;
         }
         case OS.WM_THEMECHANGED: {
             if (OS.COMCTL32_MAJOR >= 6) {
-                if (hButtonTheme !is 0) OS.CloseThemeData (hButtonTheme);
-                if (hEditTheme !is 0) OS.CloseThemeData (hEditTheme);
-                if (hExplorerBarTheme !is 0) OS.CloseThemeData (hExplorerBarTheme);
-                if (hScrollBarTheme !is 0) OS.CloseThemeData (hScrollBarTheme);
-                if (hTabTheme !is 0) OS.CloseThemeData (hTabTheme);
-                hButtonTheme = hEditTheme = hExplorerBarTheme = hScrollBarTheme = hTabTheme = 0;
+                if (hButtonTheme_ !is null) OS.CloseThemeData (hButtonTheme_);
+                if (hEditTheme_ !is null) OS.CloseThemeData (hEditTheme_);
+                if (hExplorerBarTheme_ !is null) OS.CloseThemeData (hExplorerBarTheme_);
+                if (hScrollBarTheme_ !is null) OS.CloseThemeData (hScrollBarTheme_);
+                if (hTabTheme_ !is null) OS.CloseThemeData (hTabTheme_);
+                hButtonTheme_ = hEditTheme_ = hExplorerBarTheme_ = hScrollBarTheme_ = hTabTheme_ = null;
             }
             break;
         }
@@ -3061,34 +3072,43 @@
     return OS.DefWindowProc (hwnd, msg, wParam, lParam);
 }
 
-int monitorEnumProc (int hmonitor, int hdc, int lprcMonitor, int dwData) {
+private static extern(Windows) int monitorEnumFunc (HMONITOR hmonitor, HDC hdc, RECT* lprcMonitor, int dwData) {
+    auto d = cast(Display)cast(void*)dwData;
+    return d.monitorEnumProc( hmonitor, hdc, lprcMonitor );
+}
+int monitorEnumProc (HMONITOR hmonitor, HDC hdc, RECT* lprcMonitor) {
     if (monitorCount >= monitors.length) {
-        Monitor[] newMonitors = new Monitor [monitors.length + 4];
+        dwt.widgets.Monitor.Monitor[] newMonitors = new dwt.widgets.Monitor.Monitor [monitors.length + 4];
         System.arraycopy (monitors, 0, newMonitors, 0, monitors.length);
         monitors = newMonitors;
     }
-    MONITORINFO lpmi = new MONITORINFO ();
+    MONITORINFO lpmi;
     lpmi.cbSize = MONITORINFO.sizeof;
-    OS.GetMonitorInfo (hmonitor, lpmi);
-    Monitor monitor = new Monitor ();
+    OS.GetMonitorInfo (hmonitor, &lpmi);
+    dwt.widgets.Monitor.Monitor monitor = new dwt.widgets.Monitor.Monitor ();
     monitor.handle = hmonitor;
-    monitor.x = lpmi.rcMonitor_left;
-    monitor.y = lpmi.rcMonitor_top;
-    monitor.width = lpmi.rcMonitor_right - lpmi.rcMonitor_left;
-    monitor.height = lpmi.rcMonitor_bottom - lpmi.rcMonitor_top;
-    monitor.clientX = lpmi.rcWork_left;
-    monitor.clientY = lpmi.rcWork_top;
-    monitor.clientWidth = lpmi.rcWork_right - lpmi.rcWork_left;
-    monitor.clientHeight = lpmi.rcWork_bottom - lpmi.rcWork_top;
+    monitor.x = lpmi.rcMonitor.left;
+    monitor.y = lpmi.rcMonitor.top;
+    monitor.width = lpmi.rcMonitor.right - lpmi.rcMonitor.left;
+    monitor.height = lpmi.rcMonitor.bottom - lpmi.rcMonitor.top;
+    monitor.clientX = lpmi.rcWork.left;
+    monitor.clientY = lpmi.rcWork.top;
+    monitor.clientWidth = lpmi.rcWork.right - lpmi.rcWork.left;
+    monitor.clientHeight = lpmi.rcWork.bottom - lpmi.rcWork.top;
     monitors [monitorCount++] = monitor;
     return 1;
 }
 
+private static extern(Windows) int msgFilterProcFunc (int code, int wParam, int lParam) {
+    Display pThis = Display.getCurrent();
+    return pThis.msgFilterProc( code, wParam, lParam );
+}
+
 int msgFilterProc (int code, int wParam, int lParam) {
     switch (code) {
         case OS.MSGF_COMMCTRL_BEGINDRAG: {
             if (!runDragDrop) {
-                OS.MoveMemory (hookMsg, lParam, MSG.sizeof);
+                hookMsg = *cast(MSG*)lParam;
                 if (hookMsg.message is OS.WM_MOUSEMOVE) {
                     OS.SendMessage (hookMsg.hwnd, OS.WM_CANCELMODE, 0, 0);
                 }
@@ -3111,11 +3131,11 @@
         case OS.MSGF_SCROLLBAR:
         case OS.MSGF_SIZE: {
             if (runMessages) {
-                OS.MoveMemory (hookMsg, lParam, MSG.sizeof);
+                hookMsg = *cast(MSG*)lParam;
                 if (hookMsg.message is OS.WM_NULL) {
-                    MSG msg = new MSG ();
+                    MSG msg;
                     int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE;
-                    if (!OS.PeekMessage (msg, 0, 0, 0, flags)) {
+                    if (!OS.PeekMessage (&msg, null, 0, 0, flags)) {
                         if (runAsyncMessages (false)) wakeThread ();
                     }
                 }
@@ -3208,27 +3228,27 @@
     switch (type){
         case DWT.KeyDown:
         case DWT.KeyUp: {
-            KEYBDINPUT inputs = new KEYBDINPUT ();
-            inputs.wVk = (short) untranslateKey (event.keyCode);
+            KEYBDINPUT inputs;
+            inputs.wVk = cast(short) untranslateKey (event.keyCode);
             if (inputs.wVk is 0) {
                 char key = event.character;
                 switch (key) {
-                    case DWT.BS: inputs.wVk = (short) OS.VK_BACK; break;
-                    case DWT.CR: inputs.wVk = (short) OS.VK_RETURN; break;
-                    case DWT.DEL: inputs.wVk = (short) OS.VK_DELETE; break;
-                    case DWT.ESC: inputs.wVk = (short) OS.VK_ESCAPE; break;
-                    case DWT.TAB: inputs.wVk = (short) OS.VK_TAB; break;
+                    case DWT.BS: inputs.wVk = cast(short) OS.VK_BACK; break;
+                    case DWT.CR: inputs.wVk = cast(short) OS.VK_RETURN; break;
+                    case DWT.DEL: inputs.wVk = cast(short) OS.VK_DELETE; break;
+                    case DWT.ESC: inputs.wVk = cast(short) OS.VK_ESCAPE; break;
+                    case DWT.TAB: inputs.wVk = cast(short) OS.VK_TAB; break;
                     /*
                     * Since there is no LF key on the keyboard, do not attempt
                     * to map LF to CR or attempt to post an LF key.
                     */
-//                  case DWT.LF: inputs.wVk = (short) OS.VK_RETURN; break;
+//                  case DWT.LF: inputs.wVk = cast(short) OS.VK_RETURN; break;
                     case DWT.LF: return false;
                     default: {
                         if (OS.IsWinCE) {
-                            inputs.wVk = OS.CharUpper ((short) key);
+                            inputs.wVk = cast(int)OS.CharUpper (cast(wchar*) key);
                         } else {
-                            inputs.wVk = OS.VkKeyScan ((short) wcsToMbcs (key, 0));
+                            inputs.wVk = OS.VkKeyScan (cast(short) wcsToMbcs (key, 0));
                             if (inputs.wVk is -1) return false;
                             inputs.wVk &= 0xFF;
                         }
@@ -3236,10 +3256,11 @@
                 }
             }
             inputs.dwFlags = type is DWT.KeyUp ? OS.KEYEVENTF_KEYUP : 0;
-            int hHeap = OS.GetProcessHeap ();
-            int pInputs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
-            OS.MoveMemory(pInputs, new int[] {OS.INPUT_KEYBOARD}, 4);
-            OS.MoveMemory (pInputs + 4, inputs, KEYBDINPUT.sizeof);
+            auto hHeap = OS.GetProcessHeap ();
+            auto pInputs = cast(INPUT*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
+            pInputs.type = OS.INPUT_KEYBOARD;
+            pInputs.ki = inputs;
+            //OS.MoveMemory (pInputs + 4, inputs, KEYBDINPUT.sizeof);
             bool result = OS.SendInput (1, pInputs, INPUT.sizeof) !is 0;
             OS.HeapFree (hHeap, 0, pInputs);
             return result;
@@ -3248,7 +3269,7 @@
         case DWT.MouseMove:
         case DWT.MouseUp:
         case DWT.MouseWheel: {
-            MOUSEINPUT inputs = new MOUSEINPUT ();
+            MOUSEINPUT inputs;
             if (type is DWT.MouseMove){
                 inputs.dwFlags = OS.MOUSEEVENTF_MOVE | OS.MOUSEEVENTF_ABSOLUTE;
                 int x= 0, y = 0, width = 0, height = 0;
@@ -3273,9 +3294,9 @@
                             inputs.mouseData = event.count * OS.WHEEL_DELTA;
                             break;
                         case DWT.SCROLL_LINE:
-                            int [] value = new int [1];
-                            OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, value, 0);
-                            inputs.mouseData = event.count * OS.WHEEL_DELTA / value [0];
+                            int value;
+                            OS.SystemParametersInfo (OS.SPI_GETWHEELSCROLLLINES, 0, &value, 0);
+                            inputs.mouseData = event.count * OS.WHEEL_DELTA / value;
                             break;
                         default: return false;
                     }
@@ -3300,10 +3321,12 @@
                     }
                 }
             }
-            int hHeap = OS.GetProcessHeap ();
-            int pInputs = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
-            OS.MoveMemory(pInputs, new int[] {OS.INPUT_MOUSE}, 4);
-            OS.MoveMemory (pInputs + 4, inputs, MOUSEINPUT.sizeof);
+            auto hHeap = OS.GetProcessHeap ();
+            auto pInputs = cast(INPUT*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, INPUT.sizeof);
+            pInputs.type = OS.INPUT_MOUSE;
+            //OS.MoveMemory(pInputs, [OS.INPUT_MOUSE], 4);
+            pInputs.mi = inputs;
+            //OS.MoveMemory (pInputs + 4, inputs, MOUSEINPUT.sizeof);
             bool result = OS.SendInput (1, pInputs, INPUT.sizeof) !is 0;
             OS.HeapFree (hHeap, 0, pInputs);
             return result;
@@ -3321,14 +3344,14 @@
     */
     if (eventQueue is null) eventQueue = new Event [4];
     int index = 0;
-    int length = eventQueue.length;
-    while (index < length) {
+    int length_ = eventQueue.length;
+    while (index < length_) {
         if (eventQueue [index] is null) break;
         index++;
     }
-    if (index is length) {
-        Event [] newQueue = new Event [length + 4];
-        System.arraycopy (eventQueue, 0, newQueue, 0, length);
+    if (index is length_) {
+        Event [] newQueue = new Event [length_ + 4];
+        System.arraycopy (eventQueue, 0, newQueue, 0, length_);
         eventQueue = newQueue;
     }
     eventQueue [index] = event;
@@ -3360,13 +3383,13 @@
  */
 public bool readAndDispatch () {
     checkDevice ();
-    lpStartupInfo = null;
+    //lpStartupInfo = null;
     drawMenuBars ();
     runPopups ();
-    if (OS.PeekMessage (msg, 0, 0, 0, OS.PM_REMOVE)) {
-        if (!filterMessage (msg)) {
-            OS.TranslateMessage (msg);
-            OS.DispatchMessage (msg);
+    if (OS.PeekMessage (&msg, null, 0, 0, OS.PM_REMOVE)) {
+        if (!filterMessage (&msg)) {
+            OS.TranslateMessage (&msg);
+            OS.DispatchMessage (&msg);
         }
         runDeferredEvents ();
         return true;
@@ -3434,62 +3457,62 @@
 }
 
 void releaseDisplay () {
-    if (embeddedHwnd !is 0) {
+    if (embeddedHwnd !is null) {
         OS.PostMessage (embeddedHwnd, SWT_DESTROY, 0, 0);
     }
 
     /* Release XP Themes */
     if (OS.COMCTL32_MAJOR >= 6) {
-        if (hButtonTheme !is 0) OS.CloseThemeData (hButtonTheme);
-        if (hEditTheme !is 0) OS.CloseThemeData (hEditTheme);
-        if (hExplorerBarTheme !is 0) OS.CloseThemeData (hExplorerBarTheme);
-        if (hScrollBarTheme !is 0) OS.CloseThemeData (hScrollBarTheme);
-        if (hTabTheme !is 0) OS.CloseThemeData (hTabTheme);
-        hButtonTheme = hEditTheme = hExplorerBarTheme = hScrollBarTheme = hTabTheme = 0;
+        if (hButtonTheme_ !is null) OS.CloseThemeData (hButtonTheme_);
+        if (hEditTheme_ !is null) OS.CloseThemeData (hEditTheme_);
+        if (hExplorerBarTheme_ !is null) OS.CloseThemeData (hExplorerBarTheme_);
+        if (hScrollBarTheme_ !is null) OS.CloseThemeData (hScrollBarTheme_);
+        if (hTabTheme_ !is null) OS.CloseThemeData (hTabTheme_);
+        hButtonTheme_ = hEditTheme_ = hExplorerBarTheme_ = hScrollBarTheme_ = hTabTheme_ = null;
     }
 
     /* Unhook the message hook */
-    if (!OS.IsWinCE) {
-        if (msgHook !is 0) OS.UnhookWindowsHookEx (msgHook);
-        msgHook = 0;
+    static if (!OS.IsWinCE) {
+        if (msgHook !is null) OS.UnhookWindowsHookEx (msgHook);
+        msgHook = null;
     }
 
     /* Unhook the filter hook */
-    if (!OS.IsWinCE) {
-        if (filterHook !is 0) OS.UnhookWindowsHookEx (filterHook);
-        filterHook = 0;
-        msgFilterCallback.dispose ();
-        msgFilterCallback = null;
-        msgFilterProc = 0;
+    static if (!OS.IsWinCE) {
+        if (filterHook !is null) OS.UnhookWindowsHookEx (filterHook);
+        filterHook = null;
+        //msgFilterCallback.dispose ();
+        //msgFilterCallback = null;
+        //msgFilterProc_ = 0;
     }
 
     /* Unhook the idle hook */
     if (!OS.IsWinCE) {
-        if (idleHook !is 0) OS.UnhookWindowsHookEx (idleHook);
-        idleHook = 0;
-        foregroundIdleCallback.dispose ();
-        foregroundIdleCallback = null;
-        foregroundIdleProc = 0;
+        if (idleHook !is null) OS.UnhookWindowsHookEx (idleHook);
+        idleHook = null;
+        //foregroundIdleCallback.dispose ();
+        //foregroundIdleCallback = null;
+        //foregroundIdleProc_ = 0;
     }
 
     /* Destroy the message only HWND */
-    if (hwndMessage !is 0) OS.DestroyWindow (hwndMessage);
-    hwndMessage = 0;
-    messageCallback.dispose ();
-    messageCallback = null;
-    messageProc = 0;
+    if (hwndMessage !is null) OS.DestroyWindow (hwndMessage);
+    hwndMessage = null;
+    //messageCallback.dispose ();
+    //messageCallback = null;
+    //messageProc_ = 0;
 
     /* Unregister the DWT window class */
-    int hHeap = OS.GetProcessHeap ();
-    int hInstance = OS.GetModuleHandle (null);
+    auto hHeap = OS.GetProcessHeap ();
+    auto hInstance = OS.GetModuleHandle (null);
     OS.UnregisterClass (windowClass, hInstance);
 
     /* Unregister the DWT drop shadow window class */
     OS.UnregisterClass (windowShadowClass, hInstance);
     windowClass = windowShadowClass = null;
-    windowCallback.dispose ();
-    windowCallback = null;
-    windowProc = 0;
+    //windowCallback.dispose ();
+    //windowCallback = null;
+    //windowProc_ = 0;
 
     /* Release the System fonts */
     if (systemFont !is null) systemFont.dispose ();
@@ -3523,11 +3546,11 @@
     }
 
     /* Release Custom Colors for ChooseColor */
-    if (lpCustColors !is 0) OS.HeapFree (hHeap, 0, lpCustColors);
-    lpCustColors = 0;
+    if (lpCustColors !is null) OS.HeapFree (hHeap, 0, lpCustColors);
+    lpCustColors = null;
 
     /* Uninitialize OLE */
-    if (!OS.IsWinCE) OS.OleUninitialize ();
+    static if (!OS.IsWinCE) OS.OleUninitialize ();
 
     /* Uninitialize buffered painting */
     if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) {
@@ -3536,8 +3559,8 @@
 
     /* Release references */
     thread = null;
-    msg = null;
-    keyboard = null;
+    //msg = null;
+    //keyboard = null;
     modalDialogShell = null;
     modalShells = null;
     data = null;
@@ -3552,14 +3575,14 @@
 
 void releaseImageList (ImageList list) {
     int i = 0;
-    int length = imageList.length;
-    while (i < length) {
+    int length_ = imageList.length;
+    while (i < length_) {
         if (imageList [i] is list) {
             if (list.removeRef () > 0) return;
             list.dispose ();
-            System.arraycopy (imageList, i + 1, imageList, i, --length - i);
-            imageList [length] = null;
-            for (int j=0; j<length; j++) {
+            System.arraycopy (imageList, i + 1, imageList, i, --length_ - i);
+            imageList [length_] = null;
+            for (int j=0; j<length_; j++) {
                 if (imageList [j] !is null) return;
             }
             imageList = null;
@@ -3571,14 +3594,14 @@
 
 void releaseToolImageList (ImageList list) {
     int i = 0;
-    int length = toolImageList.length;
-    while (i < length) {
+    int length_ = toolImageList.length;
+    while (i < length_) {
         if (toolImageList [i] is list) {
             if (list.removeRef () > 0) return;
             list.dispose ();
-            System.arraycopy (toolImageList, i + 1, toolImageList, i, --length - i);
-            toolImageList [length] = null;
-            for (int j=0; j<length; j++) {
+            System.arraycopy (toolImageList, i + 1, toolImageList, i, --length_ - i);
+            toolImageList [length_] = null;
+            for (int j=0; j<length_; j++) {
                 if (toolImageList [j] !is null) return;
             }
             toolImageList = null;
@@ -3590,14 +3613,14 @@
 
 void releaseToolHotImageList (ImageList list) {
     int i = 0;
-    int length = toolHotImageList.length;
-    while (i < length) {
+    int length_ = toolHotImageList.length;
+    while (i < length_) {
         if (toolHotImageList [i] is list) {
             if (list.removeRef () > 0) return;
             list.dispose ();
-            System.arraycopy (toolHotImageList, i + 1, toolHotImageList, i, --length - i);
-            toolHotImageList [length] = null;
-            for (int j=0; j<length; j++) {
+            System.arraycopy (toolHotImageList, i + 1, toolHotImageList, i, --length_ - i);
+            toolHotImageList [length_] = null;
+            for (int j=0; j<length_; j++) {
                 if (toolHotImageList [j] !is null) return;
             }
             toolHotImageList = null;
@@ -3609,14 +3632,14 @@
 
 void releaseToolDisabledImageList (ImageList list) {
     int i = 0;
-    int length = toolDisabledImageList.length;
-    while (i < length) {
+    int length_ = toolDisabledImageList.length;
+    while (i < length_) {
         if (toolDisabledImageList [i] is list) {
             if (list.removeRef () > 0) return;
             list.dispose ();
-            System.arraycopy (toolDisabledImageList, i + 1, toolDisabledImageList, i, --length - i);
-            toolDisabledImageList [length] = null;
-            for (int j=0; j<length; j++) {
+            System.arraycopy (toolDisabledImageList, i + 1, toolDisabledImageList, i, --length_ - i);
+            toolDisabledImageList [length_] = null;
+            for (int j=0; j<length_; j++) {
                 if (toolDisabledImageList [j] !is null) return;
             }
             toolDisabledImageList = null;
@@ -3696,13 +3719,13 @@
     }
 }
 
-Control removeControl (int handle) {
-    if (handle is 0) return null;
+Control removeControl (HANDLE handle) {
+    if (handle is null) return null;
     lastControl = lastGetControl = null;
     Control control = null;
     int index;
-    if (USE_PROPERTY) {
-        index = OS.RemoveProp (handle, SWT_OBJECT_INDEX) - 1;
+    static if (USE_PROPERTY) {
+        index = cast(int)OS.RemoveProp (handle, cast(wchar*)SWT_OBJECT_INDEX) - 1;
     } else {
         index = OS.GetWindowLong (handle, OS.GWL_USERDATA) - 1;
     }
@@ -3748,9 +3771,9 @@
         /* Take an event off the queue */
         Event event = eventQueue [0];
         if (event is null) break;
-        int length = eventQueue.length;
-        System.arraycopy (eventQueue, 1, eventQueue, 0, --length);
-        eventQueue [length] = null;
+        int length_ = eventQueue.length;
+        System.arraycopy (eventQueue, 1, eventQueue, 0, --length_);
+        eventQueue [length_] = null;
 
         /* Run the event */
         Widget widget = event.widget;
@@ -3779,9 +3802,9 @@
     while (popups !is null) {
         Menu menu = popups [0];
         if (menu is null) break;
-        int length = popups.length;
-        System.arraycopy (popups, 1, popups, 0, --length);
-        popups [length] = null;
+        int length_ = popups.length;
+        System.arraycopy (popups, 1, popups, 0, --length_);
+        popups [length_] = null;
         runDeferredEvents ();
         if (!menu.isDisposed ()) menu._setVisible (true);
         result = true;
@@ -3796,7 +3819,7 @@
     updateImages ();
     sendEvent (DWT.Settings, null);
     Font newFont = getSystemFont ();
-    bool sameFont = oldFont.equals (newFont);
+    bool sameFont = cast(bool)( oldFont ==/*eq*/ newFont );
     Shell [] shells = getShells ();
     for (int i=0; i<shells.length; i++) {
         Shell shell = shells [i];
@@ -3841,10 +3864,10 @@
     }
     if (systemFont !is null) {
         if (!OS.IsWinCE) {
-            NONCLIENTMETRICS info = OS.IsUnicode ? (NONCLIENTMETRICS) new NONCLIENTMETRICSW () : new NONCLIENTMETRICSA ();
+            NONCLIENTMETRICS info;
             info.cbSize = NONCLIENTMETRICS.sizeof;
-            if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, info, 0)) {
-                LOGFONT logFont = OS.IsUnicode ? (LOGFONT) ((NONCLIENTMETRICSW)info).lfMessageFont : ((NONCLIENTMETRICSA)info).lfMessageFont;
+            if (OS.SystemParametersInfo (OS.SPI_GETNONCLIENTMETRICS, 0, &info, 0)) {
+                LOGFONT* logFont = &info.lfMessageFont;
                 if (lfSystemFont is null ||
                     logFont.lfCharSet !is lfSystemFont.lfCharSet ||
                     logFont.lfHeight !is lfSystemFont.lfHeight ||
@@ -3860,7 +3883,7 @@
                     logFont.lfClipPrecision !is lfSystemFont.lfClipPrecision ||
                     logFont.lfQuality !is lfSystemFont.lfQuality ||
                     logFont.lfPitchAndFamily !is lfSystemFont.lfPitchAndFamily ||
-                    !getFontName (logFont).equals (getFontName (lfSystemFont))) {
+                    getFontName (logFont) !=/*eq*/ getFontName (lfSystemFont)) {
                         resources [resourceCount++] = systemFont;
                         lfSystemFont = logFont;
                         systemFont = null;
@@ -3963,13 +3986,13 @@
  * @see #getData(String)
  * @see #disposeExec(Runnable)
  */
-public void setData (String key, Object value) {
+public void setData (char[] key, Object value) {
     checkDevice ();
     if (key is null) error (DWT.ERROR_NULL_ARGUMENT);
 
-    if (key.equals (RUN_MESSAGES_IN_IDLE_KEY)) {
-        bool data = (bool) value;
-        runMessagesInIdle = data !is null && data.booleanValue ();
+    if (key ==/*eq*/RUN_MESSAGES_IN_IDLE_KEY) {
+        auto data = cast(ValueWrapperBool) value;
+        runMessagesInIdle = data !is null && data.value;
         return;
     }
 
@@ -3977,13 +4000,13 @@
     if (value is null) {
         if (keys is null) return;
         int index = 0;
-        while (index < keys.length && !keys [index].equals (key)) index++;
+        while (index < keys.length && keys [index]!=/*eq*/key) index++;
         if (index is keys.length) return;
         if (keys.length is 1) {
             keys = null;
             values = null;
         } else {
-            String [] newKeys = new String [keys.length - 1];
+            char[] [] newKeys = new char[] [keys.length - 1];
             Object [] newValues = new Object [values.length - 1];
             System.arraycopy (keys, 0, newKeys, 0, index);
             System.arraycopy (keys, index + 1, newKeys, index, newKeys.length - index);
@@ -3997,17 +4020,19 @@
 
     /* Add the key/value pair */
     if (keys is null) {
-        keys = new String [] {key};
-        values = new Object [] {value};
+        keys.length = 1;
+        values.length = 1;
+        keys[0] = key;
+        values[0] = value;
         return;
     }
     for (int i=0; i<keys.length; i++) {
-        if (keys [i].equals (key)) {
+        if (keys [i] ==/*eq*/key ) {
             values [i] = value;
             return;
         }
     }
-    String [] newKeys = new String [keys.length + 1];
+    char[] [] newKeys = new char[] [keys.length + 1];
     Object [] newValues = new Object [values.length + 1];
     System.arraycopy (keys, 0, newKeys, 0, keys.length);
     System.arraycopy (values, 0, newValues, 0, values.length);
@@ -4053,7 +4078,7 @@
  *
  * @param name the new app name or <code>null</code>
  */
-public static void setAppName (String name) {
+public static void setAppName (char[] name) {
     /* Do nothing */
 }
 
@@ -4066,15 +4091,15 @@
 
 void setModalShell (Shell shell) {
     if (modalShells is null) modalShells = new Shell [4];
-    int index = 0, length = modalShells.length;
-    while (index < length) {
+    int index = 0, length_ = modalShells.length;
+    while (index < length_) {
         if (modalShells [index] is shell) return;
         if (modalShells [index] is null) break;
         index++;
     }
-    if (index is length) {
-        Shell [] newModalShells = new Shell [length + 4];
-        System.arraycopy (modalShells, 0, newModalShells, 0, length);
+    if (index is length_) {
+        Shell [] newModalShells = new Shell [length_ + 4];
+        System.arraycopy (modalShells, 0, newModalShells, 0, length_);
         modalShells = newModalShells;
     }
     modalShells [index] = shell;
@@ -4114,12 +4139,12 @@
     keyboard [OS.VK_SHIFT] |= 0x80;
 
     /* Translate the key to ASCII or UNICODE using the virtual keyboard */
-    if (OS.IsUnicode) {
-        char [] result = new char [1];
-        if (OS.ToUnicode (key, key, keyboard, result, 1, 0) is 1) return result [0];
+    static if (OS.IsUnicode) {
+        wchar result;
+        if (OS.ToUnicode (key, key, keyboard.ptr, &result, 1, 0) is 1) return result;
     } else {
-        short [] result = new short [1];
-        if (OS.ToAscii (key, key, keyboard, result, 0) is 1) return result [0];
+        wchar result;
+        if (OS.ToAscii (key, key, keyboard.ptr, &result, 0) is 1) return result;
     }
     return 0;
 }
@@ -4141,11 +4166,11 @@
 public bool sleep () {
     checkDevice ();
     if (runMessages && getMessageCount () !is 0) return true;
-    if (OS.IsWinCE) {
-        OS.MsgWaitForMultipleObjectsEx (0, 0, OS.INFINITE, OS.QS_ALLINPUT, OS.MWMO_INPUTAVAILABLE);
+    static if (OS.IsWinCE) {
+        OS.MsgWaitForMultipleObjectsEx (0, null, OS.INFINITE, OS.QS_ALLINPUT, OS.MWMO_INPUTAVAILABLE);
         return true;
     }
-    return OS.WaitMessage ();
+    return cast(bool) OS.WaitMessage ();
 }
 
 /**
@@ -4203,6 +4228,7 @@
 public void timerExec (int milliseconds, Runnable runnable) {
     checkDevice ();
     if (runnable is null) error (DWT.ERROR_NULL_ARGUMENT);
+    assert( runnable );
     if (timerList is null) timerList = new Runnable [4];
     if (timerIds is null) timerIds = new int [4];
     int index = 0;
@@ -4229,21 +4255,21 @@
         timerId = nextTimerId++;
         if (index is timerList.length) {
             Runnable [] newTimerList = new Runnable [timerList.length + 4];
-            System.arraycopy (timerList, 0, newTimerList, 0, timerList.length);
+            SimpleType!(Runnable).arraycopy (timerList, 0, newTimerList, 0, timerList.length);
             timerList = newTimerList;
             int [] newTimerIds = new int [timerIds.length + 4];
             System.arraycopy (timerIds, 0, newTimerIds, 0, timerIds.length);
             timerIds = newTimerIds;
         }
     }
-    int newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, 0);
+    int newTimerID = OS.SetTimer (hwndMessage, timerId, milliseconds, null);
     if (newTimerID !is 0) {
         timerList [index] = runnable;
         timerIds [index] = newTimerID;
     }
 }
 
-bool translateAccelerator (MSG msg, Control control) {
+bool translateAccelerator (MSG* msg, Control control) {
     accelKeyHit = true;
     bool result = control.translateAccelerator (msg);
     accelKeyHit = false;
@@ -4257,16 +4283,17 @@
     return 0;
 }
 
-bool translateMnemonic (MSG msg, Control control) {
+bool translateMnemonic (MSG* msg, Control control) {
     switch (msg.message) {
         case OS.WM_CHAR:
         case OS.WM_SYSCHAR:
             return control.translateMnemonic (msg);
+        default:
     }
     return false;
 }
 
-bool translateTraversal (MSG msg, Control control) {
+bool translateTraversal (MSG* msg, Control control) {
     switch (msg.message) {
         case OS.WM_KEYDOWN:
             switch (msg.wParam) {
@@ -4280,12 +4307,14 @@
                 case OS.VK_PRIOR:
                 case OS.VK_NEXT:
                     return control.translateTraversal (msg);
+                default:
             }
             break;
         case OS.WM_SYSKEYDOWN:
             switch (msg.wParam) {
                 case OS.VK_MENU:
                     return control.translateTraversal (msg);
+                default:
             }
             break;
     }
@@ -4327,9 +4356,9 @@
     */
     if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (4, 10)) {
         if (OS.IsHungAppWindow (hwndMessage)) {
-            MSG msg = new MSG ();
+            MSG msg;
             int flags = OS.PM_REMOVE | OS.PM_NOYIELD;
-            OS.PeekMessage (msg, hwndMessage, SWT_NULL, SWT_NULL, flags);
+            OS.PeekMessage (&msg, hwndMessage, SWT_NULL, SWT_NULL, flags);
         }
     }
     Shell[] shells = getShells ();
@@ -4362,7 +4391,7 @@
  */
 public void wake () {
     if (isDisposed ()) error (DWT.ERROR_DEVICE_DISPOSED);
-    if (thread is Thread.currentThread ()) return;
+    if (thread is Thread.getThis ()) return;
     wakeThread ();
 }
 
@@ -4384,11 +4413,13 @@
  * @param codePage the code page used to convert the character
  * @return the MBCS character
  */
-static int wcsToMbcs (char ch, int codePage) {
+static int wcsToMbcs (wchar ch, int codePage) {
     if (OS.IsUnicode) return ch;
     if (ch <= 0x7F) return ch;
-    TCHAR buffer = new TCHAR (codePage, ch, false);
-    return buffer.tcharAt (0);
+    wchar[1] wc;
+    wc[0] = ch;
+    auto r = StrToMBCSs( tango.text.convert.Utf.toString(wc), codePage );
+    return r[0];
 }
 
 /*
@@ -4404,7 +4435,12 @@
     return wcsToMbcs (ch, 0);
 }
 
-int windowProc (int hwnd, int msg, int wParam, int lParam) {
+private static extern(Windows) int windowProcFunc (HWND hwnd, uint msg, uint wParam, int lParam) {
+    auto d = Display.getCurrent();
+    return d.windowProc( hwnd, msg, wParam, lParam );
+}
+
+int windowProc (HWND hwnd, uint msg, uint wParam, int lParam) {
     /*
     * Bug in Adobe Reader 7.0.  For some reason, when Adobe
     * Reader 7.0 is deactivated from within Internet Explorer,
@@ -4420,7 +4456,7 @@
     */
     if (msg is OS.WM_NCHITTEST) {
         if (hitCount++ >= 1024) {
-            try {Thread.sleep (1);} catch (Throwable t) {}
+            try {Thread.sleep (0.001);} catch (Exception t) {}
         }
     } else {
         hitCount = 0;
@@ -4429,8 +4465,8 @@
         return lastControl.windowProc (hwnd, msg, wParam, lParam);
     }
     int index;
-    if (USE_PROPERTY) {
-        index = OS.GetProp (hwnd, SWT_OBJECT_INDEX) - 1;
+    static if (USE_PROPERTY) {
+        index = cast(int)OS.GetProp (hwnd, cast(wchar*)SWT_OBJECT_INDEX) - 1;
     } else {
         index = OS.GetWindowLong (hwnd, OS.GWL_USERDATA) - 1;
     }
@@ -4445,11 +4481,11 @@
     return OS.DefWindowProc (hwnd, msg, wParam, lParam);
 }
 
-static String withCrLf (String string) {
+static char[] withCrLf (char[] string) {
 
     /* If the string is empty, return the string. */
-    int length = string.length ();
-    if (length is 0) return string;
+    int length_ = string.length;
+    if (length_ is 0) return string;
 
     /*
     * Check for an LF or CR/LF and assume the rest of
@@ -4469,20 +4505,20 @@
     */
     i++;
     int count = 1;
-    while (i < length) {
+    while (i < length_) {
         if ((i = string.indexOf ('\n', i)) is -1) break;
         count++; i++;
     }
-    count += length;
+    count += length_;
 
     /* Create a new string with the CR/LF line terminator. */
     i = 0;
     StringBuffer result = new StringBuffer (count);
-    while (i < length) {
+    while (i < length_) {
         int j = string.indexOf ('\n', i);
-        if (j is -1) j = length;
+        if (j is -1) j = length_;
         result.append (string.substring (i, j));
-        if ((i = j) < length) {
+        if ((i = j) < length_) {
             result.append ("\r\n"); //$NON-NLS-1$
             i++;
         }
@@ -4491,4 +4527,3 @@
 }
 
 }
-++/
\ No newline at end of file
--- a/dwt/widgets/Menu.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/widgets/Menu.d	Mon Jan 28 21:05:39 2008 +0100
@@ -17,6 +17,8 @@
     this( Widget, int );
 public void setLocation (int x, int y) ;
 public void setVisible (bool visible) ;
+void update ();
+void _setVisible (bool visible) ;
 }
 /++
 import dwt.DWT;
--- a/dwt/widgets/MenuItem.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/widgets/MenuItem.d	Mon Jan 28 21:05:39 2008 +0100
@@ -16,6 +16,7 @@
 import dwt.widgets.Widget;
 
 class MenuItem : Item {
+    int id;
     public this (Widget parent, int style) {
         super (parent, style);
     }
--- a/dwt/widgets/Monitor.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/widgets/Monitor.d	Mon Jan 28 21:05:39 2008 +0100
@@ -13,6 +13,7 @@
 module dwt.widgets.Monitor;
 
 import dwt.graphics.Rectangle;
+import dwt.internal.win32.WINTYPES;
 
 /**
  * Instances of this class are descriptions of monitors.
@@ -22,7 +23,7 @@
  * @since 3.0
  */
 public final class Monitor {
-    int handle;
+    HMONITOR handle;
     int x, y, width, height;
     int clientX, clientY, clientWidth, clientHeight;
 
--- a/dwt/widgets/Shell.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/widgets/Shell.d	Mon Jan 28 21:05:39 2008 +0100
@@ -13,6 +13,7 @@
 import dwt.widgets.Decorations;
 class Shell : Decorations {
     void checkWidget ();
+void updateModal () ;
 }
 /++
 import dwt.DWT;
--- a/dwt/widgets/TrayItem.d	Mon Jan 28 14:13:08 2008 +0100
+++ b/dwt/widgets/TrayItem.d	Mon Jan 28 21:05:39 2008 +0100
@@ -12,11 +12,15 @@
 
 import dwt.widgets.Item;
 import dwt.widgets.Widget;
+import dwt.internal.win32.OS;
 
 class TrayItem : Item {
+    int id;
     public this (Widget parent, int style) {
         super (parent, style);
     }
+int messageProc (HWND hwnd, int msg, int wParam, int lParam) ;
+void recreate () ;
 }
 /++
 
@@ -239,7 +243,7 @@
     return visible;
 }
 
-int messageProc (int hwnd, int msg, int wParam, int lParam) {
+int messageProc (HWND hwnd, int msg, int wParam, int lParam) {
     /*
     * Feature in Windows.  When the user clicks on the tray
     * icon, another application may be the foreground window.
--- a/tango_sys_win32/Types.di	Mon Jan 28 14:13:08 2008 +0100
+++ b/tango_sys_win32/Types.di	Mon Jan 28 21:05:39 2008 +0100
@@ -12999,8 +12999,7 @@
 alias WINDOWPLACEMENT TWINDOWPLACEMENT;
 alias WINDOWPLACEMENT* PWINDOWPLACEMENT;
 
-struct WNDCLASS
-{
+struct WNDCLASSA {
 	UINT style;
 	WNDPROC lpfnWndProc;
 	int cbClsExtra;
@@ -13013,11 +13012,34 @@
 	LPCTSTR lpszClassName;
 }
 
+alias WNDCLASSA* PWNDCLASSA, LPWNDCLASSA;
+
+struct WNDCLASSW {
+    UINT        style;
+    WNDPROC     lpfnWndProc;
+    int         cbClsExtra;
+    int         cbWndExtra;
+    HINSTANCE   hInstance;
+    HICON       hIcon;
+    HCURSOR     hCursor;
+    HBRUSH      hbrBackground;
+    LPCWSTR     lpszMenuName;
+    LPCWSTR     lpszClassName;
+};
+
+alias WNDCLASSW* PWNDCLASSW, LPWNDCLASSW;
+
+// since phobos has alias WNDCLASSA to WNDCLASS, we have to alias it another name
+version(ANSI){
+    alias WNDCLASSA WNDCLASS;
+}else{
+    alias WNDCLASSW WNDCLASS;
+}
+
 alias WNDCLASS* LPWNDCLASS;
 alias WNDCLASS _WNDCLASS;
 alias WNDCLASS TWNDCLASS;
-alias WNDCLASS TWNDCLASSA;
-alias WNDCLASS* PWNDCLASS;
+alias WNDCLASS WNDCLASS_T;
 
 struct WNDCLASSEX
 {