changeset 24:7b3e88548661

GCData, 1/3 of GC
author Frank Benoit <benoit@tionex.de>
date Sun, 27 Jan 2008 20:29:00 +0100
parents f5482da87ed8
children d6fa61ac6912
files dwt/graphics/GC.d dwt/graphics/GCData.d dwt/internal/gdip/Gdip.d dwt/internal/win32/OS.d dwt/internal/win32/WINAPI.d dwt/internal/win32/WINTYPES.d
diffstat 6 files changed, 750 insertions(+), 635 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/graphics/GC.d	Sun Jan 27 17:43:55 2008 +0100
+++ b/dwt/graphics/GC.d	Sun Jan 27 20:29:00 2008 +0100
@@ -12,10 +12,9 @@
  *******************************************************************************/
 module dwt.graphics.GC;
 
-import dwt.graphics.GCData;
-import dwt.graphics.Image;
-import dwt.internal.win32.WINTYPES;
+
 
+/+
 //PORTING_TYPE
 class GC{
     void dispose();
@@ -27,35 +26,35 @@
 public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) ;
 void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) ;
 }
++/
 
-/++
 import dwt.DWT;
 import dwt.DWTError;
 import dwt.DWTException;
 import dwt.internal.Compatibility;
 import dwt.internal.gdip.Gdip;
-import dwt.internal.gdip.PointF;
-import dwt.internal.gdip.Rect;
-import dwt.internal.gdip.RectF;
-import dwt.internal.win32.BITMAP;
-import dwt.internal.win32.BITMAPINFOHEADER;
-import dwt.internal.win32.BLENDFUNCTION;
-import dwt.internal.win32.GRADIENT_RECT;
-import dwt.internal.win32.ICONINFO;
-import dwt.internal.win32.LOGBRUSH;
-import dwt.internal.win32.LOGFONT;
-import dwt.internal.win32.LOGFONTA;
-import dwt.internal.win32.LOGFONTW;
-import dwt.internal.win32.LOGPEN;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.POINT;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.SIZE;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.TEXTMETRIC;
-import dwt.internal.win32.TEXTMETRICA;
-import dwt.internal.win32.TEXTMETRICW;
-import dwt.internal.win32.TRIVERTEX;
+
+import dwt.graphics.Color;
+import dwt.graphics.Drawable;
+import dwt.graphics.Resource;
+import dwt.graphics.Device;
+import dwt.graphics.Font;
+import dwt.graphics.FontMetrics;
+import dwt.graphics.GCData;
+import dwt.graphics.Image;
+import dwt.graphics.ImageData;
+import dwt.graphics.Path;
+import dwt.graphics.Pattern;
+import dwt.graphics.Point;
+import dwt.graphics.RGB;
+import dwt.graphics.Rectangle;
+import dwt.graphics.Region;
+import dwt.graphics.Resource;
+import dwt.graphics.Transform;
+import dwt.graphics.LineAttributes;
+
+import tango.text.convert.Format;
 
 /**
  * Class <code>GC</code> is where all of the drawing capabilities that are
@@ -87,7 +86,7 @@
  * @see dwt.events.PaintEvent
  */
 
-public final class GC extends Resource {
+public final class GC : Resource {
 
     /**
      * the handle to the OS device context
@@ -99,39 +98,39 @@
      * platforms and should never be accessed from application code.
      * </p>
      */
-    public int handle;
+    public HDC handle;
 
     Drawable drawable;
     GCData data;
 
-    static final int FOREGROUND = 1 << 0;
-    static final int BACKGROUND = 1 << 1;
-    static final int FONT = 1 << 2;
-    static final int LINE_STYLE = 1 << 3;
-    static final int LINE_WIDTH = 1 << 4;
-    static final int LINE_CAP = 1 << 5;
-    static final int LINE_JOIN = 1 << 6;
-    static final int LINE_MITERLIMIT = 1 << 7;
-    static final int FOREGROUND_TEXT = 1 << 8;
-    static final int BACKGROUND_TEXT = 1 << 9;
-    static final int BRUSH = 1 << 10;
-    static final int PEN = 1 << 11;
-    static final int NULL_BRUSH = 1 << 12;
-    static final int NULL_PEN = 1 << 13;
-    static final int DRAW_OFFSET = 1 << 14;
+    static const int FOREGROUND = 1 << 0;
+    static const int BACKGROUND = 1 << 1;
+    static const int FONT = 1 << 2;
+    static const int LINE_STYLE = 1 << 3;
+    static const int LINE_WIDTH = 1 << 4;
+    static const int LINE_CAP = 1 << 5;
+    static const int LINE_JOIN = 1 << 6;
+    static const int LINE_MITERLIMIT = 1 << 7;
+    static const int FOREGROUND_TEXT = 1 << 8;
+    static const int BACKGROUND_TEXT = 1 << 9;
+    static const int BRUSH = 1 << 10;
+    static const int PEN = 1 << 11;
+    static const int NULL_BRUSH = 1 << 12;
+    static const int NULL_PEN = 1 << 13;
+    static const int DRAW_OFFSET = 1 << 14;
 
-    static final int DRAW = FOREGROUND | LINE_STYLE | LINE_WIDTH | LINE_CAP | LINE_JOIN | LINE_MITERLIMIT | PEN | NULL_BRUSH | DRAW_OFFSET;
-    static final int FILL = BACKGROUND | BRUSH | NULL_PEN;
+    static const int DRAW = FOREGROUND | LINE_STYLE | LINE_WIDTH | LINE_CAP | LINE_JOIN | LINE_MITERLIMIT | PEN | NULL_BRUSH | DRAW_OFFSET;
+    static const int FILL = BACKGROUND | BRUSH | NULL_PEN;
 
-    static final float[] LINE_DOT_ZERO = new float[]{3, 3};
-    static final float[] LINE_DASH_ZERO = new float[]{18, 6};
-    static final float[] LINE_DASHDOT_ZERO = new float[]{9, 6, 3, 6};
-    static final float[] LINE_DASHDOTDOT_ZERO = new float[]{9, 3, 3, 3, 3, 3};
+    static const float[] LINE_DOT_ZERO = [3, 3];
+    static const float[] LINE_DASH_ZERO = [18, 6];
+    static const float[] LINE_DASHDOT_ZERO = [9, 6, 3, 6];
+    static const float[] LINE_DASHDOTDOT_ZERO = [9, 3, 3, 3, 3, 3];
 
 /**
  * Prevents uninitialized instances from being created outside the package.
  */
-GC() {
+this() {
 }
 
 /**
@@ -156,7 +155,7 @@
  *    <li>ERROR_THREAD_INVALID_ACCESS if not called from the thread that created the drawable</li>
  * </ul>
  */
-public GC(Drawable drawable) {
+public this(Drawable drawable) {
     this(drawable, DWT.NONE);
 }
 
@@ -187,11 +186,11 @@
  *
  * @since 2.1.2
  */
-public GC(Drawable drawable, int style) {
+public this(Drawable drawable, int style) {
     if (drawable is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     GCData data = new GCData ();
     data.style = checkStyle(style);
-    int hDC = drawable.internal_new_GC(data);
+    auto hDC = drawable.internal_new_GC(data);
     Device device = data.device;
     if (device is null) device = Device.getDevice();
     if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
@@ -210,14 +209,14 @@
     if ((state & mask) is mask) return;
     state = (state ^ mask) & mask;
     data.state |= mask;
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
-        int pen = data.gdipPen;
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
+        auto pen = data.gdipPen;
         float width = data.lineWidth;
-        if ((state & FOREGROUND) !is 0 || (pen is 0 && (state & (LINE_WIDTH | LINE_STYLE | LINE_MITERLIMIT | LINE_JOIN | LINE_CAP)) !is 0)) {
-            if (data.gdipFgBrush !is 0) Gdip.SolidBrush_delete(data.gdipFgBrush);
-            data.gdipFgBrush = 0;
-            int brush;
+        if ((state & FOREGROUND) !is 0 || (pen is null && (state & (LINE_WIDTH | LINE_STYLE | LINE_MITERLIMIT | LINE_JOIN | LINE_CAP)) !is 0)) {
+            if (data.gdipFgBrush !is null) Gdip.SolidBrush_delete(data.gdipFgBrush);
+            data.gdipFgBrush = null;
+            Gdip.Brush* brush;
             Pattern pattern = data.foregroundPattern;
             if (pattern !is null) {
                 brush = pattern.handle;
@@ -225,22 +224,22 @@
                     switch (Gdip.Brush_GetType(brush)) {
                         case Gdip.BrushTypeTextureFill:
                             brush = Gdip.Brush_Clone(brush);
-                            if (brush is 0) DWT.error(DWT.ERROR_NO_HANDLES);
-                            Gdip.TextureBrush_ScaleTransform(brush, -1, 1, Gdip.MatrixOrderPrepend);
-                            data.gdipFgBrush = brush;
+                            if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES);
+                            Gdip.TextureBrush_ScaleTransform( cast(Gdip.TextureBrush*) brush, -1, 1, Gdip.MatrixOrderPrepend);
+                            data.gdipFgBrush = cast(Gdip.SolidBrush*)brush;
                     }
                 }
             } else {
-                int foreground = data.foreground;
+                auto foreground = data.foreground;
                 int rgb = ((foreground >> 16) & 0xFF) | (foreground & 0xFF00) | ((foreground & 0xFF) << 16);
-                int color = Gdip.Color_new(data.alpha << 24 | rgb);
-                if (color is 0) DWT.error(DWT.ERROR_NO_HANDLES);
-                brush = Gdip.SolidBrush_new(color);
-                if (brush is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+                auto color = Gdip.Color_new(data.alpha << 24 | rgb);
+                if (color is null) DWT.error(DWT.ERROR_NO_HANDLES);
+                brush = cast(Gdip.Brush*) Gdip.SolidBrush_new(color);
+                if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES);
                 Gdip.Color_delete(color);
-                data.gdipFgBrush = brush;
+                data.gdipFgBrush = cast(Gdip.SolidBrush*)brush;
             }
-            if (pen !is 0) {
+            if (pen !is null) {
                 Gdip.Pen_SetBrush(pen, brush);
             } else {
                 pen = data.gdipPen = Gdip.Pen_new(brush, width);
@@ -276,7 +275,7 @@
                 }
             }
             if (dashes !is null) {
-                Gdip.Pen_SetDashPattern(pen, dashes, dashes.length);
+                Gdip.Pen_SetDashPattern(pen, dashes.ptr, dashes.length);
                 Gdip.Pen_SetDashStyle(pen, Gdip.DashStyleCustom);
                 Gdip.Pen_SetDashOffset(pen, dashOffset);
             } else {
@@ -305,54 +304,56 @@
             Gdip.Pen_SetLineCap(pen, capStyle, capStyle, dashCap);
         }
         if ((state & BACKGROUND) !is 0) {
-            if (data.gdipBgBrush !is 0) Gdip.SolidBrush_delete(data.gdipBgBrush);
-            data.gdipBgBrush = 0;
+            if (data.gdipBgBrush !is null) Gdip.SolidBrush_delete(data.gdipBgBrush);
+            data.gdipBgBrush = null;
             Pattern pattern = data.backgroundPattern;
             if (pattern !is null) {
                 data.gdipBrush = pattern.handle;
                 if ((data.style & DWT.MIRRORED) !is 0) {
                     switch (Gdip.Brush_GetType(data.gdipBrush)) {
                         case Gdip.BrushTypeTextureFill:
-                            int brush = Gdip.Brush_Clone(data.gdipBrush);
-                            if (brush is 0) DWT.error(DWT.ERROR_NO_HANDLES);
-                            Gdip.TextureBrush_ScaleTransform(brush, -1, 1, Gdip.MatrixOrderPrepend);
-                            data.gdipBrush = data.gdipBgBrush = brush;
+                            auto brush = Gdip.Brush_Clone(data.gdipBrush);
+                            if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES);
+                            Gdip.TextureBrush_ScaleTransform( cast(Gdip.TextureBrush*)brush, -1, 1, Gdip.MatrixOrderPrepend);
+                            data.gdipBrush = brush;
+                            data.gdipBgBrush = cast(Gdip.SolidBrush*) brush;
                     }
                 }
             } else {
-                int background = data.background;
+                auto background = data.background;
                 int rgb = ((background >> 16) & 0xFF) | (background & 0xFF00) | ((background & 0xFF) << 16);
-                int color = Gdip.Color_new(data.alpha << 24 | rgb);
-                if (color is 0) DWT.error(DWT.ERROR_NO_HANDLES);
-                int brush = Gdip.SolidBrush_new(color);
-                if (brush is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+                auto color = Gdip.Color_new(data.alpha << 24 | rgb);
+                if (color is null) DWT.error(DWT.ERROR_NO_HANDLES);
+                auto brush = Gdip.SolidBrush_new(color);
+                if (brush is null) DWT.error(DWT.ERROR_NO_HANDLES);
                 Gdip.Color_delete(color);
-                data.gdipBrush = data.gdipBgBrush = brush;
+                data.gdipBrush = cast(Gdip.Brush*)brush;
+                data.gdipBgBrush = brush;
             }
         }
         if ((state & FONT) !is 0) {
             OS.SelectObject(handle, data.hFont);
-            int font = createGdipFont(handle, data.hFont);
-            if (data.gdipFont !is 0) Gdip.Font_delete(data.gdipFont);
+            auto font = createGdipFont(handle, data.hFont);
+            if (data.gdipFont !is null) Gdip.Font_delete(data.gdipFont);
             data.gdipFont = font;
         }
         if ((state & DRAW_OFFSET) !is 0) {
             data.gdipXOffset = data.gdipYOffset = 0;
-            int matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0);
-            float[] elements = new float[6];
+            auto matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0);
+            float[6] elements;
             Gdip.Graphics_GetTransform(gdipGraphics, matrix);
-            Gdip.Matrix_GetElements(matrix, elements);
+            Gdip.Matrix_GetElements(matrix, elements.ptr );
             Gdip.Matrix_delete(matrix);
             float scaling = elements[0];
             if (scaling < 0) scaling = -scaling;
             float penWidth = data.lineWidth * scaling;
-            if (penWidth is 0 || ((int)penWidth % 2) is 1) {
+            if (penWidth is 0 || (cast(int)penWidth % 2) is 1) {
                 data.gdipXOffset = 0.5f / scaling;
             }
             scaling = elements[3];
             if (scaling < 0) scaling = -scaling;
             penWidth = data.lineWidth * scaling;
-            if (penWidth is 0 || ((int)penWidth % 2) is 1) {
+            if (penWidth is 0 || (cast(int)penWidth % 2) is 1) {
                 data.gdipYOffset = 0.5f / scaling;
             }
         }
@@ -360,8 +361,8 @@
     }
     if ((state & (FOREGROUND | LINE_CAP | LINE_JOIN | LINE_STYLE | LINE_WIDTH)) !is 0) {
         int color = data.foreground;
-        int width = (int)data.lineWidth;
-        int[] dashes = null;
+        int width = cast(int)data.lineWidth;
+        uint[] dashes = null;
         int lineStyle = OS.PS_SOLID;
         switch (data.lineStyle) {
             case DWT.LINE_SOLID: break;
@@ -372,9 +373,9 @@
             case DWT.LINE_CUSTOM: {
                 if (data.lineDashes !is null) {
                     lineStyle = OS.PS_USERSTYLE;
-                    dashes = new int[data.lineDashes.length];
+                    dashes = new uint[data.lineDashes.length];
                     for (int i = 0; i < dashes.length; i++) {
-                        dashes[i] = (int)data.lineDashes[i];
+                        dashes[i] = cast(int)data.lineDashes[i];
                     }
                 }
                 break;
@@ -401,20 +402,20 @@
         * PS_SOLID for pens wider than 1 pixel created with CreatePen().  The fix
         * is to use ExtCreatePen() instead.
         */
-        int newPen;
+        HPEN newPen;
         if (OS.IsWinCE || (width is 0 && lineStyle !is OS.PS_USERSTYLE) || style is 0) {
             newPen = OS.CreatePen(style & OS.PS_STYLE_MASK, width, color);
         } else {
-            LOGBRUSH logBrush = new LOGBRUSH();
+            LOGBRUSH logBrush;
             logBrush.lbStyle = OS.BS_SOLID;
             logBrush.lbColor = color;
             /* Feature in Windows. PS_GEOMETRIC pens cannot have zero width. */
-            newPen = OS.ExtCreatePen (style | OS.PS_GEOMETRIC, Math.max(1, width), logBrush, dashes !is null ? dashes.length : 0, dashes);
+            newPen = OS.ExtCreatePen (style | OS.PS_GEOMETRIC, Math.max(1, width), &logBrush, dashes !is null ? dashes.length : 0, dashes.ptr);
         }
-        OS.SelectObject(handle, newPen);
+        OS.SelectObject(handle, &newPen);
         data.state |= PEN;
         data.state &= ~NULL_PEN;
-        if (data.hPen !is 0) OS.DeleteObject(data.hPen);
+        if (data.hPen !is null) OS.DeleteObject(data.hPen);
         data.hPen = data.hOldPen = newPen;
     } else if ((state & PEN) !is 0) {
         OS.SelectObject(handle, data.hOldPen);
@@ -424,11 +425,11 @@
         data.state &= ~PEN;
     }
     if ((state & BACKGROUND) !is 0) {
-        int newBrush = OS.CreateSolidBrush(data.background);
+        auto newBrush = OS.CreateSolidBrush(data.background);
         OS.SelectObject(handle, newBrush);
         data.state |= BRUSH;
         data.state &= ~NULL_BRUSH;
-        if (data.hBrush !is 0) OS.DeleteObject(data.hBrush);
+        if (data.hBrush !is null) OS.DeleteObject(data.hBrush);
         data.hOldBrush = data.hBrush = newBrush;
     } else if ((state & BRUSH) !is 0) {
         OS.SelectObject(handle, data.hOldBrush);
@@ -465,14 +466,14 @@
  * </ul>
  */
 public void copyArea(Image image, int x, int y) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (image is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     if (image.type !is DWT.BITMAP || image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
 
     /* Copy the bitmap area */
     Rectangle rect = image.getBounds();
-    int memHdc = OS.CreateCompatibleDC(handle);
-    int hOldBitmap = OS.SelectObject(memHdc, image.handle);
+    auto memHdc = OS.CreateCompatibleDC(handle);
+    auto hOldBitmap = OS.SelectObject(memHdc, image.handle);
     OS.BitBlt(memHdc, 0, 0, rect.width, rect.height, handle, x, y, OS.SRCCOPY);
     OS.SelectObject(memHdc, hOldBitmap);
     OS.DeleteDC(memHdc);
@@ -516,27 +517,26 @@
  * @since 3.1
  */
 public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY, bool paint) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
 
     /*
     * Feature in WinCE.  The function WindowFromDC is not part of the
     * WinCE SDK.  The fix is to remember the HWND.
     */
-    int hwnd = data.hwnd;
-    if (hwnd is 0) {
+    auto hwnd = data.hwnd;
+    if (hwnd is null) {
         OS.BitBlt(handle, destX, destY, width, height, handle, srcX, srcY, OS.SRCCOPY);
     } else {
-        RECT lprcClip = null;
-        int hrgn = OS.CreateRectRgn(0, 0, 0, 0);
+        RECT lprcClip;
+        auto hrgn = OS.CreateRectRgn(0, 0, 0, 0);
         if (OS.GetClipRgn(handle, hrgn) is 1) {
-            lprcClip = new RECT();
-            OS.GetRgnBox(hrgn, lprcClip);
+            OS.GetRgnBox(hrgn, &lprcClip);
         }
         OS.DeleteObject(hrgn);
-        RECT lprcScroll = new RECT();
-        OS.SetRect(lprcScroll, srcX, srcY, srcX + width, srcY + height);
+        RECT lprcScroll;
+        OS.SetRect(&lprcScroll, srcX, srcY, srcX + width, srcY + height);
         int flags = paint ? OS.SW_INVALIDATE | OS.SW_ERASE : 0;
-        int res = OS.ScrollWindowEx(hwnd, destX - srcX, destY - srcY, lprcScroll, lprcClip, 0, null, flags);
+        int res = OS.ScrollWindowEx(hwnd, destX - srcX, destY - srcY, &lprcScroll, &lprcClip, null, null, flags);
 
         /*
         * Feature in WinCE.  ScrollWindowEx does not accept combined
@@ -549,19 +549,19 @@
                 int deltaX = destX - srcX, deltaY = destY - srcY;
                 bool disjoint = (destX + width < srcX) || (srcX + width < destX) || (destY + height < srcY) || (srcY + height < destY);
                 if (disjoint) {
-                    OS.InvalidateRect(hwnd, lprcScroll, true);
+                    OS.InvalidateRect(hwnd, &lprcScroll, true);
                 } else {
                     if (deltaX !is 0) {
                         int newX = destX - deltaX;
                         if (deltaX < 0) newX = destX + width;
-                        OS.SetRect(lprcScroll, newX, srcY, newX + Math.abs(deltaX), srcY + height);
-                        OS.InvalidateRect(hwnd, lprcScroll, true);
+                        OS.SetRect(&lprcScroll, newX, srcY, newX + Math.abs(deltaX), srcY + height);
+                        OS.InvalidateRect(hwnd, &lprcScroll, true);
                     }
                     if (deltaY !is 0) {
                         int newY = destY - deltaY;
                         if (deltaY < 0) newY = destY + height;
-                        OS.SetRect(lprcScroll, srcX, newY, srcX + width, newY + Math.abs(deltaY));
-                        OS.InvalidateRect(hwnd, lprcScroll, true);
+                        OS.SetRect(&lprcScroll, srcX, newY, srcX + width, newY + Math.abs(deltaY));
+                        OS.InvalidateRect(hwnd, &lprcScroll, true);
                     }
                 }
             }
@@ -569,56 +569,54 @@
     }
 }
 
-static int createGdipFont(int hDC, int hFont) {
-    int font = Gdip.Font_new(hDC, hFont);
-    if (font is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+static Gdip.Font* createGdipFont(HDC hDC, HFONT hFont) {
+    auto font = Gdip.Font_new(hDC, hFont);
+    if (font is null) DWT.error(DWT.ERROR_NO_HANDLES);
     if (!Gdip.Font_IsAvailable(font)) {
         Gdip.Font_delete(font);
-        LOGFONT logFont = OS.IsUnicode ? (LOGFONT)new LOGFONTW() : new LOGFONTA();
-        OS.GetObject(hFont, LOGFONT.sizeof, logFont);
+        LOGFONT logFont;
+        OS.GetObject(hFont, LOGFONT.sizeof, &logFont);
         int size = Math.abs(logFont.lfHeight);
         int style = Gdip.FontStyleRegular;
         if (logFont.lfWeight is 700) style |= Gdip.FontStyleBold;
         if (logFont.lfItalic !is 0) style |= Gdip.FontStyleItalic;
-        char[] chars;
-        if (OS.IsUnicode) {
-            chars = ((LOGFONTW)logFont).lfFaceName;
+        wchar[] chars;
+        static if (OS.IsUnicode) {
+            chars = logFont.lfFaceName;
         } else {
-            chars = new char[OS.LF_FACESIZE];
-            byte[] bytes = ((LOGFONTA)logFont).lfFaceName;
-            OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, bytes, bytes.length, chars, chars.length);
+            chars = new wchar[OS.LF_FACESIZE];
+            char[] bytes = logFont.lfFaceName;
+            OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, bytes.ptr, bytes.length, chars, chars.length);
         }
         int index = 0;
         while (index < chars.length) {
             if (chars [index] is 0) break;
             index++;
         }
-        String name = new String (chars, 0, index);
+        char[] name = WCHARsToStr( chars[ 0 .. index ] );
         if (Compatibility.equalsIgnoreCase(name, "Courier")) { //$NON-NLS-1$
             name = "Courier New"; //$NON-NLS-1$
         }
-        char[] buffer = new char[name.length() + 1];
-        name.getChars(0, name.length(), buffer, 0);
-        font = Gdip.Font_new(buffer, size, style, Gdip.UnitPixel, 0);
+        font = Gdip.Font_new( StrToWCHARz(name), size, style, Gdip.UnitPixel, null);
     }
-    if (font is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    if (font is null) DWT.error(DWT.ERROR_NO_HANDLES);
     return font;
 }
 
-static void destroyGdipBrush(int brush) {
+static void destroyGdipBrush(Gdip.Brush* brush) {
     int type = Gdip.Brush_GetType(brush);
     switch (type) {
         case Gdip.BrushTypeSolidColor:
-            Gdip.SolidBrush_delete(brush);
+            Gdip.SolidBrush_delete( cast(Gdip.SolidBrush*)brush);
             break;
         case Gdip.BrushTypeHatchFill:
-            Gdip.HatchBrush_delete(brush);
+            Gdip.HatchBrush_delete(cast(Gdip.HatchBrush*)brush);
             break;
         case Gdip.BrushTypeLinearGradient:
-            Gdip.LinearGradientBrush_delete(brush);
+            Gdip.LinearGradientBrush_delete(cast(Gdip.LinearGradientBrush*)brush);
             break;
         case Gdip.BrushTypeTextureFill:
-            Gdip.TextureBrush_delete(brush);
+            Gdip.TextureBrush_delete(cast(Gdip.TextureBrush*)brush);
             break;
     }
 }
@@ -633,21 +631,21 @@
  * </ul>
  */
 public void dispose() {
-    if (handle is 0) return;
+    if (handle is null) return;
     if (data.device.isDisposed()) return;
 
     disposeGdip();
 
     /* Select stock pen and brush objects and free resources */
-    if (data.hPen !is 0) {
+    if (data.hPen !is null) {
         OS.SelectObject(handle, OS.GetStockObject(OS.NULL_PEN));
         OS.DeleteObject(data.hPen);
-        data.hPen = 0;
+        data.hPen = null;
     }
-    if (data.hBrush !is 0) {
+    if (data.hBrush !is null) {
         OS.SelectObject(handle, OS.GetStockObject(OS.NULL_BRUSH));
         OS.DeleteObject(data.hBrush);
-        data.hBrush = 0;
+        data.hBrush = null;
     }
 
     /*
@@ -655,10 +653,10 @@
     * This will ensure that we have not left a bitmap
     * selected in it when we delete the HDC.
     */
-    int hNullBitmap = data.hNullBitmap;
-    if (hNullBitmap !is 0) {
+    auto hNullBitmap = data.hNullBitmap;
+    if (hNullBitmap !is null) {
         OS.SelectObject(handle, hNullBitmap);
-        data.hNullBitmap = 0;
+        data.hNullBitmap = null;
     }
     Image image = data.image;
     if (image !is null) image.memGC = null;
@@ -669,7 +667,7 @@
     Device device = data.device;
     if (drawable !is null) drawable.internal_dispose_GC(handle, data);
     drawable = null;
-    handle = 0;
+    handle = null;
     data.image = null;
     data.ps = null;
     if (device.tracking) device.dispose_Object(this);
@@ -678,13 +676,17 @@
 }
 
 void disposeGdip() {
-    if (data.gdipPen !is 0) Gdip.Pen_delete(data.gdipPen);
-    if (data.gdipBgBrush !is 0) destroyGdipBrush(data.gdipBgBrush);
-    if (data.gdipFgBrush !is 0) destroyGdipBrush(data.gdipFgBrush);
-    if (data.gdipFont !is 0) Gdip.Font_delete(data.gdipFont);
-    if (data.gdipGraphics !is 0) Gdip.Graphics_delete(data.gdipGraphics);
-    data.gdipGraphics = data.gdipBrush = data.gdipBgBrush = data.gdipFgBrush =
-        data.gdipFont = data.gdipPen = 0;
+    if (data.gdipPen !is null) Gdip.Pen_delete(data.gdipPen);
+    if (data.gdipBgBrush !is null) destroyGdipBrush(cast(Gdip.Brush*)data.gdipBgBrush);
+    if (data.gdipFgBrush !is null) destroyGdipBrush(cast(Gdip.Brush*)data.gdipFgBrush);
+    if (data.gdipFont !is null) Gdip.Font_delete(data.gdipFont);
+    if (data.gdipGraphics !is null) Gdip.Graphics_delete(data.gdipGraphics);
+    data.gdipGraphics = null;
+    data.gdipBrush = null;
+    data.gdipBgBrush = null;
+    data.gdipFgBrush = null;
+    data.gdipFont = null;
+    data.gdipPen = null;
 }
 
 /**
@@ -717,7 +719,7 @@
  * </ul>
  */
 public void drawArc (int x, int y, int width, int height, int startAngle, int arcAngle) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(DRAW);
     if (width < 0) {
         x = x + width;
@@ -728,16 +730,16 @@
         height = -height;
     }
     if (width is 0 || height is 0 || arcAngle is 0) return;
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend);
         if (width is height) {
             Gdip.Graphics_DrawArc(gdipGraphics, data.gdipPen, x, y, width, height, -startAngle, -arcAngle);
         } else {
-            int path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate);
-            if (path is 0) DWT.error(DWT.ERROR_NO_HANDLES);
-            int matrix = Gdip.Matrix_new(width, 0, 0, height, x, y);
-            if (matrix is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+            auto path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate);
+            if (path is null) DWT.error(DWT.ERROR_NO_HANDLES);
+            auto matrix = Gdip.Matrix_new(width, 0, 0, height, x, y);
+            if (matrix is null) DWT.error(DWT.ERROR_NO_HANDLES);
             Gdip.GraphicsPath_AddArc(path, 0, 0, 1, 1, -startAngle, -arcAngle);
             Gdip.GraphicsPath_Transform(path, matrix);
             Gdip.Graphics_DrawPath(gdipGraphics, data.gdipPen, path);
@@ -770,7 +772,7 @@
             points[index++] = (Compatibility.cos(startAngle + i, width) + cteX) >> 1;
             points[index++] = (cteY - Compatibility.sin(startAngle + i, height)) >> 1;
         }
-        OS.Polyline(handle, points, points.length / 2);
+        OS.Polyline(handle, cast(POINT*)points.ptr, points.length / 2);
     } else {
         int x1, y1, x2, y2,tmp;
         bool isNegative;
@@ -815,47 +817,49 @@
  * @see #drawRectangle(int, int, int, int)
  */
 public void drawFocus (int x, int y, int width, int height) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if ((data.uiState & OS.UISF_HIDEFOCUS) !is 0) return;
-    int hdc = handle, state = 0;
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
-        int clipRgn = 0;
+    HDC hdc = handle;
+    int state = 0;
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
+        HRGN clipRgn;
         Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone);
-        int rgn = Gdip.Region_new();
-        if (rgn is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+        auto rgn = Gdip.Region_new();
+        if (rgn is null) DWT.error(DWT.ERROR_NO_HANDLES);
         Gdip.Graphics_GetClip(gdipGraphics, rgn);
         if (!Gdip.Region_IsInfinite(rgn, gdipGraphics)) {
             clipRgn = Gdip.Region_GetHRGN(rgn, gdipGraphics);
         }
         Gdip.Region_delete(rgn);
         Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf);
-        float[] lpXform = null;
-        int matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0);
-        if (matrix is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+        float[6] lpXform;
+        bool gotElements = false;
+        auto matrix = Gdip.Matrix_new(1, 0, 0, 1, 0, 0);
+        if (matrix is null) DWT.error(DWT.ERROR_NO_HANDLES);
         Gdip.Graphics_GetTransform(gdipGraphics, matrix);
         if (!Gdip.Matrix_IsIdentity(matrix)) {
-            lpXform = new float[6];
-            Gdip.Matrix_GetElements(matrix, lpXform);
+            gotElements = true;
+            Gdip.Matrix_GetElements(matrix, lpXform.ptr);
         }
         Gdip.Matrix_delete(matrix);
         hdc = Gdip.Graphics_GetHDC(gdipGraphics);
         state = OS.SaveDC(hdc);
         OS.SetBkColor(hdc, data.background);
         OS.SetTextColor(hdc, data.foreground);
-        if (lpXform !is null) {
+        if (gotElements) {
             OS.SetGraphicsMode(hdc, OS.GM_ADVANCED);
-            OS.SetWorldTransform(hdc, lpXform);
+            OS.SetWorldTransform(hdc, cast(XFORM*)lpXform.ptr);
         }
-        if (clipRgn !is 0) {
+        if (clipRgn !is null) {
             OS.SelectClipRgn(hdc, clipRgn);
             OS.DeleteObject(clipRgn);
         }
     }
-    RECT rect = new RECT();
-    OS.SetRect(rect, x, y, x + width, y + height);
-    OS.DrawFocusRect(hdc, rect);
-    if (gdipGraphics !is 0) {
+    RECT rect;
+    OS.SetRect(&rect, x, y, x + width, y + height);
+    OS.DrawFocusRect(hdc, &rect);
+    if (gdipGraphics !is null) {
         OS.RestoreDC(hdc, state);
         Gdip.Graphics_ReleaseHDC(gdipGraphics, hdc);
     }
@@ -881,7 +885,7 @@
  * </ul>
  */
 public void drawImage(Image image, int x, int y) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (image is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
     if (image.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
@@ -920,7 +924,7 @@
  * </ul>
  */
 public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (srcWidth is 0 || srcHeight is 0 || destWidth is 0 || destHeight is 0) return;
     if (srcX < 0 || srcY < 0 || srcWidth < 0 || srcHeight < 0 || destWidth < 0 || destHeight < 0) {
         DWT.error (DWT.ERROR_INVALID_ARGUMENT);
@@ -931,10 +935,10 @@
 }
 
 void drawImage(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) {
-    if (data.gdipGraphics !is 0) {
+    if (data.gdipGraphics !is null) {
         //TODO - cache bitmap
         int[] gdipImage = srcImage.createGdipImage();
-        int img = gdipImage[0];
+        auto img = cast(Gdip.Image*) gdipImage[0];
         int imgWidth = Gdip.Image_GetWidth(img);
         int imgHeight = Gdip.Image_GetHeight(img);
         if (simple) {
@@ -948,7 +952,7 @@
                 srcWidth is destWidth && destWidth is imgWidth &&
                 srcHeight is destHeight && destHeight is imgHeight;
         }
-        Rect rect = new Rect();
+        Gdip.Rect rect;
         rect.X = destX;
         rect.Y = destY;
         rect.Width = destWidth;
@@ -957,17 +961,17 @@
         * Note that if the wrap mode is not WrapModeTileFlipXY, the scaled image
         * is translucent around the borders.
         */
-        int attrib = Gdip.ImageAttributes_new();
+        auto attrib = Gdip.ImageAttributes_new();
         Gdip.ImageAttributes_SetWrapMode(attrib, Gdip.WrapModeTileFlipXY);
         if (data.alpha !is 0xFF) {
-            float[] matrix = new float[]{
+            float[] matrix = [ cast(float)
                 1,0,0,0,0,
                 0,1,0,0,0,
                 0,0,1,0,0,
-                0,0,0,data.alpha / (float)0xFF,0,
+                0,0,0,data.alpha / cast(float)0xFF,0,
                 0,0,0,0,1,
-            };
-            Gdip.ImageAttributes_SetColorMatrix(attrib, matrix, Gdip.ColorMatrixFlagsDefault, Gdip.ColorAdjustTypeBitmap);
+            ];
+            Gdip.ImageAttributes_SetColorMatrix(attrib, matrix.ptr, Gdip.ColorMatrixFlagsDefault, Gdip.ColorAdjustTypeBitmap);
         }
         int gstate = 0;
         if ((data.style & DWT.MIRRORED) !is 0) {
@@ -975,15 +979,15 @@
             Gdip.Graphics_ScaleTransform(data.gdipGraphics, -1, 1, Gdip.MatrixOrderPrepend);
             Gdip.Graphics_TranslateTransform(data.gdipGraphics, - 2 * destX - destWidth, 0, Gdip.MatrixOrderPrepend);
         }
-        Gdip.Graphics_DrawImage(data.gdipGraphics, img, rect, srcX, srcY, srcWidth, srcHeight, Gdip.UnitPixel, attrib, 0, 0);
+        Gdip.Graphics_DrawImage(data.gdipGraphics, img, &rect, srcX, srcY, srcWidth, srcHeight, Gdip.UnitPixel, attrib, null, null);
         if ((data.style & DWT.MIRRORED) !is 0) {
             Gdip.Graphics_Restore(data.gdipGraphics, gstate);
         }
         Gdip.ImageAttributes_delete(attrib);
-        Gdip.Bitmap_delete(img);
+        Gdip.Bitmap_delete( cast(Gdip.Bitmap*) img);
         if (gdipImage[1] !is 0) {
-            int hHeap = OS.GetProcessHeap ();
-            OS.HeapFree(hHeap, 0, gdipImage[1]);
+            auto hHeap = OS.GetProcessHeap ();
+            OS.HeapFree(hHeap, 0, cast(void*)gdipImage[1]);
         }
         return;
     }
@@ -1012,8 +1016,8 @@
             * LAYOUT_RTL are set.  The fix is to set the window origin to
             * (0, 0) and offset the drawing ourselves.
             */
-            POINT pt = new POINT();
-            OS.GetWindowOrgEx(handle, pt);
+            POINT pt;
+            OS.GetWindowOrgEx(handle, &pt);
             offsetX = pt.x;
             offsetY = pt.y;
         }
@@ -1026,24 +1030,24 @@
     /* Simple case: no stretching, entire icon */
     if (simple && technology !is OS.DT_RASPRINTER && drawIcon) {
         if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, 0, 0, null);
-        OS.DrawIconEx(handle, destX - offsetX, destY - offsetY, srcImage.handle, 0, 0, 0, 0, flags);
+        OS.DrawIconEx(handle, destX - offsetX, destY - offsetY, srcImage.handle, 0, 0, 0, null, flags);
         if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, offsetX, offsetY, null);
         return;
     }
 
     /* Get the icon info */
-    ICONINFO srcIconInfo = new ICONINFO();
+    ICONINFO srcIconInfo;
     if (OS.IsWinCE) {
-        Image.GetIconInfo(srcImage, srcIconInfo);
+        Image.GetIconInfo(srcImage, &srcIconInfo);
     } else {
-        OS.GetIconInfo(srcImage.handle, srcIconInfo);
+        OS.GetIconInfo(srcImage.handle, &srcIconInfo);
     }
 
     /* Get the icon width and height */
-    int hBitmap = srcIconInfo.hbmColor;
-    if (hBitmap is 0) hBitmap = srcIconInfo.hbmMask;
-    BITMAP bm = new BITMAP();
-    OS.GetObject(hBitmap, BITMAP.sizeof, bm);
+    auto hBitmap = srcIconInfo.hbmColor;
+    if (hBitmap is null) hBitmap = srcIconInfo.hbmMask;
+    BITMAP bm;
+    OS.GetObject(hBitmap, BITMAP.sizeof, &bm);
     int iconWidth = bm.bmWidth, iconHeight = bm.bmHeight;
     if (hBitmap is srcIconInfo.hbmMask) iconHeight /= 2;
 
@@ -1063,26 +1067,26 @@
         } else if (simple && technology !is OS.DT_RASPRINTER) {
             /* Simple case: no stretching, entire icon */
             if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, 0, 0, null);
-            OS.DrawIconEx(handle, destX - offsetX, destY - offsetY, srcImage.handle, 0, 0, 0, 0, flags);
+            OS.DrawIconEx(handle, destX - offsetX, destY - offsetY, srcImage.handle, 0, 0, 0, null, flags);
             if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, offsetX, offsetY, null);
         } else {
             /* Create the icon info and HDC's */
-            ICONINFO newIconInfo = new ICONINFO();
+            ICONINFO newIconInfo;
             newIconInfo.fIcon = true;
-            int srcHdc = OS.CreateCompatibleDC(handle);
-            int dstHdc = OS.CreateCompatibleDC(handle);
+            auto srcHdc = OS.CreateCompatibleDC(handle);
+            auto dstHdc = OS.CreateCompatibleDC(handle);
 
             /* Blt the color bitmap */
             int srcColorY = srcY;
-            int srcColor = srcIconInfo.hbmColor;
-            if (srcColor is 0) {
+            auto srcColor = srcIconInfo.hbmColor;
+            if (srcColor is null) {
                 srcColor = srcIconInfo.hbmMask;
                 srcColorY += iconHeight;
             }
-            int oldSrcBitmap = OS.SelectObject(srcHdc, srcColor);
+            auto oldSrcBitmap = OS.SelectObject(srcHdc, srcColor);
             newIconInfo.hbmColor = OS.CreateCompatibleBitmap(srcHdc, destWidth, destHeight);
-            if (newIconInfo.hbmColor is 0) DWT.error(DWT.ERROR_NO_HANDLES);
-            int oldDestBitmap = OS.SelectObject(dstHdc, newIconInfo.hbmColor);
+            if (newIconInfo.hbmColor is null) DWT.error(DWT.ERROR_NO_HANDLES);
+            auto oldDestBitmap = OS.SelectObject(dstHdc, newIconInfo.hbmColor);
             bool stretch = !simple && (srcWidth !is destWidth || srcHeight !is destHeight);
             if (stretch) {
                 if (!OS.IsWinCE) OS.SetStretchBltMode(dstHdc, OS.COLORONCOLOR);
@@ -1094,7 +1098,7 @@
             /* Blt the mask bitmap */
             OS.SelectObject(srcHdc, srcIconInfo.hbmMask);
             newIconInfo.hbmMask = OS.CreateBitmap(destWidth, destHeight, 1, 1, null);
-            if (newIconInfo.hbmMask is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+            if (newIconInfo.hbmMask is null) DWT.error(DWT.ERROR_NO_HANDLES);
             OS.SelectObject(dstHdc, newIconInfo.hbmMask);
             if (stretch) {
                 OS.StretchBlt(dstHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCCOPY);
@@ -1111,10 +1115,10 @@
             } else {
                 OS.SelectObject(srcHdc, oldSrcBitmap);
                 OS.SelectObject(dstHdc, oldDestBitmap);
-                int hIcon = OS.CreateIconIndirect(newIconInfo);
-                if (hIcon is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+                auto hIcon = OS.CreateIconIndirect(&newIconInfo);
+                if (hIcon is null) DWT.error(DWT.ERROR_NO_HANDLES);
                 if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, 0, 0, null);
-                OS.DrawIconEx(handle, destX - offsetX, destY - offsetY, hIcon, destWidth, destHeight, 0, 0, flags);
+                OS.DrawIconEx(handle, destX - offsetX, destY - offsetY, hIcon, destWidth, destHeight, 0, null, flags);
                 if (offsetX !is 0 || offsetY !is 0) OS.SetWindowOrgEx(handle, offsetX, offsetY, null);
                 OS.DestroyIcon(hIcon);
             }
@@ -1129,7 +1133,7 @@
 
     /* Free icon info */
     OS.DeleteObject(srcIconInfo.hbmMask);
-    if (srcIconInfo.hbmColor !is 0) {
+    if (srcIconInfo.hbmColor !is null) {
         OS.DeleteObject(srcIconInfo.hbmColor);
     }
 
@@ -1137,8 +1141,8 @@
 }
 
 void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple) {
-    BITMAP bm = new BITMAP();
-    OS.GetObject(srcImage.handle, BITMAP.sizeof, bm);
+    BITMAP bm;
+    OS.GetObject(srcImage.handle, BITMAP.sizeof, &bm);
     int imgWidth = bm.bmWidth;
     int imgHeight = bm.bmHeight;
     if (simple) {
@@ -1158,9 +1162,9 @@
         memGC.flush();
         mustRestore = true;
         GCData data = memGC.data;
-        if (data.hNullBitmap !is 0) {
+        if (data.hNullBitmap !is null) {
             OS.SelectObject(memGC.handle, data.hNullBitmap);
-            data.hNullBitmap = 0;
+            data.hNullBitmap = null;
         }
     }
     if (srcImage.alpha !is -1 || srcImage.alphaData !is null) {
@@ -1171,7 +1175,7 @@
         drawBitmap(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, bm, imgWidth, imgHeight);
     }
     if (mustRestore) {
-        int hOldBitmap = OS.SelectObject(memGC.handle, srcImage.handle);
+        auto hOldBitmap = OS.SelectObject(memGC.handle, srcImage.handle);
         memGC.data.hNullBitmap = hOldBitmap;
     }
 }
@@ -1185,23 +1189,23 @@
     }
 
     if (OS.IsWinNT && OS.WIN32_VERSION >= OS.VERSION(4, 10)) {
-        BLENDFUNCTION blend = new BLENDFUNCTION();
+        BLENDFUNCTION blend;
         blend.BlendOp = OS.AC_SRC_OVER;
-        int srcHdc = OS.CreateCompatibleDC(handle);
-        int oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);
+        auto srcHdc = OS.CreateCompatibleDC(handle);
+        auto oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);
         if (srcImage.alpha !is -1) {
-            blend.SourceConstantAlpha = (byte)srcImage.alpha;
+            blend.SourceConstantAlpha = cast(byte)srcImage.alpha;
             OS.AlphaBlend(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, blend);
         } else {
-            int memDib = Image.createDIB(srcWidth, srcHeight, 32);
-            if (memDib is 0) DWT.error(DWT.ERROR_NO_HANDLES);
-            int memHdc = OS.CreateCompatibleDC(handle);
-            int oldMemBitmap = OS.SelectObject(memHdc, memDib);
-            BITMAP dibBM = new BITMAP();
-            OS.GetObject(memDib, BITMAP.sizeof, dibBM);
+            auto memDib = Image.createDIB(srcWidth, srcHeight, 32);
+            if (memDib is null) DWT.error(DWT.ERROR_NO_HANDLES);
+            auto memHdc = OS.CreateCompatibleDC(handle);
+            auto oldMemBitmap = OS.SelectObject(memHdc, memDib);
+            BITMAP dibBM;
+            OS.GetObject(memDib, BITMAP.sizeof, &dibBM);
             OS.BitBlt(memHdc, 0, 0, srcWidth, srcHeight, srcHdc, srcX, srcY, OS.SRCCOPY);
             byte[] srcData = new byte[dibBM.bmWidthBytes * dibBM.bmHeight];
-            OS.MoveMemory(srcData, dibBM.bmBits, srcData.length);
+            srcData[] = (cast(byte*)dibBM.bmBits)[ 0 .. srcData.length ];
             final int apinc = imgWidth - srcWidth;
             int ap = srcY * imgWidth + srcX, sp = 0;
             byte[] alphaData = srcImage.alphaData;
@@ -1214,16 +1218,16 @@
                     g = (g + (g >> 8)) >> 8;
                     int b = ((srcData[sp + 2] & 0xFF) * alpha) + 128;
                     b = (b + (b >> 8)) >> 8;
-                    srcData[sp+0] = (byte)r;
-                    srcData[sp+1] = (byte)g;
-                    srcData[sp+2] = (byte)b;
-                    srcData[sp+3] = (byte)alpha;
+                    srcData[sp+0] = cast(byte)r;
+                    srcData[sp+1] = cast(byte)g;
+                    srcData[sp+2] = cast(byte)b;
+                    srcData[sp+3] = cast(byte)alpha;
                     sp += 4;
                 }
                 ap += apinc;
             }
-            OS.MoveMemory(dibBM.bmBits, srcData, srcData.length);
-            blend.SourceConstantAlpha = (byte)0xff;
+            (cast(byte*)dibBM.bmBits)[ 0 .. srcData.length ] = srcData[];
+            blend.SourceConstantAlpha = 0xff;
             blend.AlphaFormat = OS.AC_SRC_ALPHA;
             OS.AlphaBlend(handle, destX, destY, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, blend);
             OS.SelectObject(memHdc, oldMemBitmap);
@@ -1258,26 +1262,26 @@
     srcHeight = Math.max(1, sy2 - sy1);
 
     /* Create resources */
-    int srcHdc = OS.CreateCompatibleDC(handle);
-    int oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);
-    int memHdc = OS.CreateCompatibleDC(handle);
-    int memDib = Image.createDIB(Math.max(srcWidth, destWidth), Math.max(srcHeight, destHeight), 32);
-    if (memDib is 0) DWT.error(DWT.ERROR_NO_HANDLES);
-    int oldMemBitmap = OS.SelectObject(memHdc, memDib);
+    auto srcHdc = OS.CreateCompatibleDC(handle);
+    auto oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);
+    auto memHdc = OS.CreateCompatibleDC(handle);
+    auto memDib = Image.createDIB(Math.max(srcWidth, destWidth), Math.max(srcHeight, destHeight), 32);
+    if (memDib is null) DWT.error(DWT.ERROR_NO_HANDLES);
+    auto oldMemBitmap = OS.SelectObject(memHdc, memDib);
 
-    BITMAP dibBM = new BITMAP();
-    OS.GetObject(memDib, BITMAP.sizeof, dibBM);
+    BITMAP dibBM;
+    OS.GetObject(memDib, BITMAP.sizeof, &dibBM);
     int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
 
     /* Get the background pixels */
     OS.BitBlt(memHdc, 0, 0, destWidth, destHeight, handle, destX, destY, OS.SRCCOPY);
     byte[] destData = new byte[sizeInBytes];
-    OS.MoveMemory(destData, dibBM.bmBits, sizeInBytes);
+    destData[] = (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ];
 
     /* Get the foreground pixels */
     OS.BitBlt(memHdc, 0, 0, srcWidth, srcHeight, srcHdc, srcX, srcY, OS.SRCCOPY);
     byte[] srcData = new byte[sizeInBytes];
-    OS.MoveMemory(srcData, dibBM.bmBits, sizeInBytes);
+    srcData[] = (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ];
 
     /* Merge the alpha channel in place */
     int alpha = srcImage.alpha;
@@ -1298,7 +1302,7 @@
     }
 
     /* Scale the foreground pixels with alpha */
-    OS.MoveMemory(dibBM.bmBits, srcData, sizeInBytes);
+     (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ] = srcData[];
     /*
     * Bug in WinCE and Win98.  StretchBlt does not correctly stretch when
     * the source and destination HDCs are the same.  The workaround is to
@@ -1307,10 +1311,10 @@
     * source and destination HDCs are the same.
     */
     if ((OS.IsWinCE && (destWidth > srcWidth || destHeight > srcHeight)) || (!OS.IsWinNT && !OS.IsWinCE)) {
-        int tempHdc = OS.CreateCompatibleDC(handle);
-        int tempDib = Image.createDIB(destWidth, destHeight, 32);
-        if (tempDib is 0) DWT.error(DWT.ERROR_NO_HANDLES);
-        int oldTempBitmap = OS.SelectObject(tempHdc, tempDib);
+        auto tempHdc = OS.CreateCompatibleDC(handle);
+        auto tempDib = Image.createDIB(destWidth, destHeight, 32);
+        if (tempDib is null) DWT.error(DWT.ERROR_NO_HANDLES);
+        auto oldTempBitmap = OS.SelectObject(tempHdc, tempDib);
         if (!simple && (srcWidth !is destWidth || srcHeight !is destHeight)) {
             if (!OS.IsWinCE) OS.SetStretchBltMode(memHdc, OS.COLORONCOLOR);
             OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, srcWidth, srcHeight, OS.SRCCOPY);
@@ -1329,7 +1333,7 @@
             OS.BitBlt(memHdc, 0, 0, destWidth, destHeight, memHdc, 0, 0, OS.SRCCOPY);
         }
     }
-    OS.MoveMemory(srcData, dibBM.bmBits, sizeInBytes);
+    srcData[] = (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ];
 
     /* Compose the pixels */
     final int dpinc = dibBM.bmWidthBytes - destWidth * 4;
@@ -1346,7 +1350,7 @@
     }
 
     /* Draw the composed pixels */
-    OS.MoveMemory(dibBM.bmBits, destData, sizeInBytes);
+    (cast(byte*)dibBM.bmBits)[ 0 .. sizeInBytes ] = destData[];
     OS.BitBlt(handle, destX, destY, destWidth, destHeight, memHdc, 0, 0, OS.SRCCOPY);
 
     /* Free resources */
@@ -1357,13 +1361,13 @@
     OS.DeleteDC(srcHdc);
 }
 
-void drawBitmapTransparentByClipping(int srcHdc, int maskHdc, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, int imgWidth, int imgHeight) {
+void drawBitmapTransparentByClipping(HDC srcHdc, HDC maskHdc, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, int imgWidth, int imgHeight) {
     /* Create a clipping region from the mask */
-    int rgn = OS.CreateRectRgn(0, 0, 0, 0);
+    auto rgn = OS.CreateRectRgn(0, 0, 0, 0);
     for (int y=0; y<imgHeight; y++) {
         for (int x=0; x<imgWidth; x++) {
             if (OS.GetPixel(maskHdc, x, y) is 0) {
-                int tempRgn = OS.CreateRectRgn(x, y, x+1, y+1);
+                auto tempRgn = OS.CreateRectRgn(x, y, x+1, y+1);
                 OS.CombineRgn(rgn, rgn, tempRgn, OS.RGN_OR);
                 OS.DeleteObject(tempRgn);
             }
@@ -1373,14 +1377,17 @@
     if (destWidth !is srcWidth || destHeight !is srcHeight) {
         int nBytes = OS.GetRegionData (rgn, 0, null);
         int[] lpRgnData = new int[nBytes / 4];
-        OS.GetRegionData (rgn, nBytes, lpRgnData);
-        float[] lpXform = new float[] {(float)destWidth/srcWidth, 0, 0, (float)destHeight/srcHeight, 0, 0};
-        int tmpRgn = OS.ExtCreateRegion(lpXform, nBytes, lpRgnData);
+        OS.GetRegionData (rgn, nBytes, cast(RGNDATA*)lpRgnData.ptr);
+        float[6] lpXform;
+        lpXform[] = 0.0f;
+        lpXform[0] = cast(float)destWidth/srcWidth;
+        lpXform[3] = cast(float)destHeight/srcHeight;
+        auto tmpRgn = OS.ExtCreateRegion(cast(XFORM*)lpXform.ptr, nBytes, cast(RGNDATA*)lpRgnData.ptr);
         OS.DeleteObject(rgn);
         rgn = tmpRgn;
     }
     OS.OffsetRgn(rgn, destX, destY);
-    int clip = OS.CreateRectRgn(0, 0, 0, 0);
+    auto clip = OS.CreateRectRgn(0, 0, 0, 0);
     int result = OS.GetClipRgn(handle, clip);
     if (result is 1) OS.CombineRgn(rgn, rgn, clip, OS.RGN_AND);
     OS.SelectClipRgn(handle, rgn);
@@ -1400,21 +1407,23 @@
     } else {
         OS.BitBlt(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, dwRop);
     }
-    OS.SelectClipRgn(handle, result is 1 ? clip : 0);
+    OS.SelectClipRgn(handle, result is 1 ? clip : null);
     OS.DeleteObject(clip);
     OS.DeleteObject(rgn);
 }
 
-void drawBitmapMask(Image srcImage, int srcColor, int srcMask, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, int imgWidth, int imgHeight, bool offscreen) {
+void drawBitmapMask(Image srcImage, HBITMAP srcColor, HBITMAP srcMask, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, int imgWidth, int imgHeight, bool offscreen) {
     int srcColorY = srcY;
-    if (srcColor is 0) {
+    if (srcColor is null) {
         srcColor = srcMask;
         srcColorY += imgHeight;
     }
-    int srcHdc = OS.CreateCompatibleDC(handle);
-    int oldSrcBitmap = OS.SelectObject(srcHdc, srcColor);
-    int destHdc = handle, x = destX, y = destY;
-    int tempHdc = 0, tempBitmap = 0, oldTempBitmap = 0;
+    auto srcHdc = OS.CreateCompatibleDC(handle);
+    auto oldSrcBitmap = OS.SelectObject(srcHdc, srcColor);
+    auto destHdc = handle, x = destX, y = destY;
+    HDC tempHdc;
+    HBITMAP tempBitmap;
+    HBITMAP oldTempBitmap;
     int oldBkColor = 0, oldTextColor = 0;
     if (offscreen) {
         tempHdc = OS.CreateCompatibleDC(handle);
@@ -1461,10 +1470,10 @@
 
     /* Find the RGB values for the transparent pixel. */
     int transBlue = 0, transGreen = 0, transRed = 0;
-    bool isDib = bm.bmBits !is 0;
-    int hBitmap = srcImage.handle;
-    int srcHdc = OS.CreateCompatibleDC(handle);
-    int oldSrcBitmap = OS.SelectObject(srcHdc, hBitmap);
+    bool isDib = bm.bmBits !is null;
+    auto hBitmap = srcImage.handle;
+    auto srcHdc = OS.CreateCompatibleDC(handle);
+    auto oldSrcBitmap = OS.SelectObject(srcHdc, hBitmap);
     byte[] originalColors = null;
     if (bm.bmBitsPixel <= 8) {
         if (isDib) {
@@ -1474,7 +1483,7 @@
                 OS.MoveMemory(pBits, bm.bmBits, 1);
                 byte oldValue = pBits[0];
                 int mask = (0xFF << (8 - bm.bmBitsPixel)) & 0x00FF;
-                pBits[0] = (byte)((srcImage.transparentPixel << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask));
+                pBits[0] = cast(byte)((srcImage.transparentPixel << (8 - bm.bmBitsPixel)) | (pBits[0] & ~mask));
                 OS.MoveMemory(bm.bmBits, pBits, 1);
                 int color = OS.GetPixel(srcHdc, 0, 0);
                 pBits[0] = oldValue;
@@ -1499,9 +1508,9 @@
                 if (fixPalette) {
                     byte[] newColors = new byte[oldColors.length];
                     transRed = transGreen = transBlue = 0xff;
-                    newColors[offset] = (byte)transBlue;
-                    newColors[offset+1] = (byte)transGreen;
-                    newColors[offset+2] = (byte)transRed;
+                    newColors[offset] = cast(byte)transBlue;
+                    newColors[offset+1] = cast(byte)transGreen;
+                    newColors[offset+2] = cast(byte)transRed;
                     OS.SetDIBColorTable(srcHdc, 0, maxColors, newColors);
                     originalColors = oldColors;
                 } else {
@@ -1563,9 +1572,9 @@
         OS.SetStretchBltMode(handle, mode);
     } else {
         /* Create the mask for the source image */
-        int maskHdc = OS.CreateCompatibleDC(handle);
-        int maskBitmap = OS.CreateBitmap(imgWidth, imgHeight, 1, 1, null);
-        int oldMaskBitmap = OS.SelectObject(maskHdc, maskBitmap);
+        auto maskHdc = OS.CreateCompatibleDC(handle);
+        auto maskBitmap = OS.CreateBitmap(imgWidth, imgHeight, 1, 1, null);
+        auto oldMaskBitmap = OS.SelectObject(maskHdc, maskBitmap);
         OS.SetBkColor(srcHdc, transparentColor);
         OS.BitBlt(maskHdc, 0, 0, imgWidth, imgHeight, srcHdc, 0, 0, OS.SRCCOPY);
         if (originalColors !is null) OS.SetDIBColorTable(srcHdc, 0, 1 << bm.bmBitsPixel, originalColors);
@@ -1575,9 +1584,9 @@
             drawBitmapTransparentByClipping(srcHdc, maskHdc, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight);
         } else {
             /* Draw the source bitmap transparently using invert/and mask/invert */
-            int tempHdc = OS.CreateCompatibleDC(handle);
-            int tempBitmap = OS.CreateCompatibleBitmap(handle, destWidth, destHeight);
-            int oldTempBitmap = OS.SelectObject(tempHdc, tempBitmap);
+            auto tempHdc = OS.CreateCompatibleDC(handle);
+            auto tempBitmap = OS.CreateCompatibleBitmap(handle, destWidth, destHeight);
+            auto oldTempBitmap = OS.SelectObject(tempHdc, tempBitmap);
             OS.BitBlt(tempHdc, 0, 0, destWidth, destHeight, handle, destX, destY, OS.SRCCOPY);
             if (!simple && (srcWidth !is destWidth || srcHeight !is destHeight)) {
                 if (!OS.IsWinCE) OS.SetStretchBltMode(tempHdc, OS.COLORONCOLOR);
@@ -1604,8 +1613,8 @@
 }
 
 void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, bool simple, BITMAP bm, int imgWidth, int imgHeight) {
-    int srcHdc = OS.CreateCompatibleDC(handle);
-    int oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);
+    auto srcHdc = OS.CreateCompatibleDC(handle);
+    auto oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);
     int rop2 = 0;
     if (!OS.IsWinCE) {
         rop2 = OS.GetROP2(handle);
@@ -1640,10 +1649,10 @@
  * </ul>
  */
 public void drawLine (int x1, int y1, int x2, int y2) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(DRAW);
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend);
         Gdip.Graphics_DrawLine(gdipGraphics, data.gdipPen, x1, y1, x2, y2);
         Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend);
@@ -1656,7 +1665,7 @@
         }
     }
     if (OS.IsWinCE) {
-        int [] points = new int [] {x1, y1, x2, y2};
+        int [] points = [x1, y1, x2, y2];
         OS.Polyline (handle, points, points.length / 2);
     } else {
         OS.MoveToEx (handle, x1, y1, 0);
@@ -1689,10 +1698,10 @@
  * </ul>
  */
 public void drawOval (int x, int y, int width, int height) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(DRAW);
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend);
         Gdip.Graphics_DrawEllipse(gdipGraphics, data.gdipPen, x, y, width, height);
         Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend);
@@ -1728,12 +1737,12 @@
  * @since 3.1
  */
 public void drawPath (Path path) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    if (path.handle is 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (path.handle is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     initGdip();
     checkGC(DRAW);
-    int gdipGraphics = data.gdipGraphics;
+    auto gdipGraphics = data.gdipGraphics;
     Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend);
     Gdip.Graphics_DrawPath(gdipGraphics, data.gdipPen, path.handle);
     Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend);
@@ -1757,8 +1766,8 @@
  * @since 3.0
  */
 public void drawPoint (int x, int y) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    if (data.gdipGraphics !is 0) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.gdipGraphics !is null) {
         checkGC(DRAW);
         Gdip.Graphics_FillRectangle(data.gdipGraphics, getFgBrush(), x, y, 1, 1);
         return;
@@ -1784,11 +1793,11 @@
  * </ul>
  */
 public void drawPolygon(int[] pointArray) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     checkGC(DRAW);
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend);
         Gdip.Graphics_DrawPolygon(gdipGraphics, data.gdipPen, pointArray, pointArray.length / 2);
         Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend);
@@ -1829,11 +1838,11 @@
  * </ul>
  */
 public void drawPolyline(int[] pointArray) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     checkGC(DRAW);
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend);
         Gdip.Graphics_DrawLines(gdipGraphics, data.gdipPen, pointArray, pointArray.length / 2);
         Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend);
@@ -1847,10 +1856,10 @@
         }
     }
     OS.Polyline(handle, pointArray, pointArray.length / 2);
-    int length = pointArray.length;
-    if (length >= 2) {
+    int length_ = pointArray.length;
+    if (length_ >= 2) {
         if (data.lineWidth <= 1) {
-            OS.SetPixel (handle, pointArray[length - 2], pointArray[length - 1], data.foreground);
+            OS.SetPixel (handle, pointArray[length_ - 2], pointArray[length_ - 1], data.foreground);
         }
     }
     if ((data.style & DWT.MIRRORED) !is 0) {
@@ -1878,10 +1887,10 @@
  * </ul>
  */
 public void drawRectangle (int x, int y, int width, int height) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(DRAW);
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend);
         Gdip.Graphics_DrawRectangle(gdipGraphics, data.gdipPen, x, y, width, height);
         Gdip.Graphics_TranslateTransform(gdipGraphics, -data.gdipXOffset, -data.gdipYOffset, Gdip.MatrixOrderPrepend);
@@ -1895,7 +1904,7 @@
         if (data.lineWidth > 1) {
             if ((data.lineWidth % 2) is 1) x++;
         } else {
-            if (data.hPen !is 0 && OS.GetObject(data.hPen, 0, 0) !is LOGPEN.sizeof) {
+            if (data.hPen !is null && OS.GetObject(data.hPen, 0, 0) !is LOGPEN.sizeof) {
                 x++;
             }
         }
@@ -1946,9 +1955,9 @@
  * </ul>
  */
 public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(DRAW);
-    if (data.gdipGraphics !is 0) {
+    if (data.gdipGraphics !is null) {
         drawRoundRectangleGdip(data.gdipGraphics, data.gdipPen, x, y, width, height, arcWidth, arcHeight);
         return;
     }
@@ -2020,8 +2029,8 @@
         nah = 0 - nah;
 
     Gdip.Graphics_TranslateTransform(gdipGraphics, data.gdipXOffset, data.gdipYOffset, Gdip.MatrixOrderPrepend);
-    int path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate);
-    if (path is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    auto path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate);
+    if (path is null) DWT.error(DWT.ERROR_NO_HANDLES);
     if (nw > naw) {
         if (nh > nah) {
             Gdip.GraphicsPath_AddArc(path, nx + nw - naw, ny, naw, nah, 0, -90);
@@ -2064,7 +2073,7 @@
  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
  * </ul>
  */
-public void drawString (String string, int x, int y) {
+public void drawString (char[] string, int x, int y) {
     drawString(string, x, y, false);
 }
 
@@ -2088,16 +2097,16 @@
  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
  * </ul>
  */
-public void drawString (String string, int x, int y, bool isTransparent) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+public void drawString (char[] string, int x, int y, bool isTransparent) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
 //  TCHAR buffer = new TCHAR (getCodePage(), string, false);
-    int length = string.length();
-    if (length is 0) return;
-    char[] buffer = new char [length];
-    string.getChars(0, length, buffer, 0);
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    int length_ = string.length;
+    if (length_ is 0) return;
+    char[] buffer = new char [length_];
+    string.getChars(0, length_, buffer, 0);
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         checkGC(FONT | FOREGROUND | (isTransparent ? 0 : BACKGROUND));
         PointF pt = new PointF();
         int format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic());
@@ -2106,7 +2115,7 @@
         Gdip.StringFormat_SetFormatFlags(format, formatFlags);
         if (!isTransparent) {
             RectF bounds = new RectF();
-            Gdip.Graphics_MeasureString(gdipGraphics, buffer, length, data.gdipFont, pt, format, bounds);
+            Gdip.Graphics_MeasureString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, bounds);
             Gdip.Graphics_FillRectangle(gdipGraphics, data.gdipBrush, x, y, Math.round(bounds.Width), Math.round(bounds.Height));
         }
         int gstate = 0, brush = getFgBrush();
@@ -2127,7 +2136,7 @@
         }
         pt.X = x;
         pt.Y = y;
-        Gdip.Graphics_DrawString(gdipGraphics, buffer, length, data.gdipFont, pt, format, brush);
+        Gdip.Graphics_DrawString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, brush);
         if ((data.style & DWT.MIRRORED) !is 0) {
             switch (Gdip.Brush_GetType(brush)) {
                 case Gdip.BrushTypeLinearGradient:
@@ -2157,7 +2166,7 @@
     if ((data.style & DWT.MIRRORED) !is 0) {
         if (!isTransparent) {
             size = new SIZE();
-            OS.GetTextExtentPoint32W(handle, buffer, length, size);
+            OS.GetTextExtentPoint32W(handle, buffer, length_, size);
             rect = new RECT ();
             rect.left = x;
             rect.right = x + size.cx;
@@ -2168,24 +2177,24 @@
         x--;
     }
     if (rop2 !is OS.R2_XORPEN) {
-        OS.ExtTextOutW(handle, x, y, flags, rect, buffer, length, null);
+        OS.ExtTextOutW(handle, x, y, flags, rect, buffer, length_, null);
     } else {
         int foreground = OS.GetTextColor(handle);
         if (isTransparent) {
             if (size is null) {
                 size = new SIZE();
-                OS.GetTextExtentPoint32W(handle, buffer, length, size);
+                OS.GetTextExtentPoint32W(handle, buffer, length_, size);
             }
             int width = size.cx, height = size.cy;
             int hBitmap = OS.CreateCompatibleBitmap(handle, width, height);
-            if (hBitmap is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+            if (hBitmap is null) DWT.error(DWT.ERROR_NO_HANDLES);
             int memDC = OS.CreateCompatibleDC(handle);
             int hOldBitmap = OS.SelectObject(memDC, hBitmap);
             OS.PatBlt(memDC, 0, 0, width, height, OS.BLACKNESS);
             OS.SetBkMode(memDC, OS.TRANSPARENT);
             OS.SetTextColor(memDC, foreground);
             OS.SelectObject(memDC, OS.GetCurrentObject(handle, OS.OBJ_FONT));
-            OS.ExtTextOutW(memDC, 0, 0, 0, null, buffer, length, null);
+            OS.ExtTextOutW(memDC, 0, 0, 0, null, buffer, length_, null);
             OS.BitBlt(handle, x, y, width, height, memDC, 0, 0, OS.SRCINVERT);
             OS.SelectObject(memDC, hOldBitmap);
             OS.DeleteDC(memDC);
@@ -2193,7 +2202,7 @@
         } else {
             int background = OS.GetBkColor(handle);
             OS.SetTextColor(handle, foreground ^ background);
-            OS.ExtTextOutW(handle, x, y, flags, rect, buffer, length, null);
+            OS.ExtTextOutW(handle, x, y, flags, rect, buffer, length_, null);
             OS.SetTextColor(handle, foreground);
         }
     }
@@ -2218,7 +2227,7 @@
  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
  * </ul>
  */
-public void drawText (String string, int x, int y) {
+public void drawText (char[] string, int x, int y) {
     drawText(string, x, y, DWT.DRAW_DELIMITER | DWT.DRAW_TAB);
 }
 
@@ -2242,7 +2251,7 @@
  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
  * </ul>
  */
-public void drawText (String string, int x, int y, bool isTransparent) {
+public void drawText (char[] string, int x, int y, bool isTransparent) {
     int flags = DWT.DRAW_DELIMITER | DWT.DRAW_TAB;
     if (isTransparent) flags |= DWT.DRAW_TRANSPARENT;
     drawText(string, x, y, flags);
@@ -2282,29 +2291,29 @@
  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
  * </ul>
  */
-public void drawText (String string, int x, int y, int flags) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+public void drawText (char[] string, int x, int y, int flags) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    if (string.length() is 0) return;
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    if (string.length is 0) return;
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         checkGC(FONT | FOREGROUND | ((flags & DWT.DRAW_TRANSPARENT) !is 0 ? 0 : BACKGROUND));
-        int length = string.length();
-        char[] buffer = new char [length];
-        string.getChars(0, length, buffer, 0);
+        int length_ = string.length;
+        char[] buffer = new char [length_];
+        string.getChars(0, length_, buffer, 0);
         PointF pt = new PointF();
         int format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic());
         int formatFlags = Gdip.StringFormat_GetFormatFlags(format) | Gdip.StringFormatFlagsMeasureTrailingSpaces;
         if ((data.style & DWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft;
         Gdip.StringFormat_SetFormatFlags(format, formatFlags);
-        float[] tabs = (flags & DWT.DRAW_TAB) !is 0 ? new float[]{measureSpace(data.gdipFont, format) * 8} : new float[1];
+        float[] tabs = (flags & DWT.DRAW_TAB) !is 0 ? [measureSpace(data.gdipFont, format) * 8] : new float[1];
         Gdip.StringFormat_SetTabStops(format, 0, tabs.length, tabs);
         int hotkeyPrefix = (flags & DWT.DRAW_MNEMONIC) !is 0 ? Gdip.HotkeyPrefixShow : Gdip.HotkeyPrefixNone;
         if ((flags & DWT.DRAW_MNEMONIC) !is 0 && (data.uiState & OS.UISF_HIDEACCEL) !is 0) hotkeyPrefix = Gdip.HotkeyPrefixHide;
         Gdip.StringFormat_SetHotkeyPrefix(format, hotkeyPrefix);
         if ((flags & DWT.DRAW_TRANSPARENT) is 0) {
             RectF bounds = new RectF();
-            Gdip.Graphics_MeasureString(gdipGraphics, buffer, length, data.gdipFont, pt, format, bounds);
+            Gdip.Graphics_MeasureString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, bounds);
             Gdip.Graphics_FillRectangle(gdipGraphics, data.gdipBrush, x, y, Math.round(bounds.Width), Math.round(bounds.Height));
         }
         int gstate = 0, brush = getFgBrush();
@@ -2325,7 +2334,7 @@
         }
         pt.X = x;
         pt.Y = y;
-        Gdip.Graphics_DrawString(gdipGraphics, buffer, length, data.gdipFont, pt, format, brush);
+        Gdip.Graphics_DrawString(gdipGraphics, buffer, length_, data.gdipFont, pt, format, brush);
         if ((data.style & DWT.MIRRORED) !is 0) {
             switch (Gdip.Brush_GetType(brush)) {
                 case Gdip.BrushTypeLinearGradient:
@@ -2341,8 +2350,8 @@
         return;
     }
     TCHAR buffer = new TCHAR(getCodePage(), string, false);
-    int length = buffer.length();
-    if (length is 0) return;
+    int length_ = buffer.length();
+    if (length_ is 0) return;
     RECT rect = new RECT();
     /*
     * Feature in Windows.  For some reason DrawText(), the maximum
@@ -2373,15 +2382,15 @@
     checkGC(FONT | FOREGROUND_TEXT | BACKGROUND_TEXT);
     int oldBkMode = OS.SetBkMode(handle, (flags & DWT.DRAW_TRANSPARENT) !is 0 ? OS.TRANSPARENT : OS.OPAQUE);
     if (rop2 !is OS.R2_XORPEN) {
-        OS.DrawText(handle, buffer, length, rect, uFormat);
+        OS.DrawText(handle, buffer, length_, rect, uFormat);
     } else {
         int foreground = OS.GetTextColor(handle);
         if ((flags & DWT.DRAW_TRANSPARENT) !is 0) {
             OS.DrawText(handle, buffer, buffer.length(), rect, uFormat | OS.DT_CALCRECT);
             int width = rect.right - rect.left;
             int height = rect.bottom - rect.top;
-            int hBitmap = OS.CreateCompatibleBitmap(handle, width, height);
-            if (hBitmap is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+            auto hBitmap = OS.CreateCompatibleBitmap(handle, width, height);
+            if (hBitmap is null) DWT.error(DWT.ERROR_NO_HANDLES);
             int memDC = OS.CreateCompatibleDC(handle);
             int hOldBitmap = OS.SelectObject(memDC, hBitmap);
             OS.PatBlt(memDC, 0, 0, width, height, OS.BLACKNESS);
@@ -2389,7 +2398,7 @@
             OS.SetTextColor(memDC, foreground);
             OS.SelectObject(memDC, OS.GetCurrentObject(handle, OS.OBJ_FONT));
             OS.SetRect(rect, 0, 0, 0x7FFF, 0x7FFF);
-            OS.DrawText(memDC, buffer, length, rect, uFormat);
+            OS.DrawText(memDC, buffer, length_, rect, uFormat);
             OS.BitBlt(handle, x, y, width, height, memDC, 0, 0, OS.SRCINVERT);
             OS.SelectObject(memDC, hOldBitmap);
             OS.DeleteDC(memDC);
@@ -2397,7 +2406,7 @@
         } else {
             int background = OS.GetBkColor(handle);
             OS.SetTextColor(handle, foreground ^ background);
-            OS.DrawText(handle, buffer, length, rect, uFormat);
+            OS.DrawText(handle, buffer, length_, rect, uFormat);
             OS.SetTextColor(handle, foreground);
         }
     }
@@ -2415,7 +2424,7 @@
  * @see #hashCode
  */
 public bool equals (Object object) {
-    return (object is this) || ((object instanceof GC) && (handle is ((GC)object).handle));
+    return (object is this) || (null !is (cast(GC)object) && (handle is (cast(GC)object).handle));
 }
 
 /**
@@ -2451,7 +2460,7 @@
  * @see #drawArc
  */
 public void fillArc (int x, int y, int width, int height, int startAngle, int arcAngle) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(FILL);
     if (width < 0) {
         x = x + width;
@@ -2462,8 +2471,8 @@
         height = -height;
     }
     if (width is 0 || height is 0 || arcAngle is 0) return;
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         if (width is height) {
             Gdip.Graphics_FillPie(gdipGraphics, data.gdipBrush, x, y, width, height, -startAngle, -arcAngle);
         } else {
@@ -2552,7 +2561,7 @@
  * @see #drawRectangle(int, int, int, int)
  */
 public void fillGradientRectangle(int x, int y, int width, int height, bool vertical) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (width is 0 || height is 0) return;
 
     RGB backgroundRGB, foregroundRGB;
@@ -2580,7 +2589,7 @@
         fillRectangle(x, y, width, height);
         return;
     }
-    if (data.gdipGraphics !is 0) {
+    if (data.gdipGraphics !is null) {
         initGdip();
         PointF p1= new PointF(), p2 = new PointF();
         p1.X = x;
@@ -2593,11 +2602,11 @@
             p2.Y = p1.Y;
         }
         int rgb = ((fromRGB.red & 0xFF) << 16) | ((fromRGB.green & 0xFF) << 8) | (fromRGB.blue & 0xFF);
-        int fromGpColor = Gdip.Color_new(data.alpha << 24 | rgb);
-        if (fromGpColor is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+        auto fromGpColor = Gdip.Color_new(data.alpha << 24 | rgb);
+        if (fromGpColor is null) DWT.error(DWT.ERROR_NO_HANDLES);
         rgb = ((toRGB.red & 0xFF) << 16) | ((toRGB.green & 0xFF) << 8) | (toRGB.blue & 0xFF);
-        int toGpColor = Gdip.Color_new(data.alpha << 24 | rgb);
-        if (toGpColor is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+        auto toGpColor = Gdip.Color_new(data.alpha << 24 | rgb);
+        if (toGpColor is null) DWT.error(DWT.ERROR_NO_HANDLES);
         int brush = Gdip.LinearGradientBrush_new(p1, p2, fromGpColor, toGpColor);
         Gdip.Graphics_FillRectangle(data.gdipGraphics, brush, x, y, width, height);
         Gdip.LinearGradientBrush_delete(brush);
@@ -2622,9 +2631,9 @@
         rop2 = OS.GetROP2(handle);
     }
     if (OS.IsWinNT && rop2 !is OS.R2_XORPEN && OS.GetDeviceCaps(handle, OS.TECHNOLOGY) !is OS.DT_RASPRINTER) {
-        final int hHeap = OS.GetProcessHeap();
-        final int pMesh = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, GRADIENT_RECT.sizeof + TRIVERTEX.sizeof * 2);
-        if (pMesh is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+        final auto hHeap = OS.GetProcessHeap();
+        final auto pMesh = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, GRADIENT_RECT.sizeof + TRIVERTEX.sizeof * 2);
+        if (pMesh is null) DWT.error(DWT.ERROR_NO_HANDLES);
         final int pVertex = pMesh + GRADIENT_RECT.sizeof;
 
         GRADIENT_RECT gradientRect = new GRADIENT_RECT();
@@ -2635,17 +2644,17 @@
         TRIVERTEX trivertex = new TRIVERTEX();
         trivertex.x = x;
         trivertex.y = y;
-        trivertex.Red = (short)((fromRGB.red << 8) | fromRGB.red);
-        trivertex.Green = (short)((fromRGB.green << 8) | fromRGB.green);
-        trivertex.Blue = (short)((fromRGB.blue << 8) | fromRGB.blue);
+        trivertex.Red = cast(short)((fromRGB.red << 8) | fromRGB.red);
+        trivertex.Green = cast(short)((fromRGB.green << 8) | fromRGB.green);
+        trivertex.Blue = cast(short)((fromRGB.blue << 8) | fromRGB.blue);
         trivertex.Alpha = -1;
         OS.MoveMemory(pVertex, trivertex, TRIVERTEX.sizeof);
 
         trivertex.x = x + width;
         trivertex.y = y + height;
-        trivertex.Red = (short)((toRGB.red << 8) | toRGB.red);
-        trivertex.Green = (short)((toRGB.green << 8) | toRGB.green);
-        trivertex.Blue = (short)((toRGB.blue << 8) | toRGB.blue);
+        trivertex.Red = cast(short)((toRGB.red << 8) | toRGB.red);
+        trivertex.Green = cast(short)((toRGB.green << 8) | toRGB.green);
+        trivertex.Blue = cast(short)((toRGB.blue << 8) | toRGB.blue);
         trivertex.Alpha = -1;
         OS.MoveMemory(pVertex + TRIVERTEX.sizeof, trivertex, TRIVERTEX.sizeof);
 
@@ -2678,9 +2687,9 @@
  * @see #drawOval
  */
 public void fillOval (int x, int y, int width, int height) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(FILL);
-    if (data.gdipGraphics !is 0) {
+    if (data.gdipGraphics !is null) {
         Gdip.Graphics_FillEllipse(data.gdipGraphics, data.gdipBrush, x, y, width, height);
         return;
     }
@@ -2712,9 +2721,9 @@
  * @since 3.1
  */
 public void fillPath (Path path) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (path is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
-    if (path.handle is 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    if (path.handle is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     initGdip();
     checkGC(FILL);
     int mode = OS.GetPolyFillMode(handle) is OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate;
@@ -2742,10 +2751,10 @@
  * @see #drawPolygon
  */
 public void fillPolygon(int[] pointArray) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (pointArray is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     checkGC(FILL);
-    if (data.gdipGraphics !is 0) {
+    if (data.gdipGraphics !is null) {
         int mode = OS.GetPolyFillMode(handle) is OS.WINDING ? Gdip.FillModeWinding : Gdip.FillModeAlternate;
         Gdip.Graphics_FillPolygon(data.gdipGraphics, data.gdipBrush, pointArray, pointArray.length / 2, mode);
         return;
@@ -2779,9 +2788,9 @@
  * @see #drawRectangle(int, int, int, int)
  */
 public void fillRectangle (int x, int y, int width, int height) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(FILL);
-    if (data.gdipGraphics !is 0) {
+    if (data.gdipGraphics !is null) {
         Gdip.Graphics_FillRectangle(data.gdipGraphics, data.gdipBrush, x, y, width, height);
         return;
     }
@@ -2834,9 +2843,9 @@
  * @see #drawRoundRectangle
  */
 public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(FILL);
-    if (data.gdipGraphics !is 0) {
+    if (data.gdipGraphics !is null) {
         fillRoundRectangleGdip(data.gdipGraphics, data.gdipBrush, x, y, width, height, arcWidth, arcHeight);
         return;
     }
@@ -2865,8 +2874,8 @@
     if (nah < 0)
         nah = 0 - nah;
 
-    int path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate);
-    if (path is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    auto path = Gdip.GraphicsPath_new(Gdip.FillModeAlternate);
+    if (path is null) DWT.error(DWT.ERROR_NO_HANDLES);
     if (nw > naw) {
         if (nh > nah) {
             Gdip.GraphicsPath_AddArc(path, nx + nw - naw, ny, naw, nah, 0, -90);
@@ -2891,7 +2900,7 @@
 }
 
 void flush () {
-    if (data.gdipGraphics !is 0) {
+    if (data.gdipGraphics !is null) {
         Gdip.Graphics_Flush(data.gdipGraphics, 0);
         /*
         * Note Flush() does not flush the output to the
@@ -2919,11 +2928,11 @@
  * </ul>
  */
 public int getAdvanceWidth(char ch) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(FONT);
     if (OS.IsWinCE) {
         SIZE size = new SIZE();
-        OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, size);
+        OS.GetTextExtentPoint32W(handle, [ch], 1, size);
         return size.cx;
     }
     int tch = ch;
@@ -2962,8 +2971,8 @@
  * @since 3.1
  */
 public bool getAdvanced() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    return data.gdipGraphics !is 0;
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return data.gdipGraphics !is null;
 }
 
 /**
@@ -2978,7 +2987,7 @@
  * @since 3.1
  */
 public int getAlpha() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return data.alpha;
 }
 
@@ -2999,8 +3008,8 @@
  * @since 3.1
  */
 public int getAntialias() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    if (data.gdipGraphics is 0) return DWT.DEFAULT;
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.gdipGraphics is null) return DWT.DEFAULT;
     int mode = Gdip.Graphics_GetSmoothingMode(data.gdipGraphics);
     switch (mode) {
         case Gdip.SmoothingModeDefault: return DWT.DEFAULT;
@@ -3023,7 +3032,7 @@
  * </ul>
  */
 public Color getBackground() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return Color.win32_new(data.device, data.background);
 }
 
@@ -3042,7 +3051,7 @@
  * @since 3.1
  */
 public Pattern getBackgroundPattern() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return data.backgroundPattern;
 }
 
@@ -3063,7 +3072,7 @@
  * </ul>
  */
 public int getCharWidth(char ch) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(FONT);
 
     /* GetCharABCWidths only succeeds on truetype fonts */
@@ -3080,10 +3089,10 @@
     }
 
     /* It wasn't a truetype font */
-    TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW() : new TEXTMETRICA();
-    OS.GetTextMetrics(handle, lptm);
-    SIZE size = new SIZE();
-    OS.GetTextExtentPoint32W(handle, new char[]{ch}, 1, size);
+    TEXTMETRIC lptm;
+    OS.GetTextMetrics(handle, &lptm);
+    SIZE size;
+    OS.GetTextExtentPoint32W(handle, [ch], 1, &size);
     return size.cx - lptm.tmOverhang;
 }
 
@@ -3100,9 +3109,9 @@
  * </ul>
  */
 public Rectangle getClipping() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         Rect rect = new Rect();
         Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeNone);
         Gdip.Graphics_GetVisibleClipBounds(gdipGraphics, rect);
@@ -3129,11 +3138,11 @@
  * </ul>
  */
 public void getClipping (Region region) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (region is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
     if (region.isDisposed()) DWT.error (DWT.ERROR_INVALID_ARGUMENT);
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         int rgn = Gdip.Region_new();
         Gdip.Graphics_GetClip(data.gdipGraphics, rgn);
         if (Gdip.Region_IsInfinite(rgn, gdipGraphics)) {
@@ -3169,13 +3178,13 @@
     }
     if (!OS.IsWinCE) {
         int metaRgn = OS.CreateRectRgn (0, 0, 0, 0);
-        if (OS.GetMetaRgn (handle, metaRgn) !is 0) {
+        if (OS.GetMetaRgn (handle, metaRgn) !is null) {
             OS.OffsetRgn (metaRgn, pt.x, pt.y);
             OS.CombineRgn (region.handle, metaRgn, region.handle, OS.RGN_AND);
         }
         OS.DeleteObject(metaRgn);
         int hwnd = data.hwnd;
-        if (hwnd !is 0 && data.ps !is null) {
+        if (hwnd !is null && data.ps !is null) {
             int sysRgn = OS.CreateRectRgn (0, 0, 0, 0);
             if (OS.GetRandomRgn (handle, sysRgn, OS.SYSRGN) is 1) {
                 if (OS.WIN32_VERSION >= OS.VERSION(4, 10)) {
@@ -3183,7 +3192,7 @@
                         int nBytes = OS.GetRegionData (sysRgn, 0, null);
                         int [] lpRgnData = new int [nBytes / 4];
                         OS.GetRegionData (sysRgn, nBytes, lpRgnData);
-                        int newSysRgn = OS.ExtCreateRegion(new float [] {-1, 0, 0, 1, 0, 0}, nBytes, lpRgnData);
+                        int newSysRgn = OS.ExtCreateRegion([-1, 0, 0, 1, 0, 0], nBytes, lpRgnData);
                         OS.DeleteObject(sysRgn);
                         sysRgn = newSysRgn;
                     }
@@ -3224,7 +3233,7 @@
  * @since 3.1
  */
 public int getFillRule() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (OS.IsWinCE) return DWT.FILL_EVEN_ODD;
     return OS.GetPolyFillMode(handle) is OS.WINDING ? DWT.FILL_WINDING : DWT.FILL_EVEN_ODD;
 }
@@ -3240,7 +3249,7 @@
  * </ul>
  */
 public Font getFont () {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return Font.win32_new(data.device, data.hFont);
 }
 
@@ -3256,11 +3265,11 @@
  * </ul>
  */
 public FontMetrics getFontMetrics() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     checkGC(FONT);
-    TEXTMETRIC lptm = OS.IsUnicode ? (TEXTMETRIC)new TEXTMETRICW() : new TEXTMETRICA();
-    OS.GetTextMetrics(handle, lptm);
-    return FontMetrics.win32_new(lptm);
+    TEXTMETRIC lptm;
+    OS.GetTextMetrics(handle, &lptm);
+    return FontMetrics.win32_new(&lptm);
 }
 
 /**
@@ -3273,7 +3282,7 @@
  * </ul>
  */
 public Color getForeground() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return Color.win32_new(data.device, data.foreground);
 }
 
@@ -3292,7 +3301,7 @@
  * @since 3.1
  */
 public Pattern getForegroundPattern() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return data.foregroundPattern;
 }
 
@@ -3317,7 +3326,7 @@
  * @since 3.2
  */
 public GCData getGCData() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return data;
 }
 
@@ -3335,8 +3344,8 @@
  * @since 3.1
  */
 public int getInterpolation() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    if (data.gdipGraphics is 0) return DWT.DEFAULT;
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.gdipGraphics is null) return DWT.DEFAULT;
     int mode = Gdip.Graphics_GetInterpolationMode(data.gdipGraphics);
     switch (mode) {
         case Gdip.InterpolationModeDefault: return DWT.DEFAULT;
@@ -3363,7 +3372,7 @@
  * @since 3.3
  */
 public LineAttributes getLineAttributes() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     float[] dashes = null;
     if (data.lineDashes !is null) {
         dashes = new float[data.lineDashes.length];
@@ -3386,7 +3395,7 @@
  * @since 3.1
  */
 public int getLineCap() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return data.lineCap;
 }
 
@@ -3403,11 +3412,11 @@
  * @since 3.1
  */
 public int[] getLineDash() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (data.lineDashes is null) return null;
     int[] lineDashes = new int[data.lineDashes.length];
     for (int i = 0; i < lineDashes.length; i++) {
-        lineDashes[i] = (int)data.lineDashes[i];
+        lineDashes[i] = cast(int)data.lineDashes[i];
     }
     return lineDashes;
 }
@@ -3426,7 +3435,7 @@
  * @since 3.1
  */
 public int getLineJoin() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return data.lineJoin;
 }
 
@@ -3443,7 +3452,7 @@
  * </ul>
  */
 public int getLineStyle() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return data.lineStyle;
 }
 
@@ -3460,8 +3469,8 @@
  * </ul>
  */
 public int getLineWidth() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    return (int)data.lineWidth;
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    return cast(int)data.lineWidth;
 }
 
 /**
@@ -3483,7 +3492,7 @@
  * @since 2.1.2
  */
 public int getStyle () {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     return data.style;
 }
 
@@ -3504,8 +3513,8 @@
  * @since 3.1
  */
 public int getTextAntialias() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    if (data.gdipGraphics is 0) return DWT.DEFAULT;
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.gdipGraphics is null) return DWT.DEFAULT;
     int mode = Gdip.Graphics_GetTextRenderingHint(data.gdipGraphics);
     switch (mode) {
         case Gdip.TextRenderingHintSystemDefault: return DWT.DEFAULT;
@@ -3537,11 +3546,11 @@
  * @since 3.1
  */
 public void getTransform(Transform transform) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (transform is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     if (transform.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
         Gdip.Graphics_GetTransform(gdipGraphics, transform.handle);
         int identity = identity();
         Gdip.Matrix_Invert(identity);
@@ -3567,7 +3576,7 @@
  * </ul>
  */
 public bool getXORMode() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     int rop2 = 0;
     if (OS.IsWinCE) {
         rop2 = OS.SetROP2 (handle, OS.R2_COPYPEN);
@@ -3580,8 +3589,8 @@
 
 void initGdip() {
     data.device.checkGDIP();
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) return;
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) return;
     /*
     * Feature in GDI+. The GDI+ clipping set with Graphics->SetClip()
     * is always intersected with the GDI clipping at the time the
@@ -3610,7 +3619,7 @@
     }
 
     gdipGraphics = data.gdipGraphics = Gdip.Graphics_new(handle);
-    if (gdipGraphics is 0) DWT.error(DWT.ERROR_NO_HANDLES);
+    if (gdipGraphics is null) DWT.error(DWT.ERROR_NO_HANDLES);
     Gdip.Graphics_SetPageUnit(gdipGraphics, Gdip.UnitPixel);
     Gdip.Graphics_SetPixelOffsetMode(gdipGraphics, Gdip.PixelOffsetModeHalf);
     if ((data.style & DWT.MIRRORED) !is 0) {
@@ -3621,15 +3630,15 @@
     if (result is 1) setClipping(hRgn);
     OS.DeleteObject(hRgn);
     data.state = 0;
-    if (data.hPen !is 0) {
+    if (data.hPen !is null) {
         OS.SelectObject(handle, OS.GetStockObject(OS.NULL_PEN));
         OS.DeleteObject(data.hPen);
-        data.hPen = 0;
+        data.hPen = null;
     }
-    if (data.hBrush !is 0) {
+    if (data.hBrush !is null) {
         OS.SelectObject(handle, OS.GetStockObject(OS.NULL_BRUSH));
         OS.DeleteObject(data.hBrush);
-        data.hBrush = 0;
+        data.hBrush = null;
     }
 }
 
@@ -3641,7 +3650,7 @@
             BITMAP bm = new BITMAP();
             OS.GetObject(image.handle, BITMAP.sizeof, bm);
             width = bm.bmWidth;
-        } else if (data.hwnd !is 0) {
+        } else if (data.hwnd !is null) {
             RECT rect = new RECT();
             OS.GetClientRect(data.hwnd, rect);
             width = rect.right - rect.left;
@@ -3653,7 +3662,7 @@
     return Gdip.Matrix_new(1, 0, 0, 1, 0, 0);
 }
 
-void init(Drawable drawable, GCData data, int hDC) {
+void init(Drawable drawable, GCData data, HDC hDC) {
     int foreground = data.foreground;
     if (foreground !is -1) {
         data.state &= ~(FOREGROUND | FOREGROUND_TEXT | PEN);
@@ -3667,14 +3676,14 @@
         data.background = OS.GetBkColor(hDC);
     }
     data.state &= ~(NULL_BRUSH | NULL_PEN);
-    int hFont = data.hFont;
-    if (hFont !is 0) {
+    auto hFont = data.hFont;
+    if (hFont !is null) {
         data.state &= ~FONT;
     } else {
         hFont = OS.GetCurrentObject(hDC, OS.OBJ_FONT);
     }
-    int hPalette = data.device.hPalette;
-    if (hPalette !is 0) {
+    auto hPalette = data.device.hPalette;
+    if (hPalette !is null) {
         OS.SelectPalette(hDC, hPalette, true);
         OS.RealizePalette(hDC);
     }
@@ -3732,7 +3741,7 @@
  * </ul>
  */
 public bool isClipped() {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     int region = OS.CreateRectRgn(0, 0, 0, 0);
     int result = OS.GetClipRgn(handle, region);
     OS.DeleteObject(region);
@@ -3750,13 +3759,13 @@
  * @return <code>true</code> when the GC is disposed and <code>false</code> otherwise
  */
 public bool isDisposed() {
-    return handle is 0;
+    return handle is null;
 }
 
 float measureSpace(int font, int format) {
     PointF pt = new PointF();
     RectF bounds = new RectF();
-    Gdip.Graphics_MeasureString(data.gdipGraphics, new char[]{' '}, 1, font, pt, format, bounds);
+    Gdip.Graphics_MeasureString(data.gdipGraphics, (" "w).ptr, 1, font, pt, format, bounds);
     return bounds.Width;
 }
 
@@ -3803,8 +3812,8 @@
  * @since 3.1
  */
 public void setAdvanced(bool advanced) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    if (advanced && data.gdipGraphics !is 0) return;
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (advanced && data.gdipGraphics !is null) return;
     if (advanced) {
         try {
             initGdip();
@@ -3850,8 +3859,8 @@
  * @since 3.1
  */
 public void setAntialias(int antialias) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    if (data.gdipGraphics is 0 && antialias is DWT.DEFAULT) return;
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.gdipGraphics is null && antialias is DWT.DEFAULT) return;
     int mode = 0;
     switch (antialias) {
         case DWT.DEFAULT:
@@ -3890,8 +3899,8 @@
  * @since 3.1
  */
 public void setAlpha(int alpha) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    if (data.gdipGraphics is 0 && (alpha & 0xFF) is 0xFF) return;
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.gdipGraphics is null && (alpha & 0xFF) is 0xFF) return;
     initGdip();
     data.alpha = alpha & 0xFF;
     data.state &= ~(BACKGROUND | FOREGROUND);
@@ -3913,7 +3922,7 @@
  * </ul>
  */
 public void setBackground (Color color) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (color is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     if (data.backgroundPattern is null && data.background is color.handle) return;
@@ -3947,9 +3956,9 @@
  * @since 3.1
  */
 public void setBackgroundPattern (Pattern pattern) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (pattern !is null && pattern.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
-    if (data.gdipGraphics is 0 && pattern is null) return;
+    if (data.gdipGraphics is null && pattern is null) return;
     initGdip();
     if (data.backgroundPattern is pattern) return;
     data.backgroundPattern = pattern;
@@ -3958,9 +3967,9 @@
 
 void setClipping(int clipRgn) {
     int hRgn = clipRgn;
-    int gdipGraphics = data.gdipGraphics;
-    if (gdipGraphics !is 0) {
-        if (hRgn !is 0) {
+    auto gdipGraphics = data.gdipGraphics;
+    if (gdipGraphics !is null) {
+        if (hRgn !is null) {
             int region = Gdip.Region_new(hRgn);
             Gdip.Graphics_SetClip(gdipGraphics, region, Gdip.CombineModeReplace);
             Gdip.Region_delete(region);
@@ -3969,17 +3978,17 @@
         }
     } else {
         POINT pt = null;
-        if (hRgn !is 0 && !OS.IsWinCE) {
+        if (hRgn !is null && !OS.IsWinCE) {
             pt = new POINT();
             OS.GetWindowOrgEx(handle, pt);
             OS.OffsetRgn(hRgn, -pt.x, -pt.y);
         }
         OS.SelectClipRgn(handle, hRgn);
-        if (hRgn !is 0 && !OS.IsWinCE) {
+        if (hRgn !is null && !OS.IsWinCE) {
             OS.OffsetRgn(hRgn, pt.x, pt.y);
         }
     }
-    if (hRgn !is 0 && hRgn !is clipRgn) {
+    if (hRgn !is null && hRgn !is clipRgn) {
         OS.DeleteObject(hRgn);
     }
 }
@@ -3999,7 +4008,7 @@
  * </ul>
  */
 public void setClipping (int x, int y, int width, int height) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     int hRgn = OS.CreateRectRgn(x, y, x + width, y + height);
     setClipping(hRgn);
     OS.DeleteObject(hRgn);
@@ -4032,7 +4041,7 @@
  * @since 3.1
  */
 public void setClipping (Path path) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (path !is null && path.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     setClipping(0);
     if (path !is null) {
@@ -4057,7 +4066,7 @@
  * </ul>
  */
 public void setClipping (Rectangle rect) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (rect is null) {
         setClipping(0);
     } else {
@@ -4082,7 +4091,7 @@
  * </ul>
  */
 public void setClipping (Region region) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (region !is null && region.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     setClipping(region !is null ? region.handle : 0);
 }
@@ -4104,7 +4113,7 @@
  * @since 3.1
  */
 public void setFillRule(int rule) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (OS.IsWinCE) return;
     int mode = OS.ALTERNATE;
     switch (rule) {
@@ -4132,7 +4141,7 @@
  * </ul>
  */
 public void setFont (Font font) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (font !is null && font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     data.hFont = font !is null ? font.handle : data.device.systemFont;
     data.state &= ~FONT;
@@ -4153,7 +4162,7 @@
  * </ul>
  */
 public void setForeground (Color color) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (color is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     if (color.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
     if (data.foregroundPattern is null && color.handle is data.foreground) return;
@@ -4186,9 +4195,9 @@
  * @since 3.1
  */
 public void setForegroundPattern (Pattern pattern) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (pattern !is null && pattern.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
-    if (data.gdipGraphics is 0 && pattern is null) return;
+    if (data.gdipGraphics is null && pattern is null) return;
     initGdip();
     if (data.foregroundPattern is pattern) return;
     data.foregroundPattern = pattern;
@@ -4222,8 +4231,8 @@
  * @since 3.1
  */
 public void setInterpolation(int interpolation) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    if (data.gdipGraphics is 0 && interpolation is DWT.DEFAULT) return;
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.gdipGraphics is null && interpolation is DWT.DEFAULT) return;
     int mode = 0;
     switch (interpolation) {
         case DWT.DEFAULT: mode = Gdip.InterpolationModeDefault; break;
@@ -4262,7 +4271,7 @@
  * @since 3.3
  */
 public void setLineAttributes(LineAttributes attributes) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (attributes is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
     int mask = 0;
     float lineWidth = attributes.width;
@@ -4371,7 +4380,7 @@
  * @since 3.1
  */
 public void setLineCap(int cap) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (data.lineCap is cap) return;
     switch (cap) {
         case DWT.CAP_ROUND:
@@ -4403,7 +4412,7 @@
  * @since 3.1
  */
 public void setLineDash(int[] dashes) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     float[] lineDashes = data.lineDashes;
     if (dashes !is null && dashes.length > 0) {
         bool changed = data.lineStyle !is DWT.LINE_CUSTOM || lineDashes is null || lineDashes.length !is dashes.length;
@@ -4443,7 +4452,7 @@
  * @since 3.1
  */
 public void setLineJoin(int join) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (data.lineJoin is join) return;
     switch (join) {
         case DWT.JOIN_MITER:
@@ -4473,7 +4482,7 @@
  * </ul>
  */
 public void setLineStyle(int lineStyle) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (data.lineStyle is lineStyle) return;
     switch (lineStyle) {
         case DWT.LINE_SOLID:
@@ -4511,7 +4520,7 @@
  * </ul>
  */
 public void setLineWidth(int lineWidth) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (data.lineWidth is lineWidth) return;
     data.lineWidth = lineWidth;
     data.state &= ~(LINE_WIDTH | DRAW_OFFSET);
@@ -4539,7 +4548,7 @@
  * @deprecated this functionality is not supported on some platforms
  */
 public void setXORMode(bool xor) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     OS.SetROP2(handle, xor ? OS.R2_XORPEN : OS.R2_COPYPEN);
 }
 
@@ -4572,8 +4581,8 @@
  * @since 3.1
  */
 public void setTextAntialias(int antialias) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
-    if (data.gdipGraphics is 0 && antialias is DWT.DEFAULT) return;
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (data.gdipGraphics is null && antialias is DWT.DEFAULT) return;
     int textMode = 0;
     switch (antialias) {
         case DWT.DEFAULT:
@@ -4625,9 +4634,9 @@
  * @since 3.1
  */
 public void setTransform(Transform transform) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (transform !is null && transform.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
-    if (data.gdipGraphics is 0 && transform is null) return;
+    if (data.gdipGraphics is null && transform is null) return;
     initGdip();
     int identity = identity();
     if (transform !is null) {
@@ -4657,20 +4666,20 @@
  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
  * </ul>
  */
-public Point stringExtent(String string) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+public Point stringExtent(char[] string) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
     checkGC(FONT);
-    int length = string.length();
-    if (data.gdipGraphics !is 0) {
+    int length_ = string.length;
+    if (data.gdipGraphics !is null) {
         PointF pt = new PointF();
         RectF bounds = new RectF();
         char[] buffer;
-        if (length !is 0) {
-            buffer = new char [length];
-            string.getChars(0, length, buffer, 0);
+        if (length_ !is 0) {
+            buffer = new char [length_];
+            string.getChars(0, length_, buffer, 0);
         } else {
-            buffer = new char[]{' '};
+            buffer = (" "w).dup;
         }
         int format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic());
         int formatFlags = Gdip.StringFormat_GetFormatFlags(format) | Gdip.StringFormatFlagsMeasureTrailingSpaces;
@@ -4678,18 +4687,18 @@
         Gdip.StringFormat_SetFormatFlags(format, formatFlags);
         Gdip.Graphics_MeasureString(data.gdipGraphics, buffer, buffer.length, data.gdipFont, pt, format, bounds);
         Gdip.StringFormat_delete(format);
-        return new Point(length is 0 ? 0 : Math.round(bounds.Width), Math.round(bounds.Height));
+        return new Point(length_ is 0 ? 0 : Math.round(bounds.Width), Math.round(bounds.Height));
     }
-    SIZE size = new SIZE();
-    if (length is 0) {
+    SIZE size;
+    if (length_ is 0) {
 //      OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size);
-        OS.GetTextExtentPoint32W(handle, new char[]{' '}, 1, size);
+        OS.GetTextExtentPoint32W(handle, (" "w).ptr, 1, &size);
         return new Point(0, size.cy);
     } else {
 //      TCHAR buffer = new TCHAR (getCodePage(), string, false);
-        char[] buffer = new char [length];
-        string.getChars(0, length, buffer, 0);
-        OS.GetTextExtentPoint32W(handle, buffer, length, size);
+        char[] buffer = new char [length_];
+        string.getChars(0, length_, buffer, 0);
+        OS.GetTextExtentPoint32W(handle, buffer, length_, &size);
         return new Point(size.cx, size.cy);
     }
 }
@@ -4713,7 +4722,7 @@
  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
  * </ul>
  */
-public Point textExtent(String string) {
+public Point textExtent(char[] string) {
     return textExtent(string, DWT.DRAW_DELIMITER | DWT.DRAW_TAB);
 }
 
@@ -4748,36 +4757,36 @@
  *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
  * </ul>
  */
-public Point textExtent(String string, int flags) {
-    if (handle is 0) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+public Point textExtent(char[] string, int flags) {
+    if (handle is null) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
     if (string is null) DWT.error (DWT.ERROR_NULL_ARGUMENT);
     checkGC(FONT);
-    if (data.gdipGraphics !is 0) {
+    if (data.gdipGraphics !is null) {
         PointF pt = new PointF();
         RectF bounds = new RectF();
         char[] buffer;
-        int length = string.length();
-        if (length !is 0) {
-            buffer = new char [length];
-            string.getChars(0, length, buffer, 0);
+        int length_ = string.length;
+        if (length_ !is 0) {
+            buffer = new char [length_];
+            string.getChars(0, length_, buffer, 0);
         } else {
-            buffer = new char[]{' '};
+            buffer = (" "w).ptr;
         }
         int format = Gdip.StringFormat_Clone(Gdip.StringFormat_GenericTypographic());
         int formatFlags = Gdip.StringFormat_GetFormatFlags(format) | Gdip.StringFormatFlagsMeasureTrailingSpaces;
         if ((data.style & DWT.MIRRORED) !is 0) formatFlags |= Gdip.StringFormatFlagsDirectionRightToLeft;
         Gdip.StringFormat_SetFormatFlags(format, formatFlags);
-        float[] tabs = (flags & DWT.DRAW_TAB) !is 0 ? new float[]{measureSpace(data.gdipFont, format) * 8} : new float[1];
+        float[] tabs = (flags & DWT.DRAW_TAB) !is 0 ? [measureSpace(data.gdipFont, format) * 8] : new float[1];
         Gdip.StringFormat_SetTabStops(format, 0, tabs.length, tabs);
         Gdip.StringFormat_SetHotkeyPrefix(format, (flags & DWT.DRAW_MNEMONIC) !is 0 ? Gdip.HotkeyPrefixShow : Gdip.HotkeyPrefixNone);
         Gdip.Graphics_MeasureString(data.gdipGraphics, buffer, buffer.length, data.gdipFont, pt, format, bounds);
         Gdip.StringFormat_delete(format);
-        return new Point(length is 0 ? 0 : Math.round(bounds.Width), Math.round(bounds.Height));
+        return new Point(length_ is 0 ? 0 : Math.round(bounds.Width), Math.round(bounds.Height));
     }
-    if (string.length () is 0) {
+    if (string.length is 0) {
         SIZE size = new SIZE();
 //      OS.GetTextExtentPoint32(handle, SPACE, SPACE.length(), size);
-        OS.GetTextExtentPoint32W(handle, new char [] {' '}, 1, size);
+        OS.GetTextExtentPoint32W(handle, (" "w).ptr, 1, size);
         return new Point(0, size.cy);
     }
     RECT rect = new RECT();
@@ -4796,9 +4805,9 @@
  *
  * @return a string representation of the receiver
  */
-public String toString () {
+public char[] toString () {
     if (isDisposed()) return "GC {*DISPOSED*}";
-    return "GC {" + handle + "}";
+    return Format( "GC {{{}}", handle );
 }
 
 /**
@@ -4818,7 +4827,7 @@
  */
 public static GC win32_new(Drawable drawable, GCData data) {
     GC gc = new GC();
-    int hDC = drawable.internal_new_GC(data);
+    auto hDC = drawable.internal_new_GC(data);
     gc.device = data.device;
     gc.init(drawable, data, hDC);
     return gc;
@@ -4839,7 +4848,7 @@
  *
  * @return a new <code>GC</code>
  */
-public static GC win32_new(int hDC, GCData data) {
+public static GC win32_new(HDC hDC, GCData data) {
     GC gc = new GC();
     gc.device = data.device;
     gc.init(null, data, hDC);
@@ -4847,4 +4856,3 @@
 }
 
 }
-++/
\ No newline at end of file
--- a/dwt/graphics/GCData.d	Sun Jan 27 17:43:55 2008 +0100
+++ b/dwt/graphics/GCData.d	Sun Jan 27 20:29:00 2008 +0100
@@ -15,19 +15,11 @@
 
 import dwt.DWT;
 import dwt.internal.win32.WINTYPES;
+import dwt.internal.gdip.Gdip;
 import dwt.graphics.Image;
 import dwt.graphics.Device;
+import dwt.graphics.Pattern;
 
-//PORTING_TYPE
-class GCData {
-    HBITMAP hNullBitmap;
-    int style;
-    int layout;
-    Device device;
-    Image image;
-    HFONT hFont;
-}
-/+++
 /**
  * Instances of this class are descriptions of GCs in terms
  * of unallocated platform-specific data fields.
@@ -44,7 +36,7 @@
     public int style, state = -1;
     public int foreground = -1;
     public int background = -1;
-    public int hFont;
+    public HFONT hFont;
     public Pattern foregroundPattern;
     public Pattern backgroundPattern;
     public int lineStyle = DWT.LINE_SOLID;
@@ -58,18 +50,18 @@
     public int uiState = 0;
 
     public Image image;
-    public int hPen, hOldPen;
-    public int hBrush, hOldBrush;
-    public int hNullBitmap;
-    public int hwnd;
-    public PAINTSTRUCT ps;
+    public HPEN hPen, hOldPen;
+    public HBRUSH hBrush, hOldBrush;
+    public HBITMAP hNullBitmap;
+    public HWND hwnd;
+    public PAINTSTRUCT* ps;
     public int layout = -1;
-    public int gdipGraphics;
-    public int gdipPen;
-    public int gdipBrush;
-    public int gdipFgBrush;
-    public int gdipBgBrush;
-    public int gdipFont;
+    public Gdip.Graphics* gdipGraphics;
+    public Gdip.Pen* gdipPen;
+    public Gdip.Brush* gdipBrush;
+    public Gdip.SolidBrush* gdipFgBrush;
+    public Gdip.SolidBrush* gdipBgBrush;
+    public Gdip.Font* gdipFont;
     public float gdipXOffset, gdipYOffset;
 }
-+++/
+
--- a/dwt/internal/gdip/Gdip.d	Sun Jan 27 17:43:55 2008 +0100
+++ b/dwt/internal/gdip/Gdip.d	Sun Jan 27 20:29:00 2008 +0100
@@ -175,6 +175,10 @@
     public int Width;
     public int Height;
 }
+public struct Point {
+    public int X;
+    public int Y;
+}
 public struct PointF {
     public float X;
     public float Y;
@@ -194,102 +198,193 @@
     public int   Reserved;
 }
 
-struct Matrix{}
 struct Bitmap{}
-struct Image{}
-struct Pen{}
 struct Brush{}
+struct Color{}
 struct Font{}
-struct StringFormat{}
-struct Region{}
+struct FontCollection{}
+struct FontFamily{}
+struct Graphics{}
 struct GraphicsPath{}
-struct Graphics{}
+struct Image{}
 struct ImageAttributes{}
+struct HatchBrush{}
+struct LinearGradientBrush{}
+struct Matrix{}
+struct Pen{}
+struct Region{}
+struct SolidBrush{}
+struct StringFormat{}
+struct TextureBrush{}
+alias extern(Windows) int function(void*) ImageAbort;
+alias ImageAbort DrawImageAbort;
 
     public alias API.GdiplusStartup  GdiplusStartup;
     public alias API.GdiplusShutdown GdiplusShutdown;
 
-    public static extern(Windows) Matrix* Matrix_new(float m11, float m12, float m21, float m22, float dx, float dy);
-    public static extern(Windows) void Matrix_delete(Matrix*);
-    public static extern(Windows) int  Matrix_GetElements(Matrix*,float* m);
-    public static extern(Windows) int  Matrix_Invert(Matrix*);
-    public static extern(Windows) int  Matrix_IsIdentity(Matrix*);
-    public static extern(Windows) int  Matrix_Multiply(Matrix*,Matrix*,int);
-    public static extern(Windows) int  Matrix_Rotate(Matrix*,float,int);
-    public static extern(Windows) int  Matrix_Scale(Matrix*,float,float,int);
-    public static extern(Windows) int  Matrix_SetElements(Matrix*,float m11, float m12, float m21, float m22, float dx, float dy);
-    public static extern(Windows) int  Matrix_TransformPoints(Matrix*,PointF*, int);
-    public static extern(Windows) int  Matrix_Translate(Matrix*,float, float, float);
+    public static extern(Windows) {
+        Matrix* Matrix_new(float m11, float m12, float m21, float m22, float dx, float dy);
+        void Matrix_delete(Matrix*);
+        int  Matrix_GetElements(Matrix*,float* m);
+        int  Matrix_Invert(Matrix*);
+        int  Matrix_IsIdentity(Matrix*);
+        int  Matrix_Multiply(Matrix*,Matrix*,int);
+        int  Matrix_Rotate(Matrix*,float,int);
+        int  Matrix_Scale(Matrix*,float,float,int);
+        int  Matrix_SetElements(Matrix*,float m11, float m12, float m21, float m22, float dx, float dy);
+        int  Matrix_TransformPoints(Matrix*,PointF*, int);
+        int  Matrix_Translate(Matrix*,float, float, float);
+
+        Bitmap* Bitmap_new(HBITMAP hbm, HPALETTE hpal);
+        Bitmap* Bitmap_new(HICON hicon);
+        Bitmap* Bitmap_new(int width, int height, int stride, int format, byte* scan0);
+        Bitmap* Bitmap_new(wchar* filename, int useIcm);
+        void Bitmap_delete(Bitmap* bitmap);
+        // colorBackground is C++ &-reference Color
+        int Bitmap_GetHBITMAP(Bitmap*bitmap, void* colorBackground, HBITMAP* hbmReturn);
+        int Bitmap_GetHICON(Bitmap* bitmap, HICON* hicon);
+        int Bitmap_LockBits(Bitmap* bitmap, Rect* rect, int flags, int pixelFormat, BitmapData* lockedBitmapData);
+        int Bitmap_UnlockBits(Bitmap* bitmap, BitmapData* lockedBitmapData);
+
+        BitmapData* BitmapData_new();
+        void BitmapData_delete(BitmapData* bitmapData);
+
+        int Image_GetLastStatus(Image* image);
+        int Image_GetPixelFormat(Image* image);
+        uint Image_GetWidth(Image* image);
+        uint Image_GetHeight(Image* image);
+        int Image_GetPalette(Image* image, ColorPalette* palette, int size);
+        int Image_GetPaletteSize(Image* image);
 
-    public static extern(Windows) Bitmap* Bitmap_new(HBITMAP hbm, HPALETTE hpal);
-    public static extern(Windows) Bitmap* Bitmap_new(HICON hicon);
-    public static extern(Windows) Bitmap* Bitmap_new(int width, int height, int stride, int format, byte* scan0);
-    public static extern(Windows) Bitmap* Bitmap_new(wchar* filename, int useIcm);
-    public static extern(Windows) void Bitmap_delete(Bitmap* bitmap);
-    // colorBackground is C++ &-reference Color
-    public static extern(Windows) int Bitmap_GetHBITMAP(Bitmap*bitmap, void* colorBackground, HBITMAP* hbmReturn);
-    public static extern(Windows) int Bitmap_GetHICON(Bitmap* bitmap, HICON* hicon);
-    public static extern(Windows) int Bitmap_LockBits(Bitmap* bitmap, Rect* rect, int flags, int pixelFormat, BitmapData* lockedBitmapData);
-    public static extern(Windows) int Bitmap_UnlockBits(Bitmap* bitmap, BitmapData* lockedBitmapData);
-
-    public static extern(Windows) BitmapData* BitmapData_new();
-    public static extern(Windows) void BitmapData_delete(BitmapData* bitmapData);
-
-    public static extern(Windows) int Image_GetLastStatus(Image* image);
-    public static extern(Windows) int Image_GetPixelFormat(Image* image);
-    public static extern(Windows) uint Image_GetWidth(Image* image);
-    public static extern(Windows) uint Image_GetHeight(Image* image);
-    public static extern(Windows) int Image_GetPalette(Image* image, ColorPalette* palette, int size);
-    public static extern(Windows) int Image_GetPaletteSize(Image* image);
+        Graphics* Graphics_new(HDC hdc);
+        void Graphics_delete(Graphics* graphics);
+        int Graphics_DrawArc(Graphics* graphics, Pen* pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
+        int Graphics_DrawEllipse(Graphics* graphics, Pen* pen, int x, int y, int width, int height);
+        int Graphics_DrawImage(Graphics* graphics, Image* image, int x, int y);
+        int Graphics_DrawImage(Graphics* graphics, Image* image, Rect* destRect, int srcx, int srcy, int srcwidth, int srcheight, int srcUnit, ImageAttributes* imageAttributes, DrawImageAbort callback, void* callbackData);
+        int Graphics_DrawLine(Graphics* graphics, Pen* pen, int x1, int y1, int x2, int y2);
+        int Graphics_DrawLines(Graphics* graphics, Pen* pen, PointF* points, int count);
+        int Graphics_DrawPath(Graphics* graphics, Pen* pen, GraphicsPath* path);
+        int Graphics_DrawPolygon(Graphics* graphics, Pen* pen, int[] points, int count);
+        int Graphics_DrawRectangle(Graphics* graphics, Pen* pen, int x, int y, int width, int height);
+        int Graphics_DrawString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, Brush* brush);
+        int Graphics_DrawString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, StringFormat* format, Brush* brush);
+        int Graphics_FillEllipse(Graphics* graphics, Brush* brush, int x, int y, int width, int height);
+        int Graphics_FillPath(Graphics* graphics, Brush* brush, GraphicsPath* path);
+        void Graphics_Flush(Graphics* graphics, int intention);
+        int Graphics_FillPie(Graphics* graphics, Brush* brush, int x, int y, int width, int height, float startAngle, float sweepAngle);
+        int Graphics_FillPolygon(Graphics* graphics, Brush* brush, int[] points, int count, int fillMode);
+        int Graphics_FillRectangle(Graphics* graphics, Brush* brush, int x, int y, int width, int height);
+        int Graphics_GetClipBounds(Graphics* graphics, RectF rect);
+        int Graphics_GetClipBounds(Graphics* graphics, Rect rect);
+        int Graphics_GetClip(Graphics* graphics, Region* region);
+        HDC Graphics_GetHDC(Graphics* graphics);
+        void Graphics_ReleaseHDC(Graphics* graphics, HDC hdc);
+        int Graphics_GetInterpolationMode(Graphics* graphics);
+        int Graphics_GetSmoothingMode(Graphics* graphics);
+        int Graphics_GetTextRenderingHint(Graphics* graphics);
+        int Graphics_GetTransform(Graphics* graphics, Matrix* matrix);
+        int Graphics_GetVisibleClipBounds(Graphics* graphics, Rect rect);
+        int Graphics_MeasureString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, RectF boundingBox);
+        int Graphics_MeasureString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, StringFormat* format, RectF boundingBox);
+        int Graphics_ResetClip(Graphics* graphics);
+        int Graphics_Restore(Graphics* graphics, int gstate);
+        int Graphics_Save(Graphics* graphics);
+        int Graphics_ScaleTransform(Graphics* graphics, float sx, float sy, int order);
+        int Graphics_SetClip(Graphics* graphics, HRGN hrgn, int combineMode);
+        int Graphics_SetClip(Graphics* graphics, GraphicsPath* path);
+        int Graphics_SetClip(Graphics* graphics, Rect rect, int combineMode);
+        int Graphics_SetCompositingQuality(Graphics* graphics, int compositingQuality);
+        int Graphics_SetPageUnit(Graphics* graphics, int unit);
+        int Graphics_SetPixelOffsetMode(Graphics* graphics, int pixelOffsetMode);
+        int Graphics_SetSmoothingMode(Graphics* graphics, int smoothingMode);
+        int Graphics_SetTransform(Graphics* graphics, Matrix* matrix);
+        int Graphics_SetInterpolationMode(Graphics* graphics, int mode);
+        int Graphics_SetTextRenderingHint(Graphics* graphics, int mode);
+        int Graphics_TranslateTransform(Graphics* graphics, float dx, float dy, int order);
 
-alias extern(Windows) int function(void*) ImageAbort;
-alias ImageAbort DrawImageAbort;
-    public static extern(Windows) Graphics* Graphics_new(HDC hdc);
-    public static extern(Windows) void Graphics_delete(Graphics* graphics);
-    public static extern(Windows) int Graphics_DrawArc(Graphics* graphics, Pen* pen, int x, int y, int width, int height, float startAngle, float sweepAngle);
-    public static extern(Windows) int Graphics_DrawEllipse(Graphics* graphics, Pen* pen, int x, int y, int width, int height);
-    public static extern(Windows) int Graphics_DrawImage(Graphics* graphics, Image* image, int x, int y);
-    public static extern(Windows) int Graphics_DrawImage(Graphics* graphics, Image* image, Rect* destRect, int srcx, int srcy, int srcwidth, int srcheight, int srcUnit, ImageAttributes* imageAttributes, DrawImageAbort callback, void* callbackData);
-    public static extern(Windows) int Graphics_DrawLine(Graphics* graphics, Pen* pen, int x1, int y1, int x2, int y2);
-    public static extern(Windows) int Graphics_DrawLines(Graphics* graphics, Pen* pen, PointF* points, int count);
-    public static extern(Windows) int Graphics_DrawPath(Graphics* graphics, Pen* pen, GraphicsPath* path);
-    public static extern(Windows) int Graphics_DrawPolygon(Graphics* graphics, Pen* pen, int[] points, int count);
-    public static extern(Windows) int Graphics_DrawRectangle(Graphics* graphics, Pen* pen, int x, int y, int width, int height);
-    public static extern(Windows) int Graphics_DrawString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, Brush* brush);
-    public static extern(Windows) int Graphics_DrawString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, StringFormat* format, Brush* brush);
-    public static extern(Windows) int Graphics_FillEllipse(Graphics* graphics, Brush* brush, int x, int y, int width, int height);
-    public static extern(Windows) int Graphics_FillPath(Graphics* graphics, Brush* brush, GraphicsPath* path);
-    public static extern(Windows) void Graphics_Flush(Graphics* graphics, int intention);
-    public static extern(Windows) int Graphics_FillPie(Graphics* graphics, Brush* brush, int x, int y, int width, int height, float startAngle, float sweepAngle);
-    public static extern(Windows) int Graphics_FillPolygon(Graphics* graphics, Brush* brush, int[] points, int count, int fillMode);
-    public static extern(Windows) int Graphics_FillRectangle(Graphics* graphics, Brush* brush, int x, int y, int width, int height);
-    public static extern(Windows) int Graphics_GetClipBounds(Graphics* graphics, RectF rect);
-    public static extern(Windows) int Graphics_GetClipBounds(Graphics* graphics, Rect rect);
-    public static extern(Windows) int Graphics_GetClip(Graphics* graphics, Region* region);
-    public static extern(Windows) HDC Graphics_GetHDC(Graphics* graphics);
-    public static extern(Windows) void Graphics_ReleaseHDC(Graphics* graphics, HDC hdc);
-    public static extern(Windows) int Graphics_GetInterpolationMode(Graphics* graphics);
-    public static extern(Windows) int Graphics_GetSmoothingMode(Graphics* graphics);
-    public static extern(Windows) int Graphics_GetTextRenderingHint(Graphics* graphics);
-    public static extern(Windows) int Graphics_GetTransform(Graphics* graphics, Matrix* matrix);
-    public static extern(Windows) int Graphics_GetVisibleClipBounds(Graphics* graphics, Rect rect);
-    public static extern(Windows) int Graphics_MeasureString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, RectF boundingBox);
-    public static extern(Windows) int Graphics_MeasureString(Graphics* graphics, wchar* string, int length, Font* font, PointF origin, StringFormat* format, RectF boundingBox);
-    public static extern(Windows) int Graphics_ResetClip(Graphics* graphics);
-    public static extern(Windows) int Graphics_Restore(Graphics* graphics, int gstate);
-    public static extern(Windows) int Graphics_Save(Graphics* graphics);
-    public static extern(Windows) int Graphics_ScaleTransform(Graphics* graphics, float sx, float sy, int order);
-    public static extern(Windows) int Graphics_SetClip(Graphics* graphics, HRGN hrgn, int combineMode);
-    public static extern(Windows) int Graphics_SetClip(Graphics* graphics, GraphicsPath* path);
-    public static extern(Windows) int Graphics_SetClip(Graphics* graphics, Rect rect, int combineMode);
-    public static extern(Windows) int Graphics_SetCompositingQuality(Graphics* graphics, int compositingQuality);
-    public static extern(Windows) int Graphics_SetPageUnit(Graphics* graphics, int unit);
-    public static extern(Windows) int Graphics_SetPixelOffsetMode(Graphics* graphics, int pixelOffsetMode);
-    public static extern(Windows) int Graphics_SetSmoothingMode(Graphics* graphics, int smoothingMode);
-    public static extern(Windows) int Graphics_SetTransform(Graphics* graphics, Matrix* matrix);
-    public static extern(Windows) int Graphics_SetInterpolationMode(Graphics* graphics, int mode);
-    public static extern(Windows) int Graphics_SetTextRenderingHint(Graphics* graphics, int mode);
-    public static extern(Windows) int Graphics_TranslateTransform(Graphics* graphics, float dx, float dy, int order);
+        SolidBrush* SolidBrush_new(Color* color);
+        void SolidBrush_delete(SolidBrush* brush);
+
+        Brush* Brush_Clone(Brush* brush);
+        int Brush_GetType(Brush* brush);
+
+        TextureBrush* TextureBrush_new(Image* image, int wrapMode, float dstX, float dstY, float dstWidth, float dstHeight);
+        void TextureBrush_delete(TextureBrush* brush);
+        int TextureBrush_SetTransform(TextureBrush* brush, Matrix* matrix);
+        int TextureBrush_ResetTransform(TextureBrush* brush);
+        int TextureBrush_ScaleTransform(TextureBrush* brush, float sx, float sy, int order);
+        int TextureBrush_TranslateTransform(TextureBrush* brush, float dx, float dy, int order);
+
+        Color* Color_new(int argb);
+        void Color_delete(Color* color);
+
+
+        Pen* Pen_new(Brush* brush, float width);
+        void Pen_delete(Pen* pen);
+        Brush* Pen_GetBrush(Pen* pen);
+        int Pen_SetBrush(Pen* pen, Brush* brush);
+        int Pen_SetDashOffset(Pen* pen, float dashOffset);
+        int Pen_SetDashPattern(Pen* pen, float* dashArray, int count);
+        int Pen_SetDashStyle(Pen* pen, int dashStyle);
+        int Pen_SetLineCap(Pen* pen, int startCap, int endCap, int dashCap);
+        int Pen_SetLineJoin(Pen* pen, int lineJoin);
+        int Pen_SetMiterLimit(Pen* pen, float miterLimit);
+        int Pen_SetWidth(Pen* pen, float width);
+
+        Font* Font_new(HDC hdc, HFONT hfont);
+        Font* Font_new(wchar* familyName, float emSize, int style, int unit, FontCollection* fontCollection);
+        void Font_delete(Font* font);
+        int Font_GetFamily(Font* font, FontFamily* family);
+        float Font_GetSize(Font* font);
+        int Font_GetStyle(Font* font);
+        bool Font_IsAvailable(Font* font);
+
+
+        void HatchBrush_delete(HatchBrush* brush);
+
+        LinearGradientBrush* LinearGradientBrush_new(PointF point1, PointF point2, Color* color1, Color* color2);
+        void LinearGradientBrush_delete(LinearGradientBrush* brush);
+        int LinearGradientBrush_SetInterpolationColors(LinearGradientBrush* brush, Color* presetColors, float* blendPositions, int count);
+        int LinearGradientBrush_SetWrapMode(LinearGradientBrush* brush, int wrapMode);
+        int LinearGradientBrush_ResetTransform(LinearGradientBrush* brush);
+        int LinearGradientBrush_ScaleTransform(LinearGradientBrush* brush, float sx, float sy, int order);
+        int LinearGradientBrush_TranslateTransform(LinearGradientBrush* brush, float dx, float dy, int order);
+
+        GraphicsPath* GraphicsPath_new(int fillMode);
+        GraphicsPath* GraphicsPath_new(Point* points, byte* types, int count, int fillMode);
+        void GraphicsPath_delete(GraphicsPath* path);
+        int GraphicsPath_AddArc(GraphicsPath* path, float x, float y, float width, float height, float startAngle, float sweepAngle);
+        int GraphicsPath_AddBezier(GraphicsPath* path, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
+        int GraphicsPath_AddLine(GraphicsPath* path, float x1, float y1, float x2, float y2);
+        int GraphicsPath_AddPath(GraphicsPath* path, GraphicsPath* addingPath, bool connect);
+        int GraphicsPath_AddRectangle(GraphicsPath* path, RectF* rect);
+        int GraphicsPath_AddString(GraphicsPath* path, wchar* string, int length, FontFamily* family, int style, float emSize, PointF origin, StringFormat* format);
+        int GraphicsPath_CloseFigure(GraphicsPath* path);
+        int GraphicsPath_Flatten(GraphicsPath* path, Matrix* matrix, float flatness);
+        int GraphicsPath_GetBounds(GraphicsPath* path, RectF bounds, Matrix* matrix, Pen* pen);
+        int GraphicsPath_GetLastPoint(GraphicsPath* path, PointF lastPoint);
+        int GraphicsPath_GetPathPoints(GraphicsPath* path, float* points, int count);
+        int GraphicsPath_GetPathTypes(GraphicsPath* path, byte[] types, int count);
+        int GraphicsPath_GetPointCount(GraphicsPath* path);
+        bool GraphicsPath_IsOutlineVisible(GraphicsPath* path, float x, float y, Pen* pen, Graphics* g);
+        bool GraphicsPath_IsVisible(GraphicsPath* path, float x, float y, Graphics* g);
+        int GraphicsPath_SetFillMode(GraphicsPath* path, int fillmode);
+        int GraphicsPath_StartFigure(GraphicsPath* path);
+        int GraphicsPath_Transform(GraphicsPath* path, Matrix* matrix);
+
+        Region* Region_new(HRGN hRgn);
+        Region* Region_new();
+        void Region_delete(Region* region);
+        HRGN Region_GetHRGN(Region* region, Graphics* graphics);
+        bool Region_IsInfinite(Region* region, Graphics* graphics);
+
+        ImageAttributes* ImageAttributes_new();
+        void ImageAttributes_delete(ImageAttributes* attrib);
+        int ImageAttributes_SetWrapMode(ImageAttributes* attrib, int wrap);
+        int ImageAttributes_SetColorMatrix(ImageAttributes* attrib, float* matrix, int mode, int type);
+    }
+
 
 
 /++
--- a/dwt/internal/win32/OS.d	Sun Jan 27 17:43:55 2008 +0100
+++ b/dwt/internal/win32/OS.d	Sun Jan 27 20:29:00 2008 +0100
@@ -4008,6 +4008,7 @@
 alias WINAPI.AbortDoc AbortDoc;
 alias WINAPI.ActivateKeyboardLayout ActivateKeyboardLayout;
 alias WINAPI.AdjustWindowRectEx AdjustWindowRectEx;
+alias WINAPI.AlphaBlend AlphaBlend;
 alias WINAPI.Arc Arc;
 alias WINAPI.BeginDeferWindowPos BeginDeferWindowPos;
 alias WINAPI.BeginPaint BeginPaint;
@@ -4125,6 +4126,8 @@
 alias WINAPI.ExtTextOutW ExtTextOutW;
 alias WINAPI.ExtractIconExA ExtractIconExA;
 alias WINAPI.ExtractIconExW ExtractIconExW;
+alias STDWIN.ExtCreatePen ExtCreatePen;
+alias STDWIN.ExtCreateRegion ExtCreateRegion;
 alias WINAPI.FillRect FillRect;
 alias WINAPI.FindResourceA FindResourceA;
 alias WINAPI.FindResourceW FindResourceW;
@@ -4239,6 +4242,7 @@
 alias WINAPI.GetVersionExA GetVersionExA;
 alias WINAPI.GetVersionExW GetVersionExW;
 alias WINAPI.GetWindow GetWindow;
+alias STDWIN.GetWindowOrgEx GetWindowOrgEx;
 alias WINAPI.GetWindowLongA GetWindowLongA;
 alias WINAPI.GetWindowLongW GetWindowLongW;
 alias WINAPI.GetWindowPlacement GetWindowPlacement;
@@ -4428,6 +4432,7 @@
 alias WINAPI.SetEvent SetEvent;
 alias WINAPI.SetFocus SetFocus;
 alias WINAPI.SetForegroundWindow SetForegroundWindow;
+alias STDWIN.SetGraphicsMode SetGraphicsMode;
 alias WINAPI.SetLastError SetLastError;
 alias WINAPI.SetLayout SetLayout;
 alias WINAPI.SetMenu SetMenu;
@@ -4448,9 +4453,11 @@
 alias WINAPI.SetTimer SetTimer;
 alias WINAPI.SetWindowLongA SetWindowLongA;
 alias WINAPI.SetWindowLongW SetWindowLongW;
+alias STDWIN.SetWindowOrgEx SetWindowOrgEx;
 alias WINAPI.SetWindowPlacement SetWindowPlacement;
 alias WINAPI.SetWindowPos SetWindowPos;
 alias WINAPI.SetWindowRgn SetWindowRgn;
+alias STDWIN.SetWorldTransform SetWorldTransform;
 alias WINAPI.SetWindowTextA SetWindowTextA;
 alias WINAPI.SetWindowTextW SetWindowTextW;
 alias WINAPI.SetWindowsHookExA SetWindowsHookExA;
--- a/dwt/internal/win32/WINAPI.d	Sun Jan 27 17:43:55 2008 +0100
+++ b/dwt/internal/win32/WINAPI.d	Sun Jan 27 20:29:00 2008 +0100
@@ -14,6 +14,19 @@
 int AddFontResourceExA(char* lpszFilename, int fl, void* pdv);
 int AddFontResourceExW(wchar* lpszFilename, int fl, void* pdv);
 
+BOOL AlphaBlend(
+  HDC hdcDest,                 // handle to destination DC
+  int nXOriginDest,            // x-coord of upper-left corner
+  int nYOriginDest,            // y-coord of upper-left corner
+  int nWidthDest,              // destination width
+  int nHeightDest,             // destination height
+  HDC hdcSrc,                  // handle to source DC
+  int nXOriginSrc,             // x-coord of upper-left corner
+  int nYOriginSrc,             // y-coord of upper-left corner
+  int nWidthSrc,               // source width
+  int nHeightSrc,              // source height
+  BLENDFUNCTION blendFunction  // alpha-blending function
+);
 }
 
 
--- a/dwt/internal/win32/WINTYPES.d	Sun Jan 27 17:43:55 2008 +0100
+++ b/dwt/internal/win32/WINTYPES.d	Sun Jan 27 20:29:00 2008 +0100
@@ -719,11 +719,11 @@
 alias LARGE_INTEGER * PLARGE_INTEGER;
 
 
-struct LOGBRUSH {
-  UINT     lbStyle;
-  COLORREF lbColor;
-  LONG     lbHatch;
-}
+// struct LOGBRUSH {
+//   UINT     lbStyle;
+//   COLORREF lbColor;
+//   LONG     lbHatch;
+// }
 
 /+struct LOGFONTA {
   int lfHeight;