changeset 167:49d8d2e0faba

merge
author Frank Benoit <benoit@tionex.de>
date Thu, 21 Feb 2008 17:55:01 +0100
parents 19a760bfd55f (current diff) cd28aa5221a3 (diff)
children 219551956439
files dwt/internal/win32/OS.d
diffstat 5 files changed, 184 insertions(+), 170 deletions(-) [+]
line wrap: on
line diff
--- a/dwt/internal/win32/OS.d	Thu Feb 21 15:20:42 2008 +0100
+++ b/dwt/internal/win32/OS.d	Thu Feb 21 17:55:01 2008 +0100
@@ -726,7 +726,7 @@
     public static const int CS_HREDRAW = 0x2;
     public static const int CS_VREDRAW = 0x1;
     public static const int CW_USEDEFAULT = 0x80000000;
-    public static const char[] DATETIMEPICK_CLASS = "SysDateTimePick32"; //$NON-NLS-1$
+    public static const TCHAR[] DATETIMEPICK_CLASS = "SysDateTimePick32"; //$NON-NLS-1$
     public static const int DATE_LONGDATE = 0x00000002;
     public static const int DATE_SHORTDATE = 0x00000001;
     public static const int DATE_YEARMONTH = 0x00000008; //#if(WINVER >= 0x0500)
@@ -1334,7 +1334,7 @@
     public static const int MNS_CHECKORBMP = 0x4000000;
     public static const int MONITOR_DEFAULTTONEAREST = 0x2;
     public static const int MONITORINFOF_PRIMARY = 0x1;
-    public static const char[] MONTHCAL_CLASS = "SysMonthCal32"; //$NON-NLS-1$
+    public static const TCHAR[] MONTHCAL_CLASS = "SysMonthCal32"; //$NON-NLS-1$
     public static const int MOUSEEVENTF_ABSOLUTE = 0x8000;
     public static const int MOUSEEVENTF_LEFTDOWN = 0x0002;
     public static const int MOUSEEVENTF_LEFTUP = 0x0004;
@@ -4029,6 +4029,8 @@
     alias WINAPI.GetClassInfoA GetClassInfo;
     alias WINAPI.GetClassNameA GetClassName;
     alias WINAPI.GetClipboardFormatNameA GetClipboardFormatName;
+    alias WINAPI.GetDateFormatA GetDateFormat;
+    alias WINAPI.GetTimeFormatA GetTimeFormat;
     alias WINAPI.GetKeyNameTextA GetKeyNameText;
     alias WINAPI.GetLocaleInfoA GetLocaleInfo;
     alias WINAPI.GetMenuItemInfoA GetMenuItemInfo;
@@ -4128,6 +4130,8 @@
     alias WINAPI.GetClassInfoW GetClassInfo;
     alias WINAPI.GetClassNameW GetClassName;
     alias WINAPI.GetClipboardFormatNameW GetClipboardFormatName;
+    alias WINAPI.GetDateFormatW GetDateFormat;
+    alias WINAPI.GetTimeFormatW GetTimeFormat;
     alias WINAPI.GetKeyNameTextW GetKeyNameText;
     alias WINAPI.GetLocaleInfoW GetLocaleInfo;
     alias WINAPI.GetMenuItemInfoW GetMenuItemInfo;
--- a/dwt/internal/win32/WINAPI.d	Thu Feb 21 15:20:42 2008 +0100
+++ b/dwt/internal/win32/WINAPI.d	Thu Feb 21 17:55:01 2008 +0100
@@ -339,8 +339,8 @@
 //     int LCMapStringA(LCID, DWORD, LPCSTR, int, LPSTR, int);
 //     int GetLocaleInfoA(LCID, LCTYPE, LPSTR, int);
 //     WINBOOL SetLocaleInfoA(LCID, LCTYPE, LPCSTR);
-//     int GetTimeFormatA(LCID, DWORD, LPSYSTEMTIME, LPCSTR, LPSTR, int);
-//     int GetDateFormatA(LCID, DWORD, LPSYSTEMTIME, LPCSTR, LPSTR, int);
+     int GetTimeFormatA(LCID, DWORD, LPSYSTEMTIME, LPCSTR, LPSTR, int);
+     int GetDateFormatA(LCID, DWORD, LPSYSTEMTIME, LPCSTR, LPSTR, int);
 //     int GetNumberFormatA(LCID, DWORD, LPCSTR, PNUMBERFMT, LPSTR, int);
 //     int GetCurrencyFormatA(LCID, DWORD, LPCSTR, PCURRENCYFMT, LPSTR, int);
 //     WINBOOL EnumCalendarInfoA(CALINFO_ENUMPROC, LCID, CALID, CALTYPE);
@@ -732,8 +732,8 @@
 //     int LCMapStringW(LCID, DWORD, LPCWSTR, int, LPWSTR, int);
 //     int GetLocaleInfoW(LCID, LCTYPE, LPWSTR, int);
 //     WINBOOL SetLocaleInfoW(LCID, LCTYPE, LPCWSTR);
-//     int GetTimeFormatW(LCID, DWORD, LPSYSTEMTIME, LPCWSTR, LPWSTR, int);
-//     int GetDateFormatW(LCID, DWORD, LPSYSTEMTIME, LPCWSTR, LPWSTR, int);
+     int GetTimeFormatW(LCID, DWORD, LPSYSTEMTIME, LPCWSTR, LPWSTR, int);
+     int GetDateFormatW(LCID, DWORD, LPSYSTEMTIME, LPCWSTR, LPWSTR, int);
 //     int GetNumberFormatW(LCID, DWORD, LPCWSTR, PNUMBERFMT, LPWSTR, int);
 //     int GetCurrencyFormatW(LCID, DWORD, LPCWSTR, PCURRENCYFMT, LPWSTR, int);
 //     WINBOOL EnumCalendarInfoW(CALINFO_ENUMPROC, LCID, CALID, CALTYPE);
--- a/dwt/widgets/Composite.d	Thu Feb 21 15:20:42 2008 +0100
+++ b/dwt/widgets/Composite.d	Thu Feb 21 17:55:01 2008 +0100
@@ -1571,6 +1571,7 @@
                     int length_ = string.length;
                     char [] chars = new char [length_ + 1];
                     string.getChars (0, length_, chars, 0);
+                    chars[$-1] = 0; // d initialize it to 0xFF, we need to make it null terminated
 
                     /*
                     * Ensure that the orientation of the tool tip matches
--- a/dwt/widgets/DateTime.d	Thu Feb 21 15:20:42 2008 +0100
+++ b/dwt/widgets/DateTime.d	Thu Feb 21 17:55:01 2008 +0100
@@ -14,22 +14,18 @@
 
 import dwt.widgets.Composite;
 
-class DateTime : Composite {
-}
-/++
 import dwt.DWT;
 import dwt.DWTException;
 import dwt.events.SelectionEvent;
 import dwt.events.SelectionListener;
 import dwt.graphics.Point;
-import dwt.internal.win32.INITCOMMONCONTROLSEX;
-import dwt.internal.win32.LRESULT;
-import dwt.internal.win32.NMHDR;
 import dwt.internal.win32.OS;
-import dwt.internal.win32.RECT;
-import dwt.internal.win32.SYSTEMTIME;
-import dwt.internal.win32.TCHAR;
-import dwt.internal.win32.WNDCLASS;
+
+import dwt.widgets.TypedListener;
+
+import dwt.dwthelper.utils;
+
+import Integer = tango.text.convert.Integer;
 
 //TODO - features not yet implemented: read-only, drop-down calendar for date
 //TODO - font, colors, background image not yet implemented (works on some platforms)
@@ -58,44 +54,56 @@
  * @since 3.3
  */
 
-public class DateTime extends Composite {
+public class DateTime : Composite {
 
     alias Composite.computeSize computeSize;
     alias Composite.windowProc windowProc;
 
-    static final int DateTimeProc;
-    static final TCHAR DateTimeClass = new TCHAR (0, OS.DATETIMEPICK_CLASS, true);
-    static final int CalendarProc;
-    static final TCHAR CalendarClass = new TCHAR (0, OS.MONTHCAL_CLASS, true);
-    static {
-        INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX ();
-        icex.dwSize = INITCOMMONCONTROLSEX.sizeof;
-        icex.dwICC = OS.ICC_DATE_CLASSES;
-        OS.InitCommonControlsEx (icex);
-        WNDCLASS lpWndClass = new WNDCLASS ();
-        OS.GetClassInfo (0, DateTimeClass, lpWndClass);
-        DateTimeProc = lpWndClass.lpfnWndProc;
-        OS.GetClassInfo (0, CalendarClass, lpWndClass);
-        CalendarProc = lpWndClass.lpfnWndProc;
+    static /+const+/ WNDPROC DateTimeProc;
+    static const TCHAR* DateTimeClass = OS.DATETIMEPICK_CLASS.ptr;
+    static /+const+/ WNDPROC CalendarProc;
+    static const TCHAR* CalendarClass = OS.MONTHCAL_CLASS.ptr;
+
+    private static bool static_this_completed = false;
+    private static void static_this() {
+        if( static_this_completed ){
+            return;
+        }
+        synchronized {
+            if( static_this_completed ){
+                return;
+            }
+            INITCOMMONCONTROLSEX icex;
+            icex.dwSize = INITCOMMONCONTROLSEX.sizeof;
+            icex.dwICC = OS.ICC_DATE_CLASSES;
+            OS.InitCommonControlsEx (&icex);
+            WNDCLASS lpWndClass;
+            OS.GetClassInfo (null, DateTimeClass, &lpWndClass);
+            DateTimeProc = lpWndClass.lpfnWndProc;
+            OS.GetClassInfo (null, CalendarClass, &lpWndClass);
+            CalendarProc = lpWndClass.lpfnWndProc;
+            static_this_completed = true;
+        }
     }
-    static final int MARGIN = 4;
-    static final int MAX_DIGIT = 9;
-    static final int MAX_DAY = 31;
-    static final int MAX_12HOUR = 12;
-    static final int MAX_24HOUR = 24;
-    static final int MAX_MINUTE = 60;
-    static final int MONTH_DAY_YEAR = 0;
-    static final int DAY_MONTH_YEAR = 1;
-    static final int YEAR_MONTH_DAY = 2;
-    static final char SINGLE_QUOTE = '\''; //$NON-NLS-1$ short date format may include quoted text
-    static final char DAY_FORMAT_CONSTANT = 'd'; //$NON-NLS-1$ 1-4 lowercase 'd's represent day
-    static final char MONTH_FORMAT_CONSTANT = 'M'; //$NON-NLS-1$ 1-4 uppercase 'M's represent month
-    static final char YEAR_FORMAT_CONSTANT = 'y'; //$NON-NLS-1$ 1-5 lowercase 'y's represent year
-    static final char HOURS_FORMAT_CONSTANT = 'h'; //$NON-NLS-1$ 1-2 upper or lowercase 'h's represent hours
-    static final char MINUTES_FORMAT_CONSTANT = 'm'; //$NON-NLS-1$ 1-2 lowercase 'm's represent minutes
-    static final char SECONDS_FORMAT_CONSTANT = 's'; //$NON-NLS-1$ 1-2 lowercase 's's represent seconds
-    static final char AMPM_FORMAT_CONSTANT = 't'; //$NON-NLS-1$ 1-2 lowercase 't's represent am/pm
-    static final int[] MONTH_NAMES = new int[] {OS.LOCALE_SMONTHNAME1, OS.LOCALE_SMONTHNAME2, OS.LOCALE_SMONTHNAME3, OS.LOCALE_SMONTHNAME4, OS.LOCALE_SMONTHNAME5, OS.LOCALE_SMONTHNAME6, OS.LOCALE_SMONTHNAME7, OS.LOCALE_SMONTHNAME8, OS.LOCALE_SMONTHNAME9, OS.LOCALE_SMONTHNAME10, OS.LOCALE_SMONTHNAME11, OS.LOCALE_SMONTHNAME12};
+
+    static const int MARGIN = 4;
+    static const int MAX_DIGIT = 9;
+    static const int MAX_DAY = 31;
+    static const int MAX_12HOUR = 12;
+    static const int MAX_24HOUR = 24;
+    static const int MAX_MINUTE = 60;
+    static const int MONTH_DAY_YEAR = 0;
+    static const int DAY_MONTH_YEAR = 1;
+    static const int YEAR_MONTH_DAY = 2;
+    static const char SINGLE_QUOTE = '\''; //$NON-NLS-1$ short date format may include quoted text
+    static const char DAY_FORMAT_CONSTANT = 'd'; //$NON-NLS-1$ 1-4 lowercase 'd's represent day
+    static const char MONTH_FORMAT_CONSTANT = 'M'; //$NON-NLS-1$ 1-4 uppercase 'M's represent month
+    static const char YEAR_FORMAT_CONSTANT = 'y'; //$NON-NLS-1$ 1-5 lowercase 'y's represent year
+    static const char HOURS_FORMAT_CONSTANT = 'h'; //$NON-NLS-1$ 1-2 upper or lowercase 'h's represent hours
+    static const char MINUTES_FORMAT_CONSTANT = 'm'; //$NON-NLS-1$ 1-2 lowercase 'm's represent minutes
+    static const char SECONDS_FORMAT_CONSTANT = 's'; //$NON-NLS-1$ 1-2 lowercase 's's represent seconds
+    static const char AMPM_FORMAT_CONSTANT = 't'; //$NON-NLS-1$ 1-2 lowercase 't's represent am/pm
+    static const int[] MONTH_NAMES = [OS.LOCALE_SMONTHNAME1, OS.LOCALE_SMONTHNAME2, OS.LOCALE_SMONTHNAME3, OS.LOCALE_SMONTHNAME4, OS.LOCALE_SMONTHNAME5, OS.LOCALE_SMONTHNAME6, OS.LOCALE_SMONTHNAME7, OS.LOCALE_SMONTHNAME8, OS.LOCALE_SMONTHNAME9, OS.LOCALE_SMONTHNAME10, OS.LOCALE_SMONTHNAME11, OS.LOCALE_SMONTHNAME12];
 
 
 /**
@@ -128,12 +136,13 @@
  * @see Widget#checkSubclass
  * @see Widget#getStyle
  */
-public DateTime (Composite parent, int style) {
+public this (Composite parent, int style) {
+    static_this();
     super (parent, checkStyle (style));
     if ((this.style & DWT.SHORT) !is 0) {
-        String buffer = ((this.style & DWT.DATE) !is 0) ? getCustomShortDateFormat() : getCustomShortTimeFormat();
-        TCHAR lpszFormat = new TCHAR (0, buffer, true);
-        OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat);
+        char[] buffer = ((this.style & DWT.DATE) !is 0) ? getCustomShortDateFormat() : getCustomShortTimeFormat();
+        TCHAR[] lpszFormat = StrToTCHARs (0, buffer, true);
+        OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat.ptr);
     }
 }
 
@@ -169,9 +178,9 @@
     addListener (DWT.DefaultSelection, typedListener);
 }
 
-override int callWindowProc (int hwnd, int msg, int wParam, int lParam) {
-    if (handle is 0) return 0;
-    return OS.CallWindowProc (windowProc (), hwnd, msg, wParam, lParam);
+override int callWindowProc (HWND hwnd, int msg, int wParam, int lParam) {
+    if (handle is null) return 0;
+    return OS.CallWindowProc ( cast(WNDPROC)windowProc(), hwnd, msg, wParam, lParam);
 }
 
 static int checkStyle (int style) {
@@ -196,33 +205,33 @@
     int width = 0, height = 0;
     if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) {
         if ((style & DWT.CALENDAR) !is 0) {
-            RECT rect = new RECT ();
-            OS.SendMessage(handle, OS.MCM_GETMINREQRECT, 0, rect);
+            RECT rect;
+            OS.SendMessage(handle, OS.MCM_GETMINREQRECT, 0, &rect);
             width = rect.right;
             height = rect.bottom;
         } else {
-            TCHAR buffer = new TCHAR (getCodePage (), 128);
-            int newFont, oldFont = 0;
-            int hDC = OS.GetDC (handle);
-            newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
-            if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont);
-            RECT rect = new RECT ();
+            TCHAR[] buffer = new TCHAR[128];
+            void* newFont = cast(void*)OS.SendMessage (handle, OS.WM_GETFONT, 0, 0), oldFont = null;
+            auto hDC = OS.GetDC (handle);
+//            newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+            if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont);
+            RECT rect;
             int flags = OS.DT_CALCRECT | OS.DT_EDITCONTROL | OS.DT_NOPREFIX;
-            SYSTEMTIME systime = new SYSTEMTIME ();
+            SYSTEMTIME systime;
             if ((style & DWT.DATE) !is 0) {
                 /* Determine the widest/tallest year string. */
                 systime.wMonth = 1;
                 systime.wDay = 1;
                 int widest = 0, secondWidest = 0, thirdWidest = 0;
                 for (int i = 0; i <= MAX_DIGIT; i++) {
-                    systime.wYear = (short) (2000 + i); // year 2000 + i is guaranteed to exist
-                    int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, systime, null, buffer, buffer.length ());
+                    systime.wYear = cast(short) (2000 + i); // year 2000 + i is guaranteed to exist
+                    int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, &systime, null, buffer.ptr, buffer.length);
                     if (size is 0) {
-                        buffer = new TCHAR (getCodePage (), size);
-                        OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, systime, null, buffer, buffer.length ());
+                        buffer = new TCHAR[size];
+                        OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, &systime, null, buffer.ptr, buffer.length);
                     }
                     rect.left = rect.top = rect.right = rect.bottom = 0;
-                    OS.DrawText (hDC, buffer, size, rect, flags);
+                    OS.DrawText (hDC, buffer.ptr, size, &rect, flags);
                     if (rect.right - rect.left >= width) {
                         width = rect.right - rect.left;
                         thirdWidest = secondWidest;
@@ -234,39 +243,39 @@
                 if (widest > 1) widest = widest * 1000 + widest * 100 + widest * 10 + widest;
                 else if (secondWidest > 1) widest = secondWidest * 1000 + widest * 100 + widest * 10 + widest;
                 else widest = thirdWidest * 1000 + widest * 100 + widest * 10 + widest;
-                systime.wYear = (short) widest;
+                systime.wYear = cast(short) widest;
 
                 /* Determine the widest/tallest month name string. */
                 width = widest = 0;
                 for (short i = 0; i < MONTH_NAMES.length; i++) {
                     int name = MONTH_NAMES [i];
-                    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer, buffer.length ());
+                    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer.ptr, buffer.length);
                     if (size is 0) {
-                        buffer = new TCHAR (getCodePage (), size);
-                        OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer, buffer.length ());
+                        buffer = new TCHAR[size];
+                        OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer.ptr, buffer.length);
                     }
                     rect.left = rect.top = rect.right = rect.bottom = 0;
-                    OS.DrawText (hDC, buffer, size, rect, flags);
+                    OS.DrawText (hDC, buffer.ptr, size, &rect, flags);
                     if (rect.right - rect.left > width) {
                         width = rect.right - rect.left;
                         widest = i;
                     }
                     height = Math.max(height, rect.bottom - rect.top);
                 }
-                systime.wMonth = (short) (widest + 1);
+                systime.wMonth = cast(short) (widest + 1);
 
                 /* Determine the widest/tallest date string in the widest month of the widest year. */
                 int dwFlags = ((style & DWT.MEDIUM) !is 0) ? OS.DATE_SHORTDATE : ((style & DWT.SHORT) !is 0) ? OS.DATE_YEARMONTH : OS.DATE_LONGDATE;
                 width = 0;
                 for (short i = 1; i <= MAX_DAY; i++) {
                     systime.wDay = i;
-                    int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());
+                    int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length);
                     if (size is 0) {
-                        buffer = new TCHAR (getCodePage (), size);
-                        OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());
+                        buffer = new TCHAR[size];
+                        OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length);
                     }
                     rect.left = rect.top = rect.right = rect.bottom = 0;
-                    OS.DrawText (hDC, buffer, size, rect, flags);
+                    OS.DrawText (hDC, buffer.ptr, size, &rect, flags);
                     width = Math.max(width, rect.right - rect.left);
                     height = Math.max(height, rect.bottom - rect.top);
                     if ((style & DWT.SHORT) !is 0) break;
@@ -278,13 +287,13 @@
                 int max = is24HourTime () ? MAX_24HOUR : MAX_12HOUR;
                 for (short i = 0; i < max; i++) {
                     systime.wHour = i;
-                    int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());
+                    int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length);
                     if (size is 0) {
-                        buffer = new TCHAR (getCodePage (), size);
-                        OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());
+                        buffer = new TCHAR[size];
+                        OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length);
                     }
                     rect.left = rect.top = rect.right = rect.bottom = 0;
-                    OS.DrawText (hDC, buffer, size, rect, flags);
+                    OS.DrawText (hDC, buffer.ptr, size, &rect, flags);
                     if (rect.right - rect.left > width) {
                         width = rect.right - rect.left;
                         widest = i;
@@ -297,13 +306,13 @@
                 width = widest = 0;
                 for (short i = 0; i < MAX_MINUTE; i++) {
                     systime.wMinute = i;
-                    int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());
+                    int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length);
                     if (size is 0) {
-                        buffer = new TCHAR (getCodePage (), size);
-                        OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());
+                        buffer = new TCHAR[size];
+                        OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length);
                     }
                     rect.left = rect.top = rect.right = rect.bottom = 0;
-                    OS.DrawText (hDC, buffer, size, rect, flags);
+                    OS.DrawText (hDC, buffer.ptr, size, &rect, flags);
                     if (rect.right - rect.left > width) {
                         width = rect.right - rect.left;
                         widest = i;
@@ -314,17 +323,17 @@
                 systime.wSecond = widest;
 
                 /* Determine the widest/tallest time string for the widest hour, widest minute, and if applicable, widest second. */
-                int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());
+                int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length);
                 if (size is 0) {
-                    buffer = new TCHAR (getCodePage (), size);
-                    OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ());
+                    buffer = new TCHAR[size];
+                    OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length);
                 }
                 rect.left = rect.top = rect.right = rect.bottom = 0;
-                OS.DrawText (hDC, buffer, size, rect, flags);
+                OS.DrawText (hDC, buffer.ptr, size, &rect, flags);
                 width = rect.right - rect.left;
                 height = Math.max(height, rect.bottom - rect.top);
             }
-            if (newFont !is 0) OS.SelectObject (hDC, oldFont);
+            if (newFont !is null) OS.SelectObject (hDC, oldFont);
             OS.ReleaseDC (handle, hDC);
             int upDownWidth = OS.GetSystemMetrics (OS.SM_CXVSCROLL);
             width += upDownWidth + MARGIN;
@@ -353,7 +362,7 @@
     return OS.GetSysColor (OS.COLOR_WINDOW);
 }
 
-String getComputeSizeString () {
+char[] getComputeSizeString () {
     // TODO: Not currently used but might need for WinCE
     if ((style & DWT.DATE) !is 0) {
         if ((style & DWT.SHORT) !is 0) return getCustomShortDateFormat ();
@@ -367,16 +376,16 @@
     return "";
 }
 
-String getCustomShortDateFormat () {
+char[] getCustomShortDateFormat () {
     if (true) {
-        TCHAR tchar = new TCHAR (getCodePage (), 80);
-        int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SYEARMONTH, tchar, 80);
-        return size !is 0 ? tchar.toString (0, size - 1) : "M/yyyy"; //$NON-NLS-1$
+        TCHAR[] tchar = new TCHAR[80];
+        int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SYEARMONTH, tchar.ptr, 80);
+        return size !is 0 ? TCHARsToStr(tchar[0..size - 1])  : "M/yyyy"; //$NON-NLS-1$
     }
 
     //TODO: Not currently used, but may need for WinCE (or if numeric short date is required)
-    StringBuffer buffer = new StringBuffer (getShortDateFormat ());
-    int length = buffer.length ();
+    char[] buffer = getShortDateFormat ();
+    int length = buffer.length;
     bool inQuotes = false;
     int start = 0, end = 0;
     while (start < length) {
@@ -405,13 +414,13 @@
         }
         start++;
     }
-    if (start < end) buffer.delete (start, end);
-    return buffer.toString ();
+    if (start < end) buffer.length = start - 1;
+    return buffer;
 }
 
-String getCustomShortTimeFormat () {
-    StringBuffer buffer = new StringBuffer (getTimeFormat ());
-    int length = buffer.length ();
+char[] getCustomShortTimeFormat () {
+    char[] buffer = getTimeFormat ();
+    int length = buffer.length;
     bool inQuotes = false;
     int start = 0, end = 0;
     while (start < length) {
@@ -427,48 +436,48 @@
         }
         start++;
     }
-    if (start < end) buffer.delete (start, end);
-    return buffer.toString ();
+    if (start < end) buffer.length = start - 1;
+    return buffer;
 }
 
-String getLongDateFormat () {
+char[] getLongDateFormat () {
     //TODO: Not currently used, but may need for WinCE
-    TCHAR tchar = new TCHAR (getCodePage (), 80);
-    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SLONGDATE, tchar, 80);
-    return size > 0 ? tchar.toString (0, size - 1) : "dddd, MMMM dd, yyyy"; //$NON-NLS-1$
+    TCHAR tchar[80];
+    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SLONGDATE, tchar.ptr, 80);
+    return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "dddd, MMMM dd, yyyy"; //$NON-NLS-1$
 }
 
-String getShortDateFormat () {
+char[] getShortDateFormat () {
     //TODO: Not currently used, but may need for WinCE
-    TCHAR tchar = new TCHAR (getCodePage (), 80);
+    TCHAR tchar[80];
     //TODO: May need to OR with LOCALE_ICENTURY
-    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SSHORTDATE, tchar, 80);
-    return size > 0 ? tchar.toString (0, size - 1) : "M/d/yyyy"; //$NON-NLS-1$
+    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SSHORTDATE, tchar.ptr, 80);
+    return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "M/d/yyyy"; //$NON-NLS-1$
 }
 
 int getShortDateFormatOrdering () {
     //TODO: Not currently used, but may need for WinCE
-    TCHAR tchar = new TCHAR (getCodePage (), 4);
-    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_IDATE, tchar, 4);
+    TCHAR tchar[80];
+    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_IDATE, tchar.ptr, 4);
     if (size > 0) {
-        String number = tchar.toString (0, size - 1);
-        return Integer.parseInt (number);
+        char[] number = TCHARsToStr(tchar[0..size - 1]);
+        return Integer.parse (number);
     }
     return 0;
 }
 
-String getTimeFormat () {
-    TCHAR tchar = new TCHAR (getCodePage (), 80);
-    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_STIMEFORMAT, tchar, 80);
-    return size > 0 ? tchar.toString (0, size - 1) : "h:mm:ss tt"; //$NON-NLS-1$
+char[] getTimeFormat () {
+    TCHAR tchar[80];
+    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_STIMEFORMAT, tchar.ptr, 80);
+    return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "h:mm:ss tt"; //$NON-NLS-1$
 }
 
 bool is24HourTime () {
-    TCHAR tchar = new TCHAR (getCodePage (), 4);
-    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_ITIME, tchar, 4);
+    TCHAR tchar[4];
+    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_ITIME, tchar.ptr, 4);
     if (size > 0) {
-        String number = tchar.toString (0, size - 1);
-        return Integer.parseInt (number) !is 0;
+        char[] number = TCHARsToStr(tchar[0..size - 1]);
+        return Integer.parse (number) !is 0;
     }
     return true;
 }
@@ -488,9 +497,9 @@
  */
 public int getDay () {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     return systime.wDay;
 }
 
@@ -509,9 +518,9 @@
  */
 public int getHours () {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     return systime.wHour;
 }
 
@@ -530,9 +539,9 @@
  */
 public int getMinutes () {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     return systime.wMinute;
 }
 
@@ -551,13 +560,13 @@
  */
 public int getMonth () {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     return systime.wMonth - 1;
 }
 
-override String getNameText () {
+override char[] getNameText () {
     return "DateTime";
 }
 
@@ -576,9 +585,9 @@
  */
 public int getSeconds () {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     return systime.wSecond;
 }
 
@@ -597,9 +606,9 @@
  */
 public int getYear () {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     return systime.wYear;
 }
 
@@ -643,12 +652,12 @@
  */
 public void setDay (int day) {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME;
-    systime.wDay = (short)day;
-    OS.SendMessage (handle, msg, 0, systime);
+    systime.wDay = cast(short)day;
+    OS.SendMessage (handle, msg, 0, &systime);
 }
 
 /**
@@ -666,12 +675,12 @@
  */
 public void setHours (int hours) {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME;
-    systime.wHour = (short)hours;
-    OS.SendMessage (handle, msg, 0, systime);
+    systime.wHour = cast(short)hours;
+    OS.SendMessage (handle, msg, 0, &systime);
 }
 
 /**
@@ -689,12 +698,12 @@
  */
 public void setMinutes (int minutes) {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME;
-    systime.wMinute = (short)minutes;
-    OS.SendMessage (handle, msg, 0, systime);
+    systime.wMinute = cast(short)minutes;
+    OS.SendMessage (handle, msg, 0, &systime);
 }
 
 /**
@@ -712,12 +721,12 @@
  */
 public void setMonth (int month) {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME;
-    systime.wMonth = (short)(month + 1);
-    OS.SendMessage (handle, msg, 0, systime);
+    systime.wMonth = cast(short)(month + 1);
+    OS.SendMessage (handle, msg, 0, &systime);
 }
 
 /**
@@ -735,12 +744,12 @@
  */
 public void setSeconds (int seconds) {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME;
-    systime.wSecond = (short)seconds;
-    OS.SendMessage (handle, msg, 0, systime);
+    systime.wSecond = cast(short)seconds;
+    OS.SendMessage (handle, msg, 0, &systime);
 }
 
 /**
@@ -758,12 +767,12 @@
  */
 public void setYear (int year) {
     checkWidget ();
-    SYSTEMTIME systime = new SYSTEMTIME ();
+    SYSTEMTIME systime;
     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME;
-    OS.SendMessage (handle, msg, 0, systime);
+    OS.SendMessage (handle, msg, 0, &systime);
     msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME;
-    systime.wYear = (short)year;
-    OS.SendMessage (handle, msg, 0, systime);
+    systime.wYear = cast(short)year;
+    OS.SendMessage (handle, msg, 0, &systime);
 }
 
 override int widgetStyle () {
@@ -780,15 +789,15 @@
     return bits;
 }
 
-override TCHAR windowClass () {
-    return (style & DWT.CALENDAR) !is 0 ? CalendarClass : DateTimeClass;
+override char[] windowClass () {
+    return (style & DWT.CALENDAR) !is 0 ? TCHARzToStr(CalendarClass) : TCHARzToStr(DateTimeClass);
 }
 
 override int windowProc () {
-    return (style & DWT.CALENDAR) !is 0 ? CalendarProc : DateTimeProc;
+    return (style & DWT.CALENDAR) !is 0 ? cast(int)CalendarProc : cast(int)DateTimeProc;
 }
 
-override LRESULT wmNotifyChild (NMHDR hdr, int wParam, int lParam) {
+override LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) {
     switch (hdr.code) {
         case OS.MCN_SELCHANGE: //SENT WHEN YOU SET IT?
         case OS.DTN_DATETIMECHANGE:
@@ -799,4 +808,4 @@
     return super.wmNotifyChild (hdr, wParam, lParam);
 }
 }
-++/
+
--- a/dwt/widgets/Shell.d	Thu Feb 21 15:20:42 2008 +0100
+++ b/dwt/widgets/Shell.d	Thu Feb 21 17:55:01 2008 +0100
@@ -1538,7 +1538,7 @@
     lpnmtdi.lpszText = lpstrTip;
 }
 
-void setToolTipText (NMTTDISPINFO lpnmtdi, char [] buffer) {
+void setToolTipText (NMTTDISPINFO* lpnmtdi, char [] buffer) {
     /*
     * Ensure that the current position of the mouse
     * is inside the client area of the shell.  This