changeset 15:1bea9f0c6f63

FontData, Font
author Frank Benoit <benoit@tionex.de>
date Fri, 25 Jan 2008 19:16:45 +0100
parents d3cfc7ee5c52
children 0bee9065699b
files .hgignore dwt/dwthelper/Float.d dwt/dwthelper/Integer.d dwt/dwthelper/utils.d dwt/graphics/Device.d dwt/graphics/Font.d dwt/graphics/FontData.d dwt/internal/win32/OS.d dwt/internal/win32/WINAPI.d
diffstat 9 files changed, 2242 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Fri Jan 25 14:23:28 2008 +0100
+++ b/.hgignore	Fri Jan 25 19:16:45 2008 +0100
@@ -1,7 +1,7 @@
 syntax: glob
 
 *.obj
-*.a
+*.lib
 *.swp
 *.proto
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/dwthelper/Float.d	Fri Jan 25 19:16:45 2008 +0100
@@ -0,0 +1,149 @@
+module dwt.dwthelper.Float;
+
+import dwt.dwthelper.utils;
+static import tango.text.convert.Float;
+import tango.core.Exception;
+
+public final class Float {
+
+    public static float POSITIVE_INFINITY = (1.0f / 0.0f);
+    public static float NEGATIVE_INFINITY = ((-1.0f) / 0.0f);
+    public static float NaN = (0.0f / 0.0f);
+    public static float MAX_VALUE = 3.4028235e+38f;
+    public static float MIN_VALUE = 1.4e-45f;
+    public static int SIZE = 32;
+    public this ( float value ){
+        implMissing( __FILE__, __LINE__ );
+    }
+
+    public this ( double value ){
+        implMissing( __FILE__, __LINE__ );
+    }
+
+    public this ( char[] s ){
+        implMissing( __FILE__, __LINE__ );
+    }
+
+    public static char[] toString( float f ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+
+    public static char[] toHexString( float f ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+
+    public static Float valueOf( char[] s ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+
+    public static Float valueOf( float f ){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+
+    public static float parseFloat( char[] s ){
+        try{
+            return tango.text.convert.Float.toFloat( s );
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
+    }
+
+    public static bool isNaN( float v ){
+        implMissing( __FILE__, __LINE__ );
+        return false;
+    }
+
+    public static bool isInfinite( float v ){
+        implMissing( __FILE__, __LINE__ );
+        return false;
+    }
+
+    public bool isNaN(){
+        implMissing( __FILE__, __LINE__ );
+        return false;
+    }
+
+    public bool isInfinite(){
+        implMissing( __FILE__, __LINE__ );
+        return false;
+    }
+
+    public char[] toString(){
+        implMissing( __FILE__, __LINE__ );
+        return null;
+    }
+
+    public byte byteValue(){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+
+    public short shortValue(){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+
+    public int intValue(){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+
+    public long longValue(){
+        implMissing( __FILE__, __LINE__ );
+        return 0L;
+    }
+
+    public float floatValue(){
+        implMissing( __FILE__, __LINE__ );
+        return 0.0f;
+    }
+
+    public double doubleValue(){
+        implMissing( __FILE__, __LINE__ );
+        return 0.0;
+    }
+
+    public hash_t toHash(){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+
+    public int opEquals( Object obj ){
+        implMissing( __FILE__, __LINE__ );
+        return false;
+    }
+
+    public static int floatToIntBits( float value ){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+
+    public static int floatToRawIntBits( float value ){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+
+    public static float intBitsToFloat( int bits ){
+        implMissing( __FILE__, __LINE__ );
+        return 0.0f;
+    }
+
+    public int compareTo( Object anotherByte ){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+
+    public static int compare( float f1, float f2 ){
+        implMissing( __FILE__, __LINE__ );
+        return 0;
+    }
+
+
+}
+
+
--- a/dwt/dwthelper/Integer.d	Fri Jan 25 14:23:28 2008 +0100
+++ b/dwt/dwthelper/Integer.d	Fri Jan 25 19:16:45 2008 +0100
@@ -1,4 +1,4 @@
-/**
+/**
  * Authors: Frank Benoit <keinfarbton@googlemail.com>
  */
 
@@ -7,7 +7,22 @@
 import dwt.dwthelper.utils;
 
 static import tango.text.convert.Integer;
+private import tango.core.Exception;
 
+public final class Byte {
+    public static byte parseByte( char[] s ){
+        try{
+            int res = tango.text.convert.Integer.parse( s );
+            if( res < byte.min || res > byte.max ){
+                throw new NumberFormatException( "out of range" );
+            }
+            return res;
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
+    }
+}
 public final class Integer {
 
     public static int MIN_VALUE = 0x80000000;
@@ -55,11 +70,21 @@
     }
 
     public static int parseInt( char[] s, int radix ){
-        return tango.text.convert.Integer.parse( s, cast(uint)radix );
+        try{
+            return tango.text.convert.Integer.parse( s, cast(uint)radix );
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
     }
 
     public static int parseInt( char[] s ){
-        return tango.text.convert.Integer.parse( s );
+        try{
+            return tango.text.convert.Integer.parse( s );
+        }
+        catch( IllegalArgumentException e ){
+            throw new NumberFormatException( e );
+        }
     }
 
     public static Integer valueOf( char[] s, int radix ){
--- a/dwt/dwthelper/utils.d	Fri Jan 25 14:23:28 2008 +0100
+++ b/dwt/dwthelper/utils.d	Fri Jan 25 19:16:45 2008 +0100
@@ -1,12 +1,17 @@
-/**
+/**
  * Authors: Frank Benoit <keinfarbton@googlemail.com>
  */
 module dwt.dwthelper.utils;
 
 public import dwt.dwthelper.System;
+public import Math = tango.math.Math;
 
 import tango.io.Stdout;
+import tango.stdc.stringz;
+import tango.text.Util;
 import tango.text.Unicode;
+import tango.text.convert.Utf;
+import tango.core.Exception;
 import tango.stdc.stdlib : exit;
 
 void implMissing( char[] file, uint line ){
@@ -45,3 +50,66 @@
     return r[0];
 }
 
+public int indexOf( char[] str, char searched ){
+    int res = tango.text.Util.locate( str, searched );
+    if( res is str.length ) res = -1;
+    return res;
+}
+
+public int indexOf( char[] str, char searched, int startpos ){
+    int res = tango.text.Util.locate( str, searched, startpos );
+    if( res is str.length ) res = -1;
+    return res;
+}
+
+public int indexOf(char[] str, char[] ch, int start){
+    int res = tango.text.Util.locatePattern( str, ch, start );
+    if( res is str.length ) res = -1;
+    return res;
+}
+
+public char[] substring( char[] str, int start ){
+    return str[ start .. $ ].dup;
+}
+
+public char[] substring( char[] str, int start, int end ){
+    return str[ start .. end ].dup;
+}
+
+public wchar[] substring( wchar[] str, int start ){
+    return str[ start .. $ ].dup;
+}
+
+public wchar[] substring( wchar[] str, int start, int end ){
+    return str[ start .. end ].dup;
+}
+
+public char charAt( char[] str, int pos ){
+    return str[ pos ];
+}
+
+static char[] toHex(uint value, bool prefix = true, int radix = 8){
+    return tango.text.convert.Integer.toString( 
+            value, 
+            radix is 10 ? tango.text.convert.Integer.Style.Signed :
+            radix is  8 ? tango.text.convert.Integer.Style.Octal  :
+            radix is 16 ? tango.text.convert.Integer.Style.Hex    :
+                          tango.text.convert.Integer.Style.Signed,
+            prefix ? tango.text.convert.Integer.Flags.Prefix : tango.text.convert.Integer.Flags.None
+            );
+}
+
+class NumberFormatException : IllegalArgumentException {
+    this( char[] e ){
+        super(e);
+    }
+    this( TracedException e ){
+        super(e.toString);
+    }
+}
+
+
+
+
+
+
--- a/dwt/graphics/Device.d	Fri Jan 25 14:23:28 2008 +0100
+++ b/dwt/graphics/Device.d	Fri Jan 25 19:16:45 2008 +0100
@@ -11,7 +11,15 @@
 module dwt.graphics.Device;
 
 //PORTING_TYPE
+import dwt.internal.win32.OS;
 class Device{
+    static Device getDevice();
+    void new_Object (Object object);
+    bool tracking;
+    public bool isDisposed () ;
+    void dispose_Object (Object object) ;
+    float computePoints(LOGFONT* logFont, HFONT hFont);
+    int computePixels(float height) ;
 }
 /+++
  
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/Font.d	Fri Jan 25 19:16:45 2008 +0100
@@ -0,0 +1,281 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+module dwt.graphics.Font;
+
+
+import dwt.DWT;
+import dwt.DWTError;
+import dwt.DWTException;
+import dwt.internal.win32.OS;
+
+import dwt.graphics.Resource;
+import dwt.graphics.FontData;
+import dwt.graphics.Device; 
+
+import tango.text.convert.Format;
+//import tango.stdc.stringz; 
+
+/**
+ * Instances of this class manage operating system resources that
+ * define how text looks when it is displayed. Fonts may be constructed
+ * by providing a device and either name, size and style information
+ * or a <code>FontData</code> object which encapsulates this data.
+ * <p>
+ * Application code must explicitly invoke the <code>Font.dispose()</code> 
+ * method to release the operating system resources managed by each instance
+ * when those instances are no longer required.
+ * </p>
+ *
+ * @see FontData
+ */
+
+public final class Font : Resource {
+    
+    /**
+     * the handle to the OS font resource
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public HFONT handle;
+    
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+this() {
+}
+
+/**  
+ * Constructs a new font given a device and font data
+ * which describes the desired font's appearance.
+ * <p>
+ * You must dispose the font when it is no longer required. 
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fd the FontData that describes the desired font (must not be null)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the fd argument is null</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ */
+public this(Device device, FontData fd) {
+    if (device is null) device = Device.getDevice();
+    if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    init(device, fd);
+    if (device.tracking) device.new_Object(this);   
+}
+
+/**  
+ * Constructs a new font given a device and an array
+ * of font data which describes the desired font's
+ * appearance.
+ * <p>
+ * You must dispose the font when it is no longer required. 
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param fds the array of FontData that describes the desired font (must not be null)
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the fds argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the length of fds is zero</li>
+ *    <li>ERROR_NULL_ARGUMENT - if any fd in the array is null</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a font could not be created from the given font data</li>
+ * </ul>
+ * 
+ * @since 2.1
+ */
+public this(Device device, FontData[] fds) {
+    if (device is null) device = Device.getDevice();
+    if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (fds is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (fds.length is 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    for (int i=0; i<fds.length; i++) {
+        if (fds[i] is null) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    init(device, fds[0]);
+    if (device.tracking) device.new_Object(this);   
+}
+
+/**  
+ * Constructs a new font given a device, a font name,
+ * the height of the desired font in points, and a font
+ * style.
+ * <p>
+ * You must dispose the font when it is no longer required. 
+ * </p>
+ *
+ * @param device the device to create the font on
+ * @param name the name of the font (must not be null)
+ * @param height the font height in points
+ * @param style a bit or combination of NORMAL, BOLD, ITALIC
+ * 
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if device is null and there is no current device</li>
+ *    <li>ERROR_NULL_ARGUMENT - if the name argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ * @exception DWTError <ul>
+ *    <li>ERROR_NO_HANDLES - if a font could not be created from the given arguments</li>
+ * </ul>
+ */
+public this(Device device, char[] name, int height, int style) {
+    if (device is null) device = Device.getDevice();
+    if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    init(device, new FontData (name, height, style));
+    if (device.tracking) device.new_Object(this);   
+}
+
+/*public*/ this(Device device, char[] name, float height, int style) {
+    if (device is null) device = Device.getDevice();
+    if (device is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    init(device, new FontData (name, height, style));
+    if (device.tracking) device.new_Object(this);   
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the font. Applications must dispose of all fonts which
+ * they allocate.
+ */
+public void dispose() {
+    if (handle is null) return;
+    if (device.isDisposed()) return;
+    OS.DeleteObject(handle);
+    handle = null;
+    if (device.tracking) device.dispose_Object(this);
+    device = null;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public int opEquals(Object object) {
+    if (object is this) return true;
+    if ( auto font = cast(Font)object ){
+        return device is font.device && handle is font.handle;
+    }
+    return false;
+}
+
+/**
+ * Returns an array of <code>FontData</code>s representing the receiver.
+ * On Windows, only one FontData will be returned per font. On X however, 
+ * a <code>Font</code> object <em>may</em> be composed of multiple X 
+ * fonts. To support this case, we return an array of font data objects.
+ *
+ * @return an array of font data objects describing the receiver
+ *
+ * @exception DWTException <ul>
+ *    <li>ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public FontData[] getFontData() {
+    if (isDisposed()) DWT.error(DWT.ERROR_GRAPHIC_DISPOSED);
+    LOGFONT* logFont = new LOGFONT();;
+    OS.GetObject(handle, LOGFONT.sizeof, logFont);
+    return [ cast(FontData) FontData.win32_new(logFont, device.computePoints(logFont, handle))];
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public hash_t toHash () {
+    return cast(hash_t)handle;
+}
+
+void init (Device device, FontData fd) {
+    if (fd is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    this.device = device;
+    LOGFONT* logFont = &fd.data;
+    int lfHeight = logFont.lfHeight;
+    logFont.lfHeight = device.computePixels(fd.height);
+    handle = OS.CreateFontIndirect(logFont);
+    logFont.lfHeight = lfHeight;
+    if (handle is null) DWT.error(DWT.ERROR_NO_HANDLES);
+}
+
+/**
+ * Returns <code>true</code> if the font has been disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * This method gets the dispose state for the font.
+ * When a font has been disposed, it is an error to
+ * invoke any other method using the font.
+ *
+ * @return <code>true</code> when the font is disposed and <code>false</code> otherwise
+ */
+public bool isDisposed() {
+    return handle is null;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public char[] toString () {
+    if (isDisposed()) return "Font {*DISPOSED*}";
+    return Format( "Font {{{}}", handle );
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new font.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Font</code>. It is marked public only so that it
+ * can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param device the device on which to allocate the color
+ * @param handle the handle for the font
+ * @return a new font object containing the specified device and handle
+ */
+public static Font win32_new(Device device, HFONT handle) {
+    if (device is null) device = Device.getDevice();
+    Font font = new Font();
+    font.handle = handle;
+    font.device = device;
+    return font;
+}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dwt/graphics/FontData.d	Fri Jan 25 19:16:45 2008 +0100
@@ -0,0 +1,656 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+module dwt.graphics.FontData;
+
+
+import dwt.DWT;
+//import dwt.internal.Callback;
+//import dwt.internal.win32.LOGFONT;
+//import dwt.internal.win32.LOGFONTA;
+//import dwt.internal.win32.LOGFONTW;
+import dwt.internal.win32.OS;
+//import dwt.internal.win32.TCHAR;
+
+import dwt.dwthelper.utils;
+import dwt.dwthelper.Float;
+import dwt.dwthelper.Integer;
+static import tango.text.Text;
+import tango.util.Convert;
+alias tango.text.Text.Text!(char) StringBuffer;
+
+/**
+ * Instances of this class describe operating system fonts.
+ * <p>
+ * For platform-independent behaviour, use the get and set methods
+ * corresponding to the following properties:
+ * <dl>
+ * <dt>height</dt><dd>the height of the font in points</dd>
+ * <dt>name</dt><dd>the face name of the font, which may include the foundry</dd>
+ * <dt>style</dt><dd>A bitwise combination of NORMAL, ITALIC and BOLD</dd>
+ * </dl>
+ * If extra, platform-dependent functionality is required:
+ * <ul>
+ * <li>On <em>Windows</em>, the data member of the <code>FontData</code>
+ * corresponds to a Windows <code>LOGFONT</code> structure whose fields
+ * may be retrieved and modified.</li>
+ * <li>On <em>X</em>, the fields of the <code>FontData</code> correspond
+ * to the entries in the font's XLFD name and may be retrieved and modified.
+ * </ul>
+ * Application code does <em>not</em> need to explicitly release the
+ * resources managed by each instance when those instances are no longer
+ * required, and thus no <code>dispose()</code> method is provided.
+ *
+ * @see Font
+ */
+
+public final class FontData {
+    
+    /**
+     * A Win32 LOGFONT struct
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public LOGFONT data;
+    
+    /**
+     * The height of the font data in points
+     * (Warning: This field is platform dependent)
+     * <p>
+     * <b>IMPORTANT:</b> This field is <em>not</em> part of the DWT
+     * public API. It is marked public only so that it can be shared
+     * within the packages provided by DWT. It is not available on all
+     * platforms and should never be accessed from application code.
+     * </p>
+     */
+    public float height;
+
+    /**
+     * The locales of the font
+     */
+    char[] lang, country, variant;
+
+    private static FontData s_this;
+
+/**  
+ * Constructs a new uninitialized font data.
+ */
+public this() {
+    // We set the charset field so that
+    // wildcard searching will work properly
+    // out of the box
+    data.lfCharSet = cast(byte)OS.DEFAULT_CHARSET;
+    height = 12;
+}
+
+/**
+ * Constructs a new font data given the Windows <code>LOGFONT</code>
+ * that it should represent.
+ * 
+ * @param data the <code>LOGFONT</code> for the result
+ */
+this(LOGFONT* data, float height) {
+    this.data = *data;
+    this.height = height;
+}
+
+/**
+ * Constructs a new FontData given a string representation
+ * in the form generated by the <code>FontData.toString</code>
+ * method.
+ * <p>
+ * Note that the representation varies between platforms,
+ * and a FontData can only be created from a string that was 
+ * generated on the same platform.
+ * </p>
+ *
+ * @param string the string representation of a <code>FontData</code> (must not be null)
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - if the argument is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the argument does not represent a valid description</li>
+ * </ul>
+ *
+ * @see #toString
+ */
+public this(char[] string) {
+    if (string is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    int start = 0;
+    int end = string.indexOf('|');
+    if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    char[] version1 = string.substring(start, end);
+    try {
+        if (Integer.parseInt(version1) !is 1) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 
+    } catch (NumberFormatException e) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    
+    start = end + 1;
+    end = string.indexOf('|', start);
+    if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    char[] name = string.substring(start, end);
+    
+    start = end + 1;
+    end = string.indexOf('|', start);
+    if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    float height = 0;
+    try {
+        height = Float.parseFloat(string.substring(start, end));
+    } catch (NumberFormatException e) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+    
+    start = end + 1;
+    end = string.indexOf('|', start);
+    if (end is -1) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    int style = 0;
+    try {
+        style = Integer.parseInt(string.substring(start, end));
+    } catch (NumberFormatException e) {
+        DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    }
+
+    start = end + 1;
+    end = string.indexOf('|', start);
+    //data = OS.IsUnicode ? cast(LOGFONT)new LOGFONTW() : new LOGFONTA();
+    data.lfCharSet = cast(byte)OS.DEFAULT_CHARSET;
+    setName(name);
+    setHeight(height);
+    setStyle(style);
+    if (end is -1) return;
+    char[] platform = string.substring(start, end);
+
+    start = end + 1;
+    end = string.indexOf('|', start);
+    if (end is -1) return;
+    char[] version2 = string.substring(start, end);
+
+    if (platform ==/*eq*/ "WINDOWS" && version2 ==/*eq*/ "1") {  //$NON-NLS-1$//$NON-NLS-2$
+        LOGFONT newData;// = OS.IsUnicode ? cast(LOGFONT)new LOGFONTW() : new LOGFONTA();
+        try {
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfHeight = Integer.parseInt(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfWidth = Integer.parseInt(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfEscapement = Integer.parseInt(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfOrientation = Integer.parseInt(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfWeight = Integer.parseInt(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfItalic = Byte.parseByte(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfUnderline = Byte.parseByte(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfStrikeOut = Byte.parseByte(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfCharSet = Byte.parseByte(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfOutPrecision = Byte.parseByte(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfClipPrecision = Byte.parseByte(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfQuality = Byte.parseByte(string.substring(start, end));
+            start = end + 1;
+            end = string.indexOf('|', start);
+            if (end is -1) return;
+            newData.lfPitchAndFamily = Byte.parseByte(string.substring(start, end));
+            start = end + 1;
+        } catch (NumberFormatException e) {
+            setName(name);
+            setHeight(height);
+            setStyle(style);
+            return;
+        }
+        char[] buffer = string.substring(start);
+        int len = Math.min(OS.LF_FACESIZE - 1, buffer.length);
+        newData.lfFaceName[ 0 .. len ] = .StrToTCHARs(buffer)[ 0 .. len ];
+        data = newData;
+    }
+}
+
+/**  
+ * Constructs a new font data given a font name,
+ * the height of the desired font in points, 
+ * and a font style.
+ *
+ * @param name the name of the font (must not be null)
+ * @param height the font height in points
+ * @param style a bit or combination of NORMAL, BOLD, ITALIC
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - when the font name is null</li>
+ *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ */
+public this(char[] name, int height, int style) {
+    if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    setName(name);
+    setHeight(height);
+    setStyle(style);
+    // We set the charset field so that
+    // wildcard searching will work properly
+    // out of the box
+    data.lfCharSet = cast(byte)OS.DEFAULT_CHARSET;
+}
+
+/*public*/ this(char[] name, float height, int style) {
+    if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+    setName(name);
+    setHeight(height);
+    setStyle(style);
+    // We set the charset field so that
+    // wildcard searching will work properly
+    // out of the box
+    data.lfCharSet = cast(byte)OS.DEFAULT_CHARSET;
+}
+
+/**
+ * Compares the argument to the receiver, and returns true
+ * if they represent the <em>same</em> object using a class
+ * specific comparison.
+ *
+ * @param object the object to compare with this object
+ * @return <code>true</code> if the object is the same as this object and <code>false</code> otherwise
+ *
+ * @see #hashCode
+ */
+public int opEquals (Object object) {
+    if (object is this) return true;
+    if( auto fd = cast(FontData)object ){
+        LOGFONT lf = fd.data;
+        return data.lfCharSet is lf.lfCharSet &&
+            /*
+            * This code is intentionally commented.  When creating
+            * a FontData, lfHeight is not necessarily set.  Instead
+            * we check the height field which is always set.
+            */ 
+    //      data.lfHeight is lf.lfHeight &&
+            height is fd.height &&
+            data.lfWidth is lf.lfWidth &&
+            data.lfEscapement is lf.lfEscapement &&
+            data.lfOrientation is lf.lfOrientation &&
+            data.lfWeight is lf.lfWeight &&
+            data.lfItalic is lf.lfItalic &&
+            data.lfUnderline is lf.lfUnderline &&
+            data.lfStrikeOut is lf.lfStrikeOut &&
+            data.lfCharSet is lf.lfCharSet &&
+            data.lfOutPrecision is lf.lfOutPrecision &&
+            data.lfClipPrecision is lf.lfClipPrecision &&
+            data.lfQuality is lf.lfQuality &&
+            data.lfPitchAndFamily is lf.lfPitchAndFamily &&
+            getName() ==/*eq*/ fd.getName();
+    }
+    return false;
+}
+
+//PORTING_FIXME: tango has this callback defined always with char*, needs fix
+extern (Windows) static
+//int EnumLocalesProc(TCHAR* lpLocaleString) {
+int EnumLocalesProc(char* lpLocaleString) {
+
+    /* Get the locale ID */
+    int length_ = 8;
+    char[] str = .TCHARzToStr( cast(TCHAR*)lpLocaleString, length_);
+    int lcid = Integer.parseInt(str, 16);
+
+    TCHAR[] buffer = new TCHAR[length_];
+
+    /* Check the language */
+    int size = OS.GetLocaleInfo(lcid, OS.LOCALE_SISO639LANGNAME, buffer.ptr, length_);
+    if (size <= 0 || s_this.lang !=/*eq*/ .TCHARzToStr( buffer.ptr ).substring(0, size - 1)) return 1;
+
+    /* Check the country */
+    if (s_this.country !is null) {
+        size = OS.GetLocaleInfo(lcid, OS.LOCALE_SISO3166CTRYNAME, buffer.ptr, length_);
+        if (size <= 0 || s_this.country !=/*eq*/ .TCHARzToStr( buffer.ptr ).substring(0, size - 1)) return 1;
+    }
+
+    /* Get the charset */
+    size = OS.GetLocaleInfo(lcid, OS.LOCALE_IDEFAULTANSICODEPAGE, buffer.ptr, length_);
+    if (size <= 0) return 1;
+    int cp = Integer.parseInt(.TCHARzToStr(buffer.ptr).substring(0, size - 1));
+    CHARSETINFO lpCs;
+    OS.TranslateCharsetInfo(cast(DWORD*)cp, &lpCs, OS.TCI_SRCCODEPAGE);
+    s_this.data.lfCharSet = cast(BYTE)lpCs.ciCharset;
+
+    return 0;
+}
+
+/**
+ * Returns the height of the receiver in points.
+ *
+ * @return the height of this FontData
+ *
+ * @see #setHeight(int)
+ */
+public int getHeight() {
+    return cast(int)(0.5f + height);
+}
+
+/*public*/ float getHeightF() {
+    return height;
+}
+
+/**
+ * Returns the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms where there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ * 
+ * @return the <code>String</code> representing a Locale object
+ * @since 3.0
+ */
+public char[] getLocale () {
+    StringBuffer buffer = new StringBuffer ();
+    char sep = '_';
+    if (lang !is null) {
+        buffer.append (lang);
+        buffer.append (sep);
+    }
+    if (country !is null) {
+        buffer.append (country);
+        buffer.append (sep);
+    }
+    if (variant !is null) {
+        buffer.append (variant);
+    }
+    
+    char[] result = buffer.toString ();
+    int length_ = result.length;
+    if (length_ > 0) {
+        if (result.charAt (length_ - 1) is sep) {
+            result = result.substring (0, length_ - 1);
+        }
+    } 
+    return result;
+}
+
+/**
+ * Returns the name of the receiver.
+ * On platforms that support font foundries, the return value will
+ * be the foundry followed by a dash ("-") followed by the face name.
+ *
+ * @return the name of this <code>FontData</code>
+ *
+ * @see #setName
+ */
+public char[] getName() {
+    return .TCHARzToStr( data.lfFaceName.ptr, -1 );
+}
+
+/**
+ * Returns the style of the receiver which is a bitwise OR of 
+ * one or more of the <code>DWT</code> constants NORMAL, BOLD
+ * and ITALIC.
+ *
+ * @return the style of this <code>FontData</code>
+ * 
+ * @see #setStyle
+ */
+public int getStyle() {
+    int style = DWT.NORMAL;
+    if (data.lfWeight is 700) style |= DWT.BOLD;
+    if (data.lfItalic !is 0) style |= DWT.ITALIC;
+    return style;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two 
+ * objects that return <code>true</code> when passed to 
+ * <code>equals</code> must return the same value for this
+ * method.
+ *
+ * @return the receiver's hash
+ *
+ * @see #equals
+ */
+public hash_t toHash () {
+    char[] name = getName();
+    return data.lfCharSet ^ getHeight() ^ data.lfWidth ^ data.lfEscapement ^
+        data.lfOrientation ^ data.lfWeight ^ data.lfItalic ^data.lfUnderline ^
+        data.lfStrikeOut ^ data.lfCharSet ^ data.lfOutPrecision ^
+        data.lfClipPrecision ^ data.lfQuality ^ data.lfPitchAndFamily ^
+        typeid(char[]).getHash(&name);
+}
+
+/**
+ * Sets the height of the receiver. The parameter is
+ * specified in terms of points, where a point is one
+ * seventy-second of an inch.
+ *
+ * @param height the height of the <code>FontData</code>
+ *
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ * 
+ * @see #getHeight
+ */
+public void setHeight(int height) {
+    if (height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    this.height = height;
+}
+
+/*public*/ void setHeight(float height) {
+    if (height < 0) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
+    this.height = height;
+}
+
+/**
+ * Sets the locale of the receiver.
+ * <p>
+ * The locale determines which platform character set this
+ * font is going to use. Widgets and graphics operations that
+ * use this font will convert UNICODE strings to the platform
+ * character set of the specified locale.
+ * </p>
+ * <p>
+ * On platforms where there are multiple character sets for a
+ * given language/country locale, the variant portion of the
+ * locale will determine the character set.
+ * </p>
+ * 
+ * @param locale the <code>String</code> representing a Locale object
+ * @see java.util.Locale#toString
+ */
+public void setLocale(char[] locale) {  
+    lang = country = variant = null;
+    if (locale !is null) {
+        char sep = '_';
+        int length_ = locale.length;
+        int firstSep, secondSep;
+        
+        firstSep = locale.indexOf(sep);
+        if (firstSep is -1) {
+            firstSep = secondSep = length_;
+        } else {
+            secondSep = locale.indexOf(sep, firstSep + 1);
+            if (secondSep is -1) secondSep = length_;
+        }
+        if (firstSep > 0) lang = locale.substring(0, firstSep);
+        if (secondSep > firstSep + 1) country = locale.substring(firstSep + 1, secondSep);
+        if (length_ > secondSep + 1) variant = locale.substring(secondSep + 1);
+    }
+    if (lang is null) {
+        data.lfCharSet = cast(byte)OS.DEFAULT_CHARSET;
+    } else {
+        synchronized(this.classinfo){
+            s_this = this;
+            OS.EnumSystemLocales(&EnumLocalesProc, OS.LCID_SUPPORTED);
+            s_this = null;
+        }
+    }
+}
+
+/**
+ * Sets the name of the receiver.
+ * <p>
+ * Some platforms support font foundries. On these platforms, the name
+ * of the font specified in setName() may have one of the following forms:
+ * <ol>
+ * <li>a face name (for example, "courier")</li>
+ * <li>a foundry followed by a dash ("-") followed by a face name (for example, "adobe-courier")</li>
+ * </ol>
+ * In either case, the name returned from getName() will include the
+ * foundry.
+ * </p>
+ * <p>
+ * On platforms that do not support font foundries, only the face name
+ * (for example, "courier") is used in <code>setName()</code> and 
+ * <code>getName()</code>.
+ * </p>
+ *
+ * @param name the name of the font data (must not be null)
+ * @exception IllegalArgumentException <ul>
+ *    <li>ERROR_NULL_ARGUMENT - when the font name is null</li>
+ * </ul>
+ *
+ * @see #getName
+ */
+public void setName(char[] name) {
+    if (name is null) DWT.error(DWT.ERROR_NULL_ARGUMENT);
+
+    /* The field lfFaceName must be NULL terminated */
+    int len = Math.min(OS.LF_FACESIZE - 1, name.length);
+
+    data.lfFaceName[0 .. len] = .StrToTCHARs(name)[0 .. len];
+    data.lfFaceName[len] = 0;
+}
+
+/**
+ * Sets the style of the receiver to the argument which must
+ * be a bitwise OR of one or more of the <code>DWT</code> 
+ * constants NORMAL, BOLD and ITALIC.  All other style bits are
+ * ignored.
+ *
+ * @param style the new style for this <code>FontData</code>
+ *
+ * @see #getStyle
+ */
+public void setStyle(int style) {
+    if ((style & DWT.BOLD) is DWT.BOLD) {
+        data.lfWeight = 700;
+    } else {
+        data.lfWeight = 0;
+    }
+    if ((style & DWT.ITALIC) is DWT.ITALIC) {
+        data.lfItalic = 1;
+    } else {
+        data.lfItalic = 0;
+    }
+}
+
+/**
+ * Returns a string representation of the receiver which is suitable
+ * for constructing an equivalent instance using the 
+ * <code>FontData(String)</code> constructor.
+ *
+ * @return a string representation of the FontData
+ *
+ * @see FontData
+ */
+public char[] toString() {
+    StringBuffer buffer = new StringBuffer();
+    buffer.append("1|"); //$NON-NLS-1$
+    buffer.append(getName());
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(getHeightF()));
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(getStyle()));
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append("WINDOWS|1|"); //$NON-NLS-1$  
+    buffer.append(to!(char[])(data.lfHeight));
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfWidth));
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfEscapement));
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfOrientation));  
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfWeight));  
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfItalic));
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfUnderline));
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfStrikeOut));  
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfCharSet)); 
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfOutPrecision));
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfClipPrecision));  
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfQuality)); 
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(to!(char[])(data.lfPitchAndFamily));
+    buffer.append("|"); //$NON-NLS-1$
+    buffer.append(getName());
+    return buffer.toString();
+}
+
+/**  
+ * Invokes platform specific functionality to allocate a new font data.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>FontData</code>. It is marked public only so that
+ * it can be shared within the packages provided by DWT. It is not
+ * available on all platforms, and should never be called from
+ * application code.
+ * </p>
+ *
+ * @param data the <code>LOGFONT</code> for the font data
+ * @param height the height of the font data
+ * @return a new font data object containing the specified <code>LOGFONT</code> and height
+ */
+public static FontData win32_new(LOGFONT* data, float height) {
+    return new FontData(data, height);
+}
+
+}
--- a/dwt/internal/win32/OS.d	Fri Jan 25 14:23:28 2008 +0100
+++ b/dwt/internal/win32/OS.d	Fri Jan 25 19:16:45 2008 +0100
@@ -12,11 +12,22 @@
 
 public import dwt.internal.win32.WINTYPES;
 private import dwt.internal.win32.WINAPI;
+alias dwt.internal.win32.WINAPI WINAPI;
 
 import dwt.internal.C;
 import dwt.internal.Library;
 
 public class OS : C {
+
+    private static int getNOTIFYICONDATAA_V2_SIZE (){
+        // hm, NOTIFYICONDATAA.dwInfoFlags.offsetof did not compile
+        return IsWinCE ? NOTIFYICONDATAA.sizeof : cast(int)(&(cast(NOTIFYICONDATAA*)null).dwInfoFlags) + int.sizeof;
+    }
+
+    private static int getNOTIFYICONDATAW_V2_SIZE (){
+        return IsWinCE ? NOTIFYICONDATAW.sizeof : cast(int)(&(cast(NOTIFYICONDATAW*)null).dwInfoFlags) + int.sizeof;
+    }
+
     /*
     * DWT Windows flags
     */
@@ -65,6 +76,32 @@
     public static const int SM_IMMENABLED = 0x52;
     public static const int LANG_KOREAN = 0x12;
     public static const int MAX_PATH = 260;
+
+    static this(){
+        NOTIFYICONDATAA_V2_SIZE = getNOTIFYICONDATAA_V2_SIZE ();
+        NOTIFYICONDATAW_V2_SIZE = getNOTIFYICONDATAW_V2_SIZE ();
+        NOTIFYICONDATA_V2_SIZE = IsUnicode ? getNOTIFYICONDATAW_V2_SIZE : getNOTIFYICONDATAA_V2_SIZE;
+        OSVERSIONINFO info;
+        IsWin32s = (info.dwPlatformId is VER_PLATFORM_WIN32s);
+        IsWin95 = (info.dwPlatformId is VER_PLATFORM_WIN32_WINDOWS);
+        IsWinNT = (info.dwPlatformId is VER_PLATFORM_WIN32_NT);
+        IsSP_ = false;
+        IsPPC_ = false;
+        IsHPC = false;
+        IsDBLocale = false;
+        WIN32_MAJOR = info.dwMajorVersion;
+        WIN32_MINOR = info.dwMinorVersion;
+        WIN32_VERSION = VERSION (WIN32_MAJOR, WIN32_MINOR);
+        //IsUnicode = !IsWin32s && !IsWin95;
+        DLLVERSIONINFO dvi;
+        COMCTL32_MAJOR = dvi.dwMajorVersion;
+        COMCTL32_MINOR = dvi.dwMinorVersion;
+        COMCTL32_VERSION = VERSION (COMCTL32_MAJOR, COMCTL32_MINOR);
+        SHELL32_MAJOR = dvi.dwMajorVersion;
+        SHELL32_MINOR = dvi.dwMinorVersion;
+        SHELL32_VERSION = VERSION (SHELL32_MAJOR, SHELL32_MINOR);
+    }
+//PORTING_LEFT
 /++
     /* Get the Windows version and the flags */
     public static this() {
@@ -214,6 +251,7 @@
         SHELL32_MINOR = dvi.dwMinorVersion;
         SHELL32_VERSION = VERSION (SHELL32_MAJOR, SHELL32_MINOR);
     }
+++/
 
     /* Flag used on WinCE */
     static const int SYS_COLOR_INDEX_FLAG = OS.IsWinCE ? 0x40000000 : 0x0;
@@ -1169,9 +1207,9 @@
     public static const int NM_RECOGNIZEGESTURE = NM_FIRST - 16;
     public static const int NM_RELEASEDCAPTURE = NM_FIRST - 16;
     public static const int NM_RETURN = 0xfffffffc;
-    public static const int NOTIFYICONDATAA_V2_SIZE = NOTIFYICONDATAA_V2_SIZE ();
-    public static const int NOTIFYICONDATAW_V2_SIZE = NOTIFYICONDATAW_V2_SIZE ();
-    public static const int NOTIFYICONDATA_V2_SIZE = IsUnicode ? NOTIFYICONDATAW_V2_SIZE : NOTIFYICONDATAA_V2_SIZE;
+    public static int NOTIFYICONDATAA_V2_SIZE;
+    public static int NOTIFYICONDATAW_V2_SIZE;
+    public static int NOTIFYICONDATA_V2_SIZE;
     public static const int NOTSRCCOPY = 0x330008;
     public static const int NULLREGION = 0x1;
     public static const int NULL_BRUSH = 0x5;
@@ -2006,6 +2044,7 @@
     public static const int WS_BORDER = 0x800000;
     public static const int WS_CAPTION = 0xc00000;
     public static const int WS_CHILD = 0x40000000;
+    public static const int WS_MINIMIZE = 0x20000000; //PORTING_TODO: from dwt, why?
     public static const int WS_CLIPCHILDREN = 0x2000000;
     public static const int WS_CLIPSIBLINGS = 0x4000000;
     public static const int WS_DISABLED = 0x4000000;
@@ -2041,11 +2080,9 @@
     public static const int XBUTTON1 = 0x1;
     public static const int XBUTTON2 = 0x2;
     
-public static int VERSION (int major, int minor) {
-    return major << 16 | minor;
-}
-
-
+
+//PORTING_LEFT
+/++
 /** Ansi/Unicode wrappers */
 
 public static final int /*long*/ AddFontResourceEx (TCHAR lpszFilename, int fl, int /*long*/ pdv) {
@@ -3519,8 +3556,7 @@
 public static final native void MoveMemory (int /*long*/ Destination, MOUSEINPUT Source, int Length);
 public static final native BOOL MoveToEx (int /*long*/ hdc, int x1, int x2, int /*long*/ lPoint);
 public static final native int MsgWaitForMultipleObjectsEx (int nCount, int /*long*/ pHandles, int dwMilliseconds, int dwWakeMask, int dwFlags);
-public static final native int MultiByteToWideChar (int CodePage, int dwFlags, byte [] lpMultiByteStr, int cchMultiByte, char [] lpWideCharStr, int cchWideChar);
-public static final native int MultiByteToWideChar (int CodePage, int dwFlags, int /*long*/ lpMultiByteStr, int cchMultiByte, char [] lpWideCharStr, int cchWideChar);
+//alias WINAPI.MultiByteToWideChar MultiByteToWideChar;
 public static final native void NotifyWinEvent (int event, int /*long*/ hwnd, int idObject, int idChild);
 public static final native BOOL OffsetRect (RECT lprc, int dx, int dy);
 public static final native int OffsetRgn (int /*long*/ hrgn, int nXOffset, int nYOffset);
@@ -3771,11 +3807,1008 @@
 
 public static final native int VtblCall (int fnNumber, int /*long*/ ppVtbl, char[] arg0, int arg1, int arg2, int[] arg3, int[] arg4);
 
-public static final native BOOL WaitMessage ();
-public static final native int WideCharToMultiByte (int CodePage, int dwFlags, char [] lpWideCharStr, int cchWideChar, byte [] lpMultiByteStr, int cchMultiByte, byte [] lpDefaultChar, BOOL [] lpUsedDefaultChar);
-public static final native int WideCharToMultiByte (int CodePage, int dwFlags, char [] lpWideCharStr, int cchWideChar, int /*long*/ lpMultiByteStr, int cchMultiByte, byte [] lpDefaultChar, BOOL [] lpUsedDefaultChar);
-public static final native int /*long*/ WindowFromDC (int /*long*/ hDC);
-public static final native int /*long*/ WindowFromPoint (POINT lpPoint);
-public static final native int wcslen (int /*long*/ string);
 ++/
+
+/** Ansi/Unicode wrappers */
+// Unicode/Ansi alias
+version(ANSI) {
+    alias WINAPI.CallWindowProcA CallWindowProc;
+    alias WINAPI.CharLowerA CharLower;
+    alias WINAPI.CharUpperA CharUpper;
+    alias WINAPI.ChooseColorA ChooseColor;
+    alias WINAPI.ChooseFontA ChooseFont;
+    alias WINAPI.CreateAcceleratorTableA CreateAcceleratorTable;
+    alias WINAPI.CreateDCA CreateDC;
+    alias WINAPI.CreateEventA CreateEvent;
+    alias WINAPI.CreateFileA CreateFile;
+    alias WINAPI.CreateFontIndirectA CreateFontIndirect;
+    alias WINAPI.CreateWindowExA CreateWindowEx;
+    alias WINAPI.DefFrameProcA DefFrameProc;
+    alias WINAPI.DefMDIChildProcA DefMDIChildProc;
+    alias WINAPI.DefWindowProcA DefWindowProc;
+    alias WINAPI.DeleteFileA DeleteFile;
+    alias WINAPI.DispatchMessageA DispatchMessage;
+    alias WINAPI.DragQueryFileA DragQueryFile;
+    alias WINAPI.DrawStateA DrawState;
+    alias WINAPI.DrawTextA DrawText;
+    alias WINAPI.EnumFontFamiliesExA EnumFontFamiliesEx;
+    alias WINAPI.EnumFontFamiliesA EnumFontFamilies;
+    alias WINAPI.EnumSystemLanguageGroupsA EnumSystemLanguageGroups;
+    alias WINAPI.EnumSystemLocalesA EnumSystemLocales;
+    alias WINAPI.ExpandEnvironmentStringsA ExpandEnvironmentStrings;
+    alias WINAPI.ExtTextOutA ExtTextOut;
+    alias WINAPI.ExtractIconExA ExtractIconEx;
+    alias WINAPI.FindResourceA FindResource;
+    alias WINAPI.FindWindowA FindWindow;
+    alias WINAPI.FormatMessageA FormatMessage;
+    alias WINAPI.GetCharABCWidthsA GetCharABCWidths;
+    alias WINAPI.GetCharWidthA GetCharWidth;
+    alias WINAPI.GetCharacterPlacementA GetCharacterPlacement;
+    alias WINAPI.GetClassInfoA GetClassInfo;
+    alias WINAPI.GetClipboardFormatNameA GetClipboardFormatName;
+    alias WINAPI.GetKeyNameTextA GetKeyNameText;
+    alias WINAPI.GetLocaleInfoA GetLocaleInfo;
+    alias WINAPI.GetMenuItemInfoA GetMenuItemInfo;
+    alias WINAPI.GetMessageA GetMessage;
+    alias WINAPI.GetModuleFileNameA GetModuleFileName;
+    alias WINAPI.GetModuleHandleA GetModuleHandle;
+    alias WINAPI.GetMonitorInfoA GetMonitorInfo;
+    alias WINAPI.GetObjectA GetObject;
+    alias WINAPI.GetOpenFileNameA GetOpenFileName;
+    alias WINAPI.GetProfileStringA _GetProfileString;
+    alias WINAPI.GetSaveFileNameA GetSaveFileName;
+    alias WINAPI.GetTextExtentPoint32A GetTextExtentPoint32;
+    alias WINAPI.GetTextMetricsA GetTextMetrics;
+    alias WINAPI.GetVersionExA GetVersionEx;
+    alias WINAPI.GetWindowLongA GetWindowLong;
+    alias WINAPI.GetWindowTextA _GetWindowText;
+    alias WINAPI.GetWindowTextLengthA GetWindowTextLength;
+    alias WINAPI.ImmGetCompositionFontA ImmGetCompositionFont;
+    alias WINAPI.ImmGetCompositionStringA ImmGetCompositionString;
+    alias WINAPI.ImmSetCompositionFontA ImmSetCompositionFont;
+    alias WINAPI.InsertMenuA InsertMenu;
+    alias WINAPI.InsertMenuItemA InsertMenuItem;
+    alias WINAPI.LoadBitmapA LoadBitmap;
+    alias WINAPI.LoadCursorA LoadCursor;
+    alias WINAPI.LoadIconA LoadIcon;
+    alias WINAPI.LoadImageA LoadImage;
+    alias WINAPI.LoadLibraryA LoadLibrary;
+    alias WINAPI.LoadStringA LoadString;
+    alias WINAPI.MapVirtualKeyA MapVirtualKey;
+    alias WINAPI.MessageBoxA MessageBox;
+    alias WINAPI.OutputDebugStringA OutputDebugString;
+    alias WINAPI.PeekMessageA PeekMessage;
+    alias WINAPI.PostMessageA PostMessage;
+    alias WINAPI.PostThreadMessageA PostThreadMessage;
+    alias WINAPI.PrintDlgA PrintDlg;
+    alias WINAPI.RegEnumKeyExA RegEnumKeyEx;
+    alias WINAPI.RegOpenKeyExA RegOpenKeyEx;
+    alias WINAPI.RegQueryInfoKeyA RegQueryInfoKey;
+    alias WINAPI.RegQueryValueExA RegQueryValueEx;
+    alias WINAPI.RegisterClassA RegisterClass;
+    alias WINAPI.RegisterClipboardFormatA RegisterClipboardFormat;
+    alias WINAPI.RegisterWindowMessageA RegisterWindowMessage;
+    alias WINAPI.SHBrowseForFolderA SHBrowseForFolder;
+    alias WINAPI.SHGetPathFromIDListA SHGetPathFromIDList;
+    alias WINAPI.SendMessageA SendMessage;
+    alias WINAPI.SetMenuItemInfoA SetMenuItemInfo;
+    alias WINAPI.SetWindowLongA SetWindowLong;
+    alias WINAPI.SetWindowTextA SetWindowText;
+    alias WINAPI.SetWindowsHookExA SetWindowsHookEx;
+    alias WINAPI.ShellExecuteExA ShellExecuteEx;
+    alias WINAPI.Shell_NotifyIconA Shell_NotifyIcon;
+    alias WINAPI.StartDocA StartDoc;
+    alias WINAPI.SystemParametersInfoA SystemParametersInfo;
+    alias WINAPI.TranslateAcceleratorA TranslateAccelerator;
+    alias WINAPI.UnregisterClassA UnregisterClass;
+    alias WINAPI.VkKeyScanA VkKeyScan;
+}else{
+    alias WINAPI.CallWindowProcW CallWindowProc;
+    alias WINAPI.CharLowerW CharLower;
+    alias WINAPI.CharUpperW CharUpper;
+    alias WINAPI.ChooseColorW ChooseColor;
+    alias WINAPI.ChooseFontW ChooseFont;
+    alias WINAPI.CreateAcceleratorTableW CreateAcceleratorTable;
+    alias WINAPI.CreateDCW CreateDC;
+    alias WINAPI.CreateEventW CreateEvent;
+    alias WINAPI.CreateFileW CreateFile;
+    alias WINAPI.CreateFontIndirectW CreateFontIndirect;
+    alias WINAPI.CreateWindowExW CreateWindowEx;
+    alias WINAPI.DefFrameProcW DefFrameProc;
+    alias WINAPI.DefMDIChildProcW DefMDIChildProc;
+    alias WINAPI.DefWindowProcW DefWindowProc;
+    alias WINAPI.DeleteFileW DeleteFile;
+    alias WINAPI.DispatchMessageW DispatchMessage;
+    alias WINAPI.DragQueryFileW DragQueryFile;
+    alias WINAPI.DrawStateW DrawState;
+    alias WINAPI.DrawTextW DrawText;
+    alias WINAPI.EnumFontFamiliesExW EnumFontFamiliesEx;
+    alias WINAPI.EnumFontFamiliesW EnumFontFamilies;
+    alias WINAPI.EnumSystemLanguageGroupsW EnumSystemLanguageGroups;
+    alias WINAPI.EnumSystemLocalesW EnumSystemLocales;
+    alias WINAPI.ExpandEnvironmentStringsW ExpandEnvironmentStrings;
+    alias WINAPI.ExtTextOutW ExtTextOut;
+    alias WINAPI.ExtractIconExW ExtractIconEx;
+    alias WINAPI.FindResourceW FindResource;
+    alias WINAPI.FindWindowW FindWindow;
+    alias WINAPI.FormatMessageW FormatMessage;
+    alias WINAPI.GetCharABCWidthsW GetCharABCWidths;
+    alias WINAPI.GetCharWidthW GetCharWidth;
+    alias WINAPI.GetCharacterPlacementW GetCharacterPlacement;
+    alias WINAPI.GetClassInfoW GetClassInfo;
+    alias WINAPI.GetClipboardFormatNameW GetClipboardFormatName;
+    alias WINAPI.GetKeyNameTextW GetKeyNameText;
+    alias WINAPI.GetLocaleInfoW GetLocaleInfo;
+    alias WINAPI.GetMenuItemInfoW GetMenuItemInfo;
+    alias WINAPI.GetMessageW GetMessage;
+    alias WINAPI.GetModuleFileNameW GetModuleFileName;
+    alias WINAPI.GetModuleHandleW GetModuleHandle;
+    alias WINAPI.GetMonitorInfoW GetMonitorInfo;
+    alias WINAPI.GetObjectW GetObject;
+    alias WINAPI.GetOpenFileNameW GetOpenFileName;
+    alias WINAPI.GetProfileStringW _GetProfileString;
+    alias WINAPI.GetSaveFileNameW GetSaveFileName;
+    alias WINAPI.GetTextExtentPoint32W GetTextExtentPoint32;
+    alias WINAPI.GetTextMetricsW GetTextMetrics;
+    alias WINAPI.GetVersionExW GetVersionEx;
+    alias WINAPI.GetWindowLongW GetWindowLong;
+    alias WINAPI.GetWindowTextW _GetWindowText;
+    alias WINAPI.GetWindowTextLengthW GetWindowTextLength;
+    alias WINAPI.ImmGetCompositionFontW ImmGetCompositionFont;
+    alias WINAPI.ImmGetCompositionStringW ImmGetCompositionString;
+    alias WINAPI.ImmSetCompositionFontW ImmSetCompositionFont;
+    alias WINAPI.InsertMenuW InsertMenu;
+    alias WINAPI.InsertMenuItemW InsertMenuItem;
+    alias WINAPI.LoadBitmapW LoadBitmap;
+    alias WINAPI.LoadCursorW LoadCursor;
+    alias WINAPI.LoadIconW LoadIcon;
+    alias WINAPI.LoadImageW LoadImage;
+    alias WINAPI.LoadLibraryW LoadLibrary;
+    alias WINAPI.LoadStringW LoadString;
+    alias WINAPI.MapVirtualKeyW MapVirtualKey;
+    alias WINAPI.MessageBoxW MessageBox;
+    alias WINAPI.OutputDebugStringW OutputDebugString;
+    alias WINAPI.PeekMessageW PeekMessage;
+    alias WINAPI.PostMessageW PostMessage;
+    alias WINAPI.PostThreadMessageW PostThreadMessage;
+    alias WINAPI.PrintDlgW PrintDlg;
+    alias WINAPI.RegEnumKeyExW RegEnumKeyEx;
+    alias WINAPI.RegOpenKeyExW RegOpenKeyEx;
+    alias WINAPI.RegQueryInfoKeyW RegQueryInfoKey;
+    alias WINAPI.RegQueryValueExW RegQueryValueEx;
+    alias WINAPI.RegisterClassW RegisterClass;
+    alias WINAPI.RegisterClipboardFormatW RegisterClipboardFormat;
+    alias WINAPI.RegisterWindowMessageW RegisterWindowMessage;
+    alias WINAPI.SHBrowseForFolderW SHBrowseForFolder;
+    alias WINAPI.SHGetPathFromIDListW SHGetPathFromIDList;
+    alias WINAPI.SendMessageW SendMessage;
+    alias WINAPI.SetMenuItemInfoW SetMenuItemInfo;
+    alias WINAPI.SetWindowLongW SetWindowLong;
+    alias WINAPI.SetWindowTextW SetWindowText;
+    alias WINAPI.SetWindowsHookExW SetWindowsHookEx;
+    alias WINAPI.ShellExecuteExW ShellExecuteEx;
+    alias WINAPI.Shell_NotifyIconW Shell_NotifyIcon;
+    alias WINAPI.StartDocW StartDoc;
+    alias WINAPI.SystemParametersInfoW SystemParametersInfo;
+    alias WINAPI.TranslateAcceleratorW TranslateAccelerator;
+    alias WINAPI.UnregisterClassW UnregisterClass;
+    alias WINAPI.VkKeyScanW VkKeyScan;
 }
+    
+    
+    
+    
+    
+    
+/** All Natives */
+alias WINAPI.AbortDoc AbortDoc;
+alias WINAPI.ActivateKeyboardLayout ActivateKeyboardLayout;
+alias WINAPI.AdjustWindowRectEx AdjustWindowRectEx;
+alias WINAPI.Arc Arc;
+alias WINAPI.BeginDeferWindowPos BeginDeferWindowPos;
+alias WINAPI.BeginPaint BeginPaint;
+alias WINAPI.BitBlt BitBlt;
+alias WINAPI.BringWindowToTop BringWindowToTop;
+alias WINAPI.CallNextHookEx CallNextHookEx;
+alias WINAPI.CallWindowProcA CallWindowProcA;
+alias WINAPI.CallWindowProcW CallWindowProcW;
+alias WINAPI.CharLowerA CharLowerA;
+alias WINAPI.CharLowerW CharLowerW;
+alias WINAPI.CharUpperA CharUpperA;
+alias WINAPI.CharUpperW CharUpperW;
+alias WINAPI.CheckMenuItem CheckMenuItem;
+alias WINAPI.ChooseColorA ChooseColorA;
+alias WINAPI.ChooseColorW ChooseColorW;
+alias WINAPI.ChooseFontA ChooseFontA;
+alias WINAPI.ChooseFontW ChooseFontW;
+alias WINAPI.ClientToScreen ClientToScreen;
+alias WINAPI.CloseHandle CloseHandle;
+alias WINAPI.CloseClipboard CloseClipboard;
+alias WINAPI.CombineRgn CombineRgn;
+alias WINAPI.CommDlgExtendedError CommDlgExtendedError;
+
+version(WinCE){
+alias WINAPI.CommandBar_AddAdornments CommandBar_AddAdornments;
+alias WINAPI.CommandBar_Create CommandBar_Create;
+alias WINAPI.CommandBar_Destroy CommandBar_Destroy;
+alias WINAPI.CommandBar_DrawMenuBar CommandBar_DrawMenuBar;
+alias WINAPI.CommandBar_Height CommandBar_Height;
+alias WINAPI.CommandBar_InsertMenubarEx CommandBar_InsertMenubarEx;
+alias WINAPI.CommandBar_Show CommandBar_Show;
+}
+
+alias WINAPI.CopyImage CopyImage;
+alias WINAPI.CreateAcceleratorTableA CreateAcceleratorTableA;
+alias WINAPI.CreateAcceleratorTableW CreateAcceleratorTableW;
+alias WINAPI.CreateBitmap CreateBitmap;
+alias WINAPI.CreateCaret CreateCaret;
+alias WINAPI.CreateCompatibleBitmap CreateCompatibleBitmap;
+alias WINAPI.CreateCompatibleDC CreateCompatibleDC;
+alias WINAPI.CreateCursor CreateCursor;
+alias WINAPI.CreateDCA CreateDCA;
+alias WINAPI.CreateDCW CreateDCW;
+alias WINAPI.CreateDIBSection CreateDIBSection;
+alias WINAPI.CreateEventA CreateEventA;
+alias WINAPI.CreateEventW CreateEventW;
+alias WINAPI.CreateFileA CreateFileA;
+alias WINAPI.CreateFileW CreateFileW;
+alias WINAPI.CreateFontIndirectA CreateFontIndirectA;
+alias WINAPI.CreateFontIndirectW CreateFontIndirectW;
+alias WINAPI.CreateIconIndirect CreateIconIndirect;
+alias WINAPI.CreateMenu CreateMenu;
+alias WINAPI.CreatePalette CreatePalette;
+alias WINAPI.CreatePatternBrush CreatePatternBrush;
+alias WINAPI.CreatePen CreatePen;
+alias WINAPI.CreatePolygonRgn CreatePolygonRgn;
+alias WINAPI.CreatePopupMenu CreatePopupMenu;
+alias WINAPI.CreateRectRgn CreateRectRgn;
+alias WINAPI.CreateSolidBrush CreateSolidBrush;
+alias WINAPI.CreateWindowExA CreateWindowExA;
+alias WINAPI.CreateWindowExW CreateWindowExW;
+alias WINAPI.DefFrameProcA DefFrameProcA;
+alias WINAPI.DefFrameProcW DefFrameProcW;
+alias WINAPI.DefMDIChildProcA DefMDIChildProcA;
+alias WINAPI.DefMDIChildProcW DefMDIChildProcW;
+alias WINAPI.DefWindowProcA DefWindowProcA;
+alias WINAPI.DefWindowProcW DefWindowProcW;
+alias WINAPI.DeferWindowPos DeferWindowPos;
+alias WINAPI.DeleteDC DeleteDC;
+alias WINAPI.DeleteMenu DeleteMenu;
+alias WINAPI.DeleteObject DeleteObject;
+alias WINAPI.DestroyAcceleratorTable DestroyAcceleratorTable;
+alias WINAPI.DestroyCaret DestroyCaret;
+alias WINAPI.DestroyCursor DestroyCursor;
+alias WINAPI.DestroyIcon DestroyIcon;
+alias WINAPI.DestroyMenu DestroyMenu;
+alias WINAPI.DestroyWindow DestroyWindow;
+alias WINAPI.DispatchMessageA DispatchMessageA;
+alias WINAPI.DispatchMessageW DispatchMessageW;
+alias WINAPI.DragDetect DragDetect;
+alias WINAPI.DragFinish DragFinish;
+alias WINAPI.DragQueryFileA DragQueryFileA;
+alias WINAPI.DragQueryFileW DragQueryFileW;
+alias WINAPI.DrawEdge DrawEdge;
+alias WINAPI.DrawFocusRect DrawFocusRect;
+alias WINAPI.DrawFrameControl DrawFrameControl;
+alias WINAPI.DrawIconEx DrawIconEx;
+alias WINAPI.DrawMenuBar DrawMenuBar;
+alias WINAPI.DrawStateA DrawStateA;
+alias WINAPI.DrawStateW DrawStateW;
+alias WINAPI.DrawTextA DrawTextA;
+alias WINAPI.DrawTextW DrawTextW;
+alias WINAPI.Ellipse Ellipse;
+alias WINAPI.EnableMenuItem EnableMenuItem;
+alias WINAPI.EnableScrollBar EnableScrollBar;
+alias WINAPI.EnableWindow EnableWindow;
+alias WINAPI.EndDeferWindowPos EndDeferWindowPos;
+alias WINAPI.EndDoc EndDoc;
+alias WINAPI.EndPage EndPage;
+alias WINAPI.EndPaint EndPaint;
+alias WINAPI.EnumDisplayMonitors EnumDisplayMonitors;
+alias WINAPI.EnumFontFamiliesA EnumFontFamiliesA;
+alias WINAPI.EnumFontFamiliesExA EnumFontFamiliesExA;
+alias WINAPI.EnumFontFamiliesExW EnumFontFamiliesExW;
+alias WINAPI.EnumFontFamiliesW EnumFontFamiliesW;
+alias WINAPI.EnumSystemLanguageGroupsA EnumSystemLanguageGroupsA;
+alias WINAPI.EnumSystemLanguageGroupsW EnumSystemLanguageGroupsW;
+alias WINAPI.EnumSystemLocalesA EnumSystemLocalesA;
+alias WINAPI.EnumSystemLocalesW EnumSystemLocalesW;
+alias WINAPI.EqualRect EqualRect;
+alias WINAPI.EqualRgn EqualRgn;
+alias WINAPI.ExpandEnvironmentStringsA ExpandEnvironmentStringsA;
+alias WINAPI.ExpandEnvironmentStringsW ExpandEnvironmentStringsW;
+alias WINAPI.ExtTextOutA ExtTextOutA;
+alias WINAPI.ExtTextOutW ExtTextOutW;
+alias WINAPI.ExtractIconExA ExtractIconExA;
+alias WINAPI.ExtractIconExW ExtractIconExW;
+alias WINAPI.FillRect FillRect;
+alias WINAPI.FindResourceA FindResourceA;
+alias WINAPI.FindResourceW FindResourceW;
+alias WINAPI.FindWindowA FindWindowA;
+alias WINAPI.FindWindowW FindWindowW;
+alias WINAPI.FormatMessageA FormatMessageA;
+alias WINAPI.FormatMessageW FormatMessageW;
+alias WINAPI.FreeLibrary FreeLibrary;
+alias WINAPI.GdiSetBatchLimit GdiSetBatchLimit;
+alias WINAPI.GetACP GetACP;
+alias WINAPI.GetActiveWindow GetActiveWindow;
+alias WINAPI.GetBkColor GetBkColor;
+alias WINAPI.GetCapture GetCapture;
+alias WINAPI.GetCaretPos GetCaretPos;
+alias WINAPI.GetCharABCWidthsA GetCharABCWidthsA;
+alias WINAPI.GetCharABCWidthsW GetCharABCWidthsW;
+alias WINAPI.GetCharWidthA GetCharWidthA;
+alias WINAPI.GetCharWidthW GetCharWidthW;
+alias WINAPI.GetCharacterPlacementA GetCharacterPlacementA;
+alias WINAPI.GetCharacterPlacementW GetCharacterPlacementW;
+alias WINAPI.GetClassInfoA GetClassInfoA;
+alias WINAPI.GetClassInfoW GetClassInfoW;
+alias WINAPI.GetClientRect GetClientRect;
+alias WINAPI.GetClipBox GetClipBox;
+alias WINAPI.GetClipRgn GetClipRgn;
+alias WINAPI.GetClipboardData GetClipboardData;
+alias WINAPI.GetClipboardFormatNameA GetClipboardFormatNameA;
+alias WINAPI.GetClipboardFormatNameW GetClipboardFormatNameW;
+alias WINAPI.GetComboBoxInfo GetComboBoxInfo;
+alias WINAPI.GetCurrentObject GetCurrentObject;
+alias WINAPI.GetCurrentProcessId GetCurrentProcessId;
+alias WINAPI.GetCurrentThreadId GetCurrentThreadId;
+alias WINAPI.GetCursor GetCursor;
+alias WINAPI.GetCursorPos GetCursorPos;
+alias WINAPI.GetDC GetDC;
+alias WINAPI.GetDCEx GetDCEx;
+alias WINAPI.GetDIBColorTable GetDIBColorTable;
+alias WINAPI.GetDIBits GetDIBits;
+alias WINAPI.GetDesktopWindow GetDesktopWindow;
+alias WINAPI.GetDeviceCaps GetDeviceCaps;
+alias WINAPI.GetDialogBaseUnits GetDialogBaseUnits;
+alias WINAPI.GetDlgItem GetDlgItem;
+alias WINAPI.GetDoubleClickTime GetDoubleClickTime;
+alias WINAPI.GetFocus GetFocus;
+alias WINAPI.GetFontLanguageInfo GetFontLanguageInfo;
+alias WINAPI.GetGUIThreadInfo GetGUIThreadInfo;
+alias WINAPI.GetIconInfo GetIconInfo;
+alias WINAPI.GetKeyNameTextA GetKeyNameTextA;
+alias WINAPI.GetKeyNameTextW GetKeyNameTextW;
+alias WINAPI.GetKeyState GetKeyState;
+alias WINAPI.GetKeyboardLayout GetKeyboardLayout;
+alias WINAPI.GetKeyboardLayoutList GetKeyboardLayoutList;
+alias WINAPI.GetKeyboardState GetKeyboardState;
+alias WINAPI.GetLastActivePopup GetLastActivePopup;
+alias WINAPI.GetLastError GetLastError;
+alias WINAPI.GetLayout GetLayout;
+alias WINAPI.GetLocaleInfoA GetLocaleInfoA;
+alias WINAPI.GetLocaleInfoW GetLocaleInfoW;
+alias WINAPI.GetMenu GetMenu;
+alias WINAPI.GetMenuBarInfo GetMenuBarInfo;
+alias WINAPI.GetMenuDefaultItem GetMenuDefaultItem;
+alias WINAPI.GetMenuInfo GetMenuInfo;
+alias WINAPI.GetMenuItemCount GetMenuItemCount;
+alias WINAPI.GetMenuItemInfoA GetMenuItemInfoA;
+alias WINAPI.GetMenuItemInfoW GetMenuItemInfoW;
+alias WINAPI.GetMenuItemRect GetMenuItemRect;
+alias WINAPI.GetMessageA GetMessageA;
+alias WINAPI.GetMessagePos GetMessagePos;
+alias WINAPI.GetMessageTime GetMessageTime;
+alias WINAPI.GetMessageW GetMessageW;
+alias WINAPI.GetModuleFileNameA GetModuleFileNameA;
+alias WINAPI.GetModuleFileNameW GetModuleFileNameW;
+alias WINAPI.GetModuleHandleA GetModuleHandleA;
+alias WINAPI.GetModuleHandleW GetModuleHandleW;
+alias WINAPI.GetMonitorInfoA GetMonitorInfoA;
+alias WINAPI.GetMonitorInfoW GetMonitorInfoW;
+alias WINAPI.GetNearestPaletteIndex GetNearestPaletteIndex;
+alias WINAPI.GetObjectA GetObjectA;
+alias WINAPI.GetObjectW GetObjectW;
+alias WINAPI.GetOpenFileNameA GetOpenFileNameA;
+alias WINAPI.GetOpenFileNameW GetOpenFileNameW;
+alias WINAPI.GetPaletteEntries GetPaletteEntries;
+alias WINAPI.GetParent GetParent;
+alias WINAPI.GetPixel GetPixel;
+alias WINAPI.GetProcAddress GetProcAddress;
+alias WINAPI.GetProcessHeap GetProcessHeap;
+alias WINAPI.GetProfileStringA GetProfileStringA;
+alias WINAPI.GetProfileStringW GetProfileStringW;
+alias WINAPI.GetROP2 GetROP2;
+alias WINAPI.GetRandomRgn GetRandomRgn;
+alias WINAPI.GetRegionData GetRegionData;
+alias WINAPI.GetRgnBox GetRgnBox;
+alias WINAPI.GetSaveFileNameA GetSaveFileNameA;
+alias WINAPI.GetSaveFileNameW GetSaveFileNameW;
+alias WINAPI.GetScrollInfo GetScrollInfo;
+alias WINAPI.GetStockObject GetStockObject;
+alias WINAPI.GetSysColor GetSysColor;
+alias WINAPI.GetSysColorBrush GetSysColorBrush;
+alias WINAPI.GetSystemMenu GetSystemMenu;
+alias WINAPI.GetSystemMetrics GetSystemMetrics;
+alias WINAPI.GetSystemPaletteEntries GetSystemPaletteEntries;
+alias WINAPI.GetTextCharset GetTextCharset;
+alias WINAPI.GetTextColor GetTextColor;
+alias WINAPI.GetTextExtentPoint32A GetTextExtentPoint32A;
+alias WINAPI.GetTextExtentPoint32W GetTextExtentPoint32W;
+alias WINAPI.GetTextMetricsA GetTextMetricsA;
+alias WINAPI.GetTextMetricsW GetTextMetricsW;
+alias WINAPI.GetTickCount GetTickCount;
+alias WINAPI.GetUpdateRect GetUpdateRect;
+alias WINAPI.GetUpdateRgn GetUpdateRgn;
+alias WINAPI.GetVersion GetVersion;
+alias WINAPI.GetVersionExA GetVersionExA;
+alias WINAPI.GetVersionExW GetVersionExW;
+alias WINAPI.GetWindow GetWindow;
+alias WINAPI.GetWindowLongA GetWindowLongA;
+alias WINAPI.GetWindowLongW GetWindowLongW;
+alias WINAPI.GetWindowPlacement GetWindowPlacement;
+alias WINAPI.GetWindowRect GetWindowRect;
+alias WINAPI.GetWindowRgn GetWindowRgn;
+alias WINAPI.GetWindowTextA GetWindowTextA;
+alias WINAPI.GetWindowTextLengthA GetWindowTextLengthA;
+alias WINAPI.GetWindowTextLengthW GetWindowTextLengthW;
+alias WINAPI.GetWindowTextW GetWindowTextW;
+alias WINAPI.GetWindowThreadProcessId GetWindowThreadProcessId;
+alias WINAPI.GlobalAlloc GlobalAlloc;
+alias WINAPI.GlobalFree GlobalFree;
+alias WINAPI.GlobalLock GlobalLock;
+alias WINAPI.GlobalSize GlobalSize;
+alias WINAPI.GlobalUnlock GlobalUnlock;
+alias WINAPI.GradientFill GradientFill;
+alias WINAPI.HeapAlloc HeapAlloc;
+alias WINAPI.HeapFree HeapFree;
+alias WINAPI.HideCaret HideCaret;
+alias WINAPI.ImageList_Add ImageList_Add;
+alias WINAPI.ImageList_AddMasked ImageList_AddMasked;
+alias WINAPI.ImageList_Create ImageList_Create;
+alias WINAPI.ImageList_Destroy ImageList_Destroy;
+alias WINAPI.ImageList_GetIcon ImageList_GetIcon;
+alias WINAPI.ImageList_GetIconSize ImageList_GetIconSize;
+alias WINAPI.ImageList_GetImageCount ImageList_GetImageCount;
+alias WINAPI.ImageList_Remove ImageList_Remove;
+alias WINAPI.ImageList_Replace ImageList_Replace;
+alias WINAPI.ImageList_ReplaceIcon ImageList_ReplaceIcon;
+alias WINAPI.ImageList_SetIconSize ImageList_SetIconSize;
+alias WINAPI.ImmAssociateContext ImmAssociateContext;
+alias WINAPI.ImmCreateContext ImmCreateContext;
+alias WINAPI.ImmDestroyContext ImmDestroyContext;
+alias WINAPI.ImmGetCompositionFontA ImmGetCompositionFontA;
+alias WINAPI.ImmGetCompositionFontW ImmGetCompositionFontW;
+alias WINAPI.ImmGetCompositionStringA ImmGetCompositionStringA;
+alias WINAPI.ImmGetCompositionStringW ImmGetCompositionStringW;
+alias WINAPI.ImmGetContext ImmGetContext;
+alias WINAPI.ImmGetConversionStatus ImmGetConversionStatus;
+alias WINAPI.ImmGetDefaultIMEWnd ImmGetDefaultIMEWnd;
+alias WINAPI.ImmGetOpenStatus ImmGetOpenStatus;
+alias WINAPI.ImmReleaseContext ImmReleaseContext;
+alias WINAPI.ImmSetCompositionFontA ImmSetCompositionFontA;
+alias WINAPI.ImmSetCompositionFontW ImmSetCompositionFontW;
+alias WINAPI.ImmSetCompositionWindow ImmSetCompositionWindow;
+alias WINAPI.ImmSetConversionStatus ImmSetConversionStatus;
+alias WINAPI.ImmSetOpenStatus ImmSetOpenStatus;
+alias WINAPI.InitCommonControls InitCommonControls;
+alias WINAPI.InitCommonControlsEx InitCommonControlsEx;
+alias WINAPI.InsertMenuA InsertMenuA;
+alias WINAPI.InsertMenuItemA InsertMenuItemA;
+alias WINAPI.InsertMenuItemW InsertMenuItemW;
+alias WINAPI.InsertMenuW InsertMenuW;
+alias WINAPI.InterlockedDecrement InterlockedDecrement;
+alias WINAPI.InterlockedIncrement InterlockedIncrement;
+alias WINAPI.IntersectRect IntersectRect;
+alias WINAPI.InvalidateRect InvalidateRect;
+alias WINAPI.InvalidateRgn InvalidateRgn;
+alias WINAPI.IsDBCSLeadByte IsDBCSLeadByte;
+alias WINAPI.IsIconic IsIconic;
+alias WINAPI.IsWindow IsWindow;
+alias WINAPI.IsWindowEnabled IsWindowEnabled;
+alias WINAPI.IsWindowVisible IsWindowVisible;
+alias WINAPI.IsZoomed IsZoomed;
+alias WINAPI.KillTimer KillTimer;
+alias WINAPI.LineTo LineTo;
+alias WINAPI.LoadBitmapA LoadBitmapA;
+alias WINAPI.LoadBitmapW LoadBitmapW;
+alias WINAPI.LoadCursorA LoadCursorA;
+alias WINAPI.LoadCursorW LoadCursorW;
+alias WINAPI.LoadIconA LoadIconA;
+alias WINAPI.LoadIconW LoadIconW;
+alias WINAPI.LoadImageA LoadImageA;
+alias WINAPI.LoadImageW LoadImageW;
+alias WINAPI.LoadLibraryA LoadLibraryA;
+alias WINAPI.LoadLibraryW LoadLibraryW;
+alias WINAPI.LoadResource LoadResource;
+alias WINAPI.LoadStringA LoadStringA;
+alias WINAPI.LoadStringW LoadStringW;
+alias WINAPI.LocalFree LocalFree;
+alias WINAPI.LockResource LockResource;
+alias WINAPI.MapVirtualKeyA MapVirtualKeyA;
+alias WINAPI.MapVirtualKeyW MapVirtualKeyW;
+alias WINAPI.MapWindowPoints MapWindowPoints;
+alias WINAPI.MessageBeep MessageBeep;
+alias WINAPI.MessageBoxA MessageBoxA;
+alias WINAPI.MessageBoxW MessageBoxW;
+alias WINAPI.MonitorFromWindow MonitorFromWindow;
+alias WINAPI.MoveToEx MoveToEx;
+alias WINAPI.MsgWaitForMultipleObjectsEx MsgWaitForMultipleObjectsEx;
+alias WINAPI.MultiByteToWideChar MultiByteToWideChar;
+alias WINAPI.NotifyWinEvent NotifyWinEvent;
+alias WINAPI.OffsetRgn OffsetRgn;
+//alias WINAPI.OleInitialize OleInitialize;
+//alias WINAPI.OleUninitialize OleUninitialize;
+alias WINAPI.OpenClipboard OpenClipboard;
+alias WINAPI.OutputDebugStringA OutputDebugStringA;
+alias WINAPI.OutputDebugStringW OutputDebugStringW;
+alias WINAPI.PatBlt PatBlt;
+alias WINAPI.PeekMessageA PeekMessageA;
+alias WINAPI.PeekMessageW PeekMessageW;
+alias WINAPI.Pie Pie;
+alias WINAPI.Polygon Polygon;
+alias WINAPI.Polyline Polyline;
+alias WINAPI.PostMessageA PostMessageA;
+alias WINAPI.PostMessageW PostMessageW;
+alias WINAPI.PostThreadMessageA PostThreadMessageA;
+alias WINAPI.PostThreadMessageW PostThreadMessageW;
+alias WINAPI.PrintDlgA PrintDlgA;
+alias WINAPI.PrintDlgW PrintDlgW;
+alias WINAPI.PtInRect PtInRect;
+alias WINAPI.PtInRegion PtInRegion;
+alias WINAPI.RealizePalette RealizePalette;
+alias WINAPI.RectInRegion RectInRegion;
+// <Shawn> Renamed : may conflict with dwt.graphics.rectangle.Rectangle
+alias WINAPI.Rectangle _Rectangle;  
+alias WINAPI.RedrawWindow RedrawWindow;
+alias WINAPI.RegCloseKey RegCloseKey;
+alias WINAPI.RegEnumKeyExA RegEnumKeyExA;
+alias WINAPI.RegEnumKeyExW RegEnumKeyExW;
+alias WINAPI.RegOpenKeyExA RegOpenKeyExA;
+alias WINAPI.RegOpenKeyExW RegOpenKeyExW;
+alias WINAPI.RegQueryInfoKeyA RegQueryInfoKeyA;
+alias WINAPI.RegQueryInfoKeyW RegQueryInfoKeyW;
+alias WINAPI.RegQueryValueExA RegQueryValueExA;
+alias WINAPI.RegQueryValueExW RegQueryValueExW;
+alias WINAPI.RegisterClassA RegisterClassA;
+alias WINAPI.RegisterClassW RegisterClassW;
+alias WINAPI.RegisterClipboardFormatA RegisterClipboardFormatA;
+alias WINAPI.RegisterClipboardFormatW RegisterClipboardFormatW;
+alias WINAPI.RegisterWindowMessageA RegisterWindowMessageA;
+alias WINAPI.RegisterWindowMessageW RegisterWindowMessageW;
+alias WINAPI.ReleaseCapture ReleaseCapture;
+alias WINAPI.ReleaseDC ReleaseDC;
+alias WINAPI.RemoveMenu RemoveMenu;
+alias WINAPI.RestoreDC RestoreDC;
+alias WINAPI.RoundRect RoundRect;
+alias WINAPI.RtlMoveMemory MoveMemory;
+alias WINAPI.SHBrowseForFolderA SHBrowseForFolderA;
+alias WINAPI.SHBrowseForFolderW SHBrowseForFolderW;
+version(WinCE){
+    alias WINAPI.SHCreateMenuBar SHCreateMenuBar;
+}
+alias WINAPI.SHGetMalloc SHGetMalloc;
+alias WINAPI.SHGetPathFromIDListA SHGetPathFromIDListA;
+alias WINAPI.SHGetPathFromIDListW SHGetPathFromIDListW;
+version(WinCE)
+{
+    alias WINAPI.SHHandleWMSettingChange SHHandleWMSettingChange;
+    alias WINAPI.SHRecognizeGesture SHRecognizeGesture;
+    alias WINAPI.SHSendBackToFocusWindow SHSendBackToFocusWindow;
+    alias WINAPI.SHSetAppKeyWndAssoc SHSetAppKeyWndAssoc;
+    alias WINAPI.SHSipPreference SHSipPreference;
+}
+alias WINAPI.SaveDC SaveDC;
+alias WINAPI.ScreenToClient ScreenToClient;
+alias WINAPI.ScriptBreak ScriptBreak;
+alias WINAPI.ScriptCPtoX ScriptCPtoX;
+alias WINAPI.ScriptCacheGetHeight ScriptCacheGetHeight;
+alias WINAPI.ScriptFreeCache ScriptFreeCache;
+alias WINAPI.ScriptGetFontProperties ScriptGetFontProperties;
+alias WINAPI.ScriptGetLogicalWidths ScriptGetLogicalWidths;
+alias WINAPI.ScriptGetProperties ScriptGetProperties;
+alias WINAPI.ScriptItemize ScriptItemize;
+alias WINAPI.ScriptLayout ScriptLayout;
+alias WINAPI.ScriptPlace ScriptPlace;
+alias WINAPI.ScriptShape ScriptShape;
+alias WINAPI.ScriptTextOut ScriptTextOut;
+alias WINAPI.ScriptXtoCP ScriptXtoCP;
+alias WINAPI.ScrollWindowEx ScrollWindowEx;
+alias WINAPI.SelectClipRgn SelectClipRgn;
+alias WINAPI.SelectObject SelectObject;
+alias WINAPI.SelectPalette SelectPalette;
+alias WINAPI.SendInput SendInput;
+alias WINAPI.SendMessageA SendMessageA;
+alias WINAPI.SendMessageW SendMessageW;
+alias WINAPI.SetActiveWindow SetActiveWindow;
+alias WINAPI.SetBkColor SetBkColor;
+alias WINAPI.SetBkMode SetBkMode;
+alias WINAPI.SetCapture SetCapture;
+alias WINAPI.SetCaretPos SetCaretPos;
+alias WINAPI.SetClipboardData SetClipboardData;
+alias WINAPI.SetCursor SetCursor;
+alias WINAPI.SetCursorPos SetCursorPos;
+alias WINAPI.SetDIBColorTable SetDIBColorTable;
+alias WINAPI.SetErrorMode SetErrorMode;
+alias WINAPI.SetEvent SetEvent;
+alias WINAPI.SetFocus SetFocus;
+alias WINAPI.SetForegroundWindow SetForegroundWindow;
+alias WINAPI.SetLastError SetLastError;
+alias WINAPI.SetLayout SetLayout;
+alias WINAPI.SetMenu SetMenu;
+alias WINAPI.SetMenuDefaultItem SetMenuDefaultItem;
+alias WINAPI.SetMenuInfo SetMenuInfo;
+alias WINAPI.SetMenuItemInfoA SetMenuItemInfoA;
+alias WINAPI.SetMenuItemInfoW SetMenuItemInfoW;
+alias WINAPI.SetPaletteEntries SetPaletteEntries;
+alias WINAPI.SetParent SetParent;
+alias WINAPI.SetPixel SetPixel;
+alias WINAPI.SetROP2 SetROP2;
+alias WINAPI.SetRect SetRect;
+alias WINAPI.SetRectRgn SetRectRgn;
+alias WINAPI.SetScrollInfo SetScrollInfo;
+alias WINAPI.SetStretchBltMode SetStretchBltMode;
+alias WINAPI.SetTextAlign SetTextAlign;
+alias WINAPI.SetTextColor SetTextColor;
+alias WINAPI.SetTimer SetTimer;
+alias WINAPI.SetWindowLongA SetWindowLongA;
+alias WINAPI.SetWindowLongW SetWindowLongW;
+alias WINAPI.SetWindowPlacement SetWindowPlacement;
+alias WINAPI.SetWindowPos SetWindowPos;
+alias WINAPI.SetWindowRgn SetWindowRgn;
+alias WINAPI.SetWindowTextA SetWindowTextA;
+alias WINAPI.SetWindowTextW SetWindowTextW;
+alias WINAPI.SetWindowsHookExA SetWindowsHookExA;
+alias WINAPI.SetWindowsHookExW SetWindowsHookExW;
+alias WINAPI.ShellExecuteExA ShellExecuteExA;
+alias WINAPI.ShellExecuteExW ShellExecuteExW;
+alias WINAPI.Shell_NotifyIconA Shell_NotifyIconA;
+alias WINAPI.Shell_NotifyIconW Shell_NotifyIconW;
+alias WINAPI.ShowCaret ShowCaret;
+alias WINAPI.ShowOwnedPopups ShowOwnedPopups;
+alias WINAPI.ShowScrollBar ShowScrollBar;
+alias WINAPI.ShowWindow ShowWindow;
+version(WinCE){
+alias WINAPI.SipGetInfo SipGetInfo;
+}
+alias WINAPI.SizeofResource SizeofResource;
+alias WINAPI.Sleep Sleep;
+alias WINAPI.StartDocA StartDocA;
+alias WINAPI.StartDocW StartDocW;
+alias WINAPI.StartPage StartPage;
+alias WINAPI.StretchBlt StretchBlt;
+alias WINAPI.SystemParametersInfoA SystemParametersInfoA;
+alias WINAPI.SystemParametersInfoW SystemParametersInfoW;
+alias WINAPI.ToAscii ToAscii;
+alias WINAPI.ToUnicode ToUnicode;
+alias WINAPI.TrackMouseEvent TrackMouseEvent;
+alias WINAPI.TrackPopupMenu TrackPopupMenu;
+alias WINAPI.TranslateAcceleratorA TranslateAcceleratorA;
+alias WINAPI.TranslateAcceleratorW TranslateAcceleratorW;
+alias WINAPI.TranslateCharsetInfo TranslateCharsetInfo;
+alias WINAPI.TranslateMDISysAccel TranslateMDISysAccel;
+alias WINAPI.TranslateMessage TranslateMessage;
+version(WinCE){
+    alias WINAPI.TransparentImage TransparentImage;
+}
+alias WINAPI.UnhookWindowsHookEx UnhookWindowsHookEx;
+alias WINAPI.UnregisterClassA UnregisterClassA;
+alias WINAPI.UnregisterClassW UnregisterClassW;
+alias WINAPI.UpdateWindow UpdateWindow;
+alias WINAPI.ValidateRect ValidateRect;
+alias WINAPI.VkKeyScanA VkKeyScanA;
+alias WINAPI.VkKeyScanW VkKeyScanW;
+alias WINAPI.WaitForMultipleObjects WaitForMultipleObjects;
+alias WINAPI.WaitForSingleObject WaitForSingleObject;
+alias WINAPI.WaitMessage WaitMessage;
+alias WINAPI.WideCharToMultiByte WideCharToMultiByte;
+alias WINAPI.WindowFromDC WindowFromDC;
+alias WINAPI.WindowFromPoint WindowFromPoint;
+alias WINAPI.wcslen wcslen;
+
+public static int VERSION (int major, int minor) {  return major << 16 | minor;}
+
+//static int DrawText(int hDC, String lpString, RECT* lpRect, int uFormat){
+//  return WINAPI.DrawText(hDC, Convert.StringToTCHARz(lpString), lpString.length, lpRect, uFormat);
+//}
+//
+//static int DrawText(int hDC, TCHAR* lpString, int length, RECT* lpRect, int uFormat){
+//  return WINAPI.DrawText(hDC, lpString, length, lpRect, uFormat);
+//}
+
+static int GetProfileString(char[] lpAppName, char[] lpKeyName, char[] lpDefault, out char[] lpReturnedString, int nSize ){
+    TCHAR[] buffer = new TCHAR[nSize];
+    int result = _GetProfileString(.StrToTCHARz(lpAppName), .StrToTCHARz(lpKeyName), .StrToTCHARz(lpDefault), buffer.ptr, nSize);
+    lpReturnedString = .TCHARzToStr(buffer.ptr);
+    return result;  
+}
+
+static char[] GetWindowText(HWND hwnd){
+    assert(hwnd); 
+    int len = GetWindowTextLength(hwnd);
+    if(len > 0){
+        TCHAR[] buffer = new TCHAR[len + 1];
+        len = _GetWindowText(hwnd, buffer.ptr, buffer.length);
+        return .TCHARzToStr(buffer.ptr, len);
+    }
+    return "";
+}
+
+// Note: nMaxCount including the NULL character
+static int GetWindowText(HWND hWnd, TCHAR* lpString, int nMaxCount)
+{
+    return _GetWindowText(hWnd, lpString, nMaxCount);
+}
+
+// <Shawn Liu> added this method, copied from ATL : atlwin.h 
+static int CenterWindow(HWND m_hWnd, HWND hWndCenter = null)
+{
+    assert(m_hWnd);
+    
+    // determine owner window to center against
+    uint dwStyle = OS.GetWindowLong(m_hWnd, OS.GWL_STYLE);
+    if(hWndCenter is null)
+    {
+        if(dwStyle & OS.WS_CHILD)
+            hWndCenter = OS.GetParent(m_hWnd);
+        else
+            hWndCenter = OS.GetWindow(m_hWnd, OS.GW_OWNER);
+    }
+
+    // get coordinates of the window relative to its parent
+    RECT rcDlg;
+    OS.GetWindowRect(m_hWnd, &rcDlg);
+    RECT rcArea;
+    RECT rcCenter;
+    HWND hWndParent;
+    if(!(dwStyle & OS.WS_CHILD))
+    {
+        // don't center against invisible or minimized WINAPI 
+        if(hWndCenter !is null)
+        {
+            uint dwStyleCenter = OS.GetWindowLong(hWndCenter, OS.GWL_STYLE);
+            if(!(dwStyleCenter & OS.WS_VISIBLE) || (dwStyleCenter & OS.WS_MINIMIZE))
+                hWndCenter = null;
+        }
+
+        // center within screen coordinates
+        OS.SystemParametersInfo(OS.SPI_GETWORKAREA, 0, &rcArea, 0);
+        if(hWndCenter is null)
+            rcCenter = rcArea;
+        else
+            OS.GetWindowRect(hWndCenter, &rcCenter);
+    }
+    else
+    {
+        // center within parent client coordinates
+        hWndParent = OS.GetParent(m_hWnd);
+        assert(OS.IsWindow(hWndParent));
+
+        OS.GetClientRect(hWndParent, &rcArea);
+        assert(OS.IsWindow(hWndCenter));
+        OS.GetClientRect(hWndCenter, &rcCenter);
+        OS.MapWindowPoints(hWndCenter, hWndParent, cast(POINT*)&rcCenter, 2);
+    }
+
+    int DlgWidth = rcDlg.right - rcDlg.left;
+    int DlgHeight = rcDlg.bottom - rcDlg.top;
+
+    // find dialog's upper left based on rcCenter
+    int xLeft = (rcCenter.left + rcCenter.right) / 2 - DlgWidth / 2;
+    int yTop = (rcCenter.top + rcCenter.bottom) / 2 - DlgHeight / 2;
+
+    // if the dialog is outside the screen, move it inside
+    if(xLeft < rcArea.left)
+        xLeft = rcArea.left;
+    else if(xLeft + DlgWidth > rcArea.right)
+        xLeft = rcArea.right - DlgWidth;
+
+    if(yTop < rcArea.top)
+        yTop = rcArea.top;
+    else if(yTop + DlgHeight > rcArea.bottom)
+        yTop = rcArea.bottom - DlgHeight;
+
+    // map screen coordinates to child coordinates
+    return OS.SetWindowPos(m_hWnd, null, xLeft, yTop, -1, -1,
+        OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE);   
+}
+
+static int OleInitialize(LPVOID reserved = null){
+    return WINAPI.OleInitialize(reserved);
+}
+
+static void OleUninitialize(){
+    WINAPI.OleUninitialize();
+}
+
+} // END of OS
+
+private import tango.sys.win32.CodePage;
+private import tango.text.convert.Utf;
+private import tango.stdc.stringz;
+
+// convert UTF-8 to MBCS
+alias StrToMBCS StrToMBCSs;
+public char[] StrToMBCS(char[] sc, uint codepage = 0) {
+    char[] ret = sc;
+    try{
+        foreach (char c; sc){
+            if (c >= 0x80)
+            { 
+                char[] result;
+                int i;
+                wchar[] ws = .toString16(sc);
+                result.length = OS.WideCharToMultiByte(codepage, 0, ws.ptr, ws.length, null, 0, null, null);
+                i = OS.WideCharToMultiByte(codepage, 0, ws.ptr, ws.length, result.ptr, result.length, null, null);
+                assert(i == result.length);
+                return result;
+            }
+        }
+    }catch(Exception e){
+        // do nothing
+        ret = "";
+    }
+    return ret;
+}
+
+// convert UTF-8 to MBCSz
+public char* StrToMBCSz(char[] sc) {
+    char* ret = null;
+    try{
+        if( CodePage.isAscii( sc )){
+            return .toStringz( sc );
+        }
+        char[] dst;
+        dst.length = sc.length;
+        return toStringz( tango.sys.win32.CodePage.CodePage.into( sc, dst ));
+    }catch(Exception e){
+        // do nothing
+        ret = "";
+    }
+
+    return ret;
+}
+
+public wchar[] StrToWCHARs(char[] sc) {
+    wchar[] ret;
+    try{
+        ret = toString16(sc);
+    }catch(Exception e){
+        // do nothing
+        ret = "";           
+    }
+
+    return ret;
+}
+
+public wchar* StrToWCHARz(char[] sc) {
+    return toString16z( StrToWCHARs(sc));
+}
+
+public char[] MBCSsToStr(char[] string, uint codepage = 0){
+    return MBCSzToStr( string.ptr, string.length, codepage);
+}
+
+public char[] MBCSzToStr(char* pString, int _length = -1, uint codepage = 0) {
+    // null terminated string pointer
+    if(_length == -1){
+        _length = 0;
+        while(*(pString + _length))
+            ++_length; 
+    }
+    // convert MBCS to UTF-8
+    if(_length == 0)
+        return null;
+        
+    wchar[] wcs = _mbcszToWs(pString, _length, codepage);
+    char[] result;
+    try{
+        result = .toString(wcs);   
+    }catch(Exception e){
+    }
+    return result;
+}
+
+public char[] WCHARsToStr(wchar[] string){
+    return WCHARzToStr(cast(wchar*)string, string.length);
+}
+
+public char[] WCHARzToStr(wchar* pString, int _length = -1)
+{
+    // null terminated string pointer
+    if(_length == -1){
+        _length = 0;
+        while(*(pString + _length))
+            ++_length; 
+    }
+    if(_length == 0)
+        return null;
+    // convert wchar* to UTF-8
+    wchar[] wcs = pString[0.._length];
+    
+    char[] result;
+    try{
+        result = .toString(wcs);
+    }catch(Exception e){
+        // do nothing
+    }
+    return result;
+}
+
+/** 
+ * <Shawn> difference between WCHARzToStr(pwstr, -1) :
+ * BSTRToStr() internally call WCHARzToStr(pwstr, length) with length set, 
+ * instead to determine the null ended, this mean BSTRToStr() can get string 
+ * which has embedded null characters.
+ */
+
+version(OLE_COM)
+{ 
+// BSTR is aliased to wchar* 
+// Note : Free the "bstr" memory if freeTheString is true, default false
+static char[] BSTRToStr(/*BSTR*/ inout wchar* bstr, bool freeTheString = false){
+    if(bstr is null) return null;
+    int size = (SysStringByteLen(bstr) + 1)/wchar.sizeof;
+    char[] result = WCHARzToStr(bstr, size);
+    if(freeTheString) {
+        // free the string and set ptr to null
+        SysFreeString(bstr);
+        bstr = null;
+    }
+    return result;
+}
+} // end of OLE_COM
+
+
+public static wchar[] _mbcszToWs(char* pMBCS, int len, uint codepage = 0)
+{
+    wchar[] wbuf;
+    // Convert MBCS to unicode              
+    wbuf.length = OS.MultiByteToWideChar(codepage, 0, pMBCS, len, null, 0);
+    int n = OS.MultiByteToWideChar(codepage, 0, pMBCS, len, wbuf.ptr, wbuf.length);
+    assert(n == wbuf.length);
+    return wbuf;
+}   
+
+// static methods
+public int _tcslen(TCHAR* pString){
+    int _length = 0;
+    while(*(pString + _length))
+        ++_length; 
+    
+    return _length;     
+}
+
+/**
+ * There is a bug in Phobos std.string.toupper() to lower() with 
+ std.string.toupper() and std.string.tolower() give a wrong result when deal with a mixture of upper/lower English and Chinese characters. e.g.
+char[] a = "AbCd中文eFgH";
+char[] b = std.string.toupper(a);
+char[] c = std.string.tolower(a);
+The length of a is 11, but the length of b,c is 18 now.
+ *
+ */
+public char[] tolower(char[] string) {
+    TCHAR* ps = StrToTCHARz(string);
+    TCHAR* ps2 = OS.CharLower(ps);
+    return TCHARzToStr(ps2);
+}
+public char[] toupper(char[] string) {
+    TCHAR* ps = StrToTCHARz(string);
+    TCHAR* ps2 = OS.CharUpper(ps);
+    return TCHARzToStr(ps2);
+}
+    
+version(ANSI){
+    alias StrToMBCS         StrToTCHARs;
+    alias StrToMBCSz        StrToTCHARz;
+    alias MBCSzToStr        TCHARzToStr;
+    alias MBCSsToStr        TCHARsToStr;
+}else{
+    // Unicode
+    alias StrToWCHARs       StrToTCHARs;
+    alias StrToWCHARz       StrToTCHARz;
+    alias WCHARzToStr       TCHARzToStr;
+    alias WCHARsToStr       TCHARsToStr;
+}
+
+
+//alias Converter.StrToTCHARs     StrToTCHARs;
+//alias Converter.StrToTCHARz     StrToTCHARz;
+//alias Converter.TCHARzToStr     TCHARzToStr;
+//alias Converter.TCHARsToStr     TCHARsToStr;
+
+
+
+
--- a/dwt/internal/win32/WINAPI.d	Fri Jan 25 14:23:28 2008 +0100
+++ b/dwt/internal/win32/WINAPI.d	Fri Jan 25 19:16:45 2008 +0100
@@ -6,7 +6,7 @@
 
 module dwt.internal.win32.WINAPI;
 
-import dwt.internal.win32.WINTYPES;
+public import dwt.internal.win32.WINTYPES;
 import tango.sys.win32.Types;
 import STDWIN = tango.sys.win32.UserGdi;