Changeset 166:cd28aa5221a3

Show
Ignore:
Timestamp:
02/21/08 11:43:13 (8 months ago)
Author:
davelzg@gmail.com
branch:
default
Message:

Added DateTime? widget port. by Zhiguang Liang
but we need to pay attention to the java code.
Mostly is the call of following:
size = OS.GetDateFormat?
if it fails, MSDN says size would be 0, reasons :
1.ERROR_INSUFFICIENT_BUFFER
2.ERROR_INVALID_FLAGS
3.ERROR_INVALID_PARAMETER
since the second time calling , the java code uses the exactly same args. So I assume the javacode is trying to retry for the 1st case. But it shouldn't allocate an empty array for this?
weird...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/widgets/DateTime.d

    r82 r166  
    1515import dwt.widgets.Composite; 
    1616 
    17 class DateTime : Composite { 
    18 } 
    19 /++ 
    2017import dwt.DWT; 
    2118import dwt.DWTException; 
     
    2320import dwt.events.SelectionListener; 
    2421import dwt.graphics.Point; 
    25 import dwt.internal.win32.INITCOMMONCONTROLSEX; 
    26 import dwt.internal.win32.LRESULT; 
    27 import dwt.internal.win32.NMHDR; 
    2822import dwt.internal.win32.OS; 
    29 import dwt.internal.win32.RECT; 
    30 import dwt.internal.win32.SYSTEMTIME; 
    31 import dwt.internal.win32.TCHAR; 
    32 import dwt.internal.win32.WNDCLASS; 
     23 
     24import dwt.widgets.TypedListener; 
     25 
     26import dwt.dwthelper.utils; 
     27 
     28import Integer = tango.text.convert.Integer; 
    3329 
    3430//TODO - features not yet implemented: read-only, drop-down calendar for date 
     
    5955 */ 
    6056 
    61 public class DateTime extends Composite { 
     57public class DateTime : Composite { 
    6258 
    6359    alias Composite.computeSize computeSize; 
    6460    alias Composite.windowProc windowProc; 
    6561 
    66     static final int DateTimeProc; 
    67     static final TCHAR DateTimeClass = new TCHAR (0, OS.DATETIMEPICK_CLASS, true); 
    68     static final int CalendarProc; 
    69     static final TCHAR CalendarClass = new TCHAR (0, OS.MONTHCAL_CLASS, true); 
    70     static { 
    71         INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX (); 
    72         icex.dwSize = INITCOMMONCONTROLSEX.sizeof; 
    73         icex.dwICC = OS.ICC_DATE_CLASSES; 
    74         OS.InitCommonControlsEx (icex); 
    75         WNDCLASS lpWndClass = new WNDCLASS (); 
    76         OS.GetClassInfo (0, DateTimeClass, lpWndClass); 
    77         DateTimeProc = lpWndClass.lpfnWndProc; 
    78         OS.GetClassInfo (0, CalendarClass, lpWndClass); 
    79         CalendarProc = lpWndClass.lpfnWndProc; 
    80     } 
    81     static final int MARGIN = 4; 
    82     static final int MAX_DIGIT = 9; 
    83     static final int MAX_DAY = 31; 
    84     static final int MAX_12HOUR = 12; 
    85     static final int MAX_24HOUR = 24; 
    86     static final int MAX_MINUTE = 60; 
    87     static final int MONTH_DAY_YEAR = 0; 
    88     static final int DAY_MONTH_YEAR = 1; 
    89     static final int YEAR_MONTH_DAY = 2; 
    90     static final char SINGLE_QUOTE = '\''; //$NON-NLS-1$ short date format may include quoted text 
    91     static final char DAY_FORMAT_CONSTANT = 'd'; //$NON-NLS-1$ 1-4 lowercase 'd's represent day 
    92     static final char MONTH_FORMAT_CONSTANT = 'M'; //$NON-NLS-1$ 1-4 uppercase 'M's represent month 
    93     static final char YEAR_FORMAT_CONSTANT = 'y'; //$NON-NLS-1$ 1-5 lowercase 'y's represent year 
    94     static final char HOURS_FORMAT_CONSTANT = 'h'; //$NON-NLS-1$ 1-2 upper or lowercase 'h's represent hours 
    95     static final char MINUTES_FORMAT_CONSTANT = 'm'; //$NON-NLS-1$ 1-2 lowercase 'm's represent minutes 
    96     static final char SECONDS_FORMAT_CONSTANT = 's'; //$NON-NLS-1$ 1-2 lowercase 's's represent seconds 
    97     static final char AMPM_FORMAT_CONSTANT = 't'; //$NON-NLS-1$ 1-2 lowercase 't's represent am/pm 
    98     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}; 
     62    static /+const+/ WNDPROC DateTimeProc; 
     63    static const TCHAR* DateTimeClass = OS.DATETIMEPICK_CLASS.ptr; 
     64    static /+const+/ WNDPROC CalendarProc; 
     65    static const TCHAR* CalendarClass = OS.MONTHCAL_CLASS.ptr; 
     66 
     67    private static bool static_this_completed = false; 
     68    private static void static_this() { 
     69        if( static_this_completed ){ 
     70            return; 
     71        } 
     72        synchronized { 
     73            if( static_this_completed ){ 
     74                return; 
     75            } 
     76            INITCOMMONCONTROLSEX icex; 
     77            icex.dwSize = INITCOMMONCONTROLSEX.sizeof; 
     78            icex.dwICC = OS.ICC_DATE_CLASSES; 
     79            OS.InitCommonControlsEx (&icex); 
     80            WNDCLASS lpWndClass; 
     81            OS.GetClassInfo (null, DateTimeClass, &lpWndClass); 
     82            DateTimeProc = lpWndClass.lpfnWndProc; 
     83            OS.GetClassInfo (null, CalendarClass, &lpWndClass); 
     84            CalendarProc = lpWndClass.lpfnWndProc; 
     85            static_this_completed = true; 
     86        } 
     87    } 
     88 
     89    static const int MARGIN = 4; 
     90    static const int MAX_DIGIT = 9; 
     91    static const int MAX_DAY = 31; 
     92    static const int MAX_12HOUR = 12; 
     93    static const int MAX_24HOUR = 24; 
     94    static const int MAX_MINUTE = 60; 
     95    static const int MONTH_DAY_YEAR = 0; 
     96    static const int DAY_MONTH_YEAR = 1; 
     97    static const int YEAR_MONTH_DAY = 2; 
     98    static const char SINGLE_QUOTE = '\''; //$NON-NLS-1$ short date format may include quoted text 
     99    static const char DAY_FORMAT_CONSTANT = 'd'; //$NON-NLS-1$ 1-4 lowercase 'd's represent day 
     100    static const char MONTH_FORMAT_CONSTANT = 'M'; //$NON-NLS-1$ 1-4 uppercase 'M's represent month 
     101    static const char YEAR_FORMAT_CONSTANT = 'y'; //$NON-NLS-1$ 1-5 lowercase 'y's represent year 
     102    static const char HOURS_FORMAT_CONSTANT = 'h'; //$NON-NLS-1$ 1-2 upper or lowercase 'h's represent hours 
     103    static const char MINUTES_FORMAT_CONSTANT = 'm'; //$NON-NLS-1$ 1-2 lowercase 'm's represent minutes 
     104    static const char SECONDS_FORMAT_CONSTANT = 's'; //$NON-NLS-1$ 1-2 lowercase 's's represent seconds 
     105    static const char AMPM_FORMAT_CONSTANT = 't'; //$NON-NLS-1$ 1-2 lowercase 't's represent am/pm 
     106    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]; 
    99107 
    100108 
     
    129137 * @see Widget#getStyle 
    130138 */ 
    131 public DateTime (Composite parent, int style) { 
     139public this (Composite parent, int style) { 
     140    static_this(); 
    132141    super (parent, checkStyle (style)); 
    133142    if ((this.style & DWT.SHORT) !is 0) { 
    134         String buffer = ((this.style & DWT.DATE) !is 0) ? getCustomShortDateFormat() : getCustomShortTimeFormat(); 
    135         TCHAR lpszFormat = new TCHAR (0, buffer, true); 
    136         OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat); 
     143        char[] buffer = ((this.style & DWT.DATE) !is 0) ? getCustomShortDateFormat() : getCustomShortTimeFormat(); 
     144        TCHAR[] lpszFormat = StrToTCHARs (0, buffer, true); 
     145        OS.SendMessage (handle, OS.DTM_SETFORMAT, 0, lpszFormat.ptr); 
    137146    } 
    138147} 
     
    170179} 
    171180 
    172 override int callWindowProc (int hwnd, int msg, int wParam, int lParam) { 
    173     if (handle is 0) return 0; 
    174     return OS.CallWindowProc (windowProc (), hwnd, msg, wParam, lParam); 
     181override int callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 
     182    if (handle is null) return 0; 
     183    return OS.CallWindowProc ( cast(WNDPROC)windowProc(), hwnd, msg, wParam, lParam); 
    175184} 
    176185 
     
    197206    if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) { 
    198207        if ((style & DWT.CALENDAR) !is 0) { 
    199             RECT rect = new RECT ()
    200             OS.SendMessage(handle, OS.MCM_GETMINREQRECT, 0, rect); 
     208            RECT rect
     209            OS.SendMessage(handle, OS.MCM_GETMINREQRECT, 0, &rect); 
    201210            width = rect.right; 
    202211            height = rect.bottom; 
    203212        } else { 
    204             TCHAR buffer = new TCHAR (getCodePage (), 128)
    205             int newFont, oldFont = 0
    206             int hDC = OS.GetDC (handle); 
    207             newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    208             if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
    209             RECT rect = new RECT ()
     213            TCHAR[] buffer = new TCHAR[128]
     214            void* newFont = cast(void*)OS.SendMessage (handle, OS.WM_GETFONT, 0, 0), oldFont = null
     215            auto hDC = OS.GetDC (handle); 
     216//            newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     217            if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
     218            RECT rect
    210219            int flags = OS.DT_CALCRECT | OS.DT_EDITCONTROL | OS.DT_NOPREFIX; 
    211             SYSTEMTIME systime = new SYSTEMTIME ()
     220            SYSTEMTIME systime
    212221            if ((style & DWT.DATE) !is 0) { 
    213222                /* Determine the widest/tallest year string. */ 
     
    216225                int widest = 0, secondWidest = 0, thirdWidest = 0; 
    217226                for (int i = 0; i <= MAX_DIGIT; i++) { 
    218                     systime.wYear = (short) (2000 + i); // year 2000 + i is guaranteed to exist 
    219                     int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, systime, null, buffer, buffer.length ()); 
     227                    systime.wYear = cast(short) (2000 + i); // year 2000 + i is guaranteed to exist 
     228                    int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, &systime, null, buffer.ptr, buffer.length); 
    220229                    if (size is 0) { 
    221                         buffer = new TCHAR (getCodePage (), size)
    222                         OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, systime, null, buffer, buffer.length ()); 
     230                        buffer = new TCHAR[size]
     231                        OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, OS.DATE_SHORTDATE, &systime, null, buffer.ptr, buffer.length); 
    223232                    } 
    224233                    rect.left = rect.top = rect.right = rect.bottom = 0; 
    225                     OS.DrawText (hDC, buffer, size, rect, flags); 
     234                    OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 
    226235                    if (rect.right - rect.left >= width) { 
    227236                        width = rect.right - rect.left; 
     
    235244                else if (secondWidest > 1) widest = secondWidest * 1000 + widest * 100 + widest * 10 + widest; 
    236245                else widest = thirdWidest * 1000 + widest * 100 + widest * 10 + widest; 
    237                 systime.wYear = (short) widest; 
     246                systime.wYear = cast(short) widest; 
    238247 
    239248                /* Determine the widest/tallest month name string. */ 
     
    241250                for (short i = 0; i < MONTH_NAMES.length; i++) { 
    242251                    int name = MONTH_NAMES [i]; 
    243                     int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer, buffer.length ()); 
     252                    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer.ptr, buffer.length); 
    244253                    if (size is 0) { 
    245                         buffer = new TCHAR (getCodePage (), size)
    246                         OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer, buffer.length ()); 
     254                        buffer = new TCHAR[size]
     255                        OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, name, buffer.ptr, buffer.length); 
    247256                    } 
    248257                    rect.left = rect.top = rect.right = rect.bottom = 0; 
    249                     OS.DrawText (hDC, buffer, size, rect, flags); 
     258                    OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 
    250259                    if (rect.right - rect.left > width) { 
    251260                        width = rect.right - rect.left; 
     
    254263                    height = Math.max(height, rect.bottom - rect.top); 
    255264                } 
    256                 systime.wMonth = (short) (widest + 1); 
     265                systime.wMonth = cast(short) (widest + 1); 
    257266 
    258267                /* Determine the widest/tallest date string in the widest month of the widest year. */ 
     
    261270                for (short i = 1; i <= MAX_DAY; i++) { 
    262271                    systime.wDay = i; 
    263                     int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); 
     272                    int size = OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 
    264273                    if (size is 0) { 
    265                         buffer = new TCHAR (getCodePage (), size)
    266                         OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); 
     274                        buffer = new TCHAR[size]
     275                        OS.GetDateFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 
    267276                    } 
    268277                    rect.left = rect.top = rect.right = rect.bottom = 0; 
    269                     OS.DrawText (hDC, buffer, size, rect, flags); 
     278                    OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 
    270279                    width = Math.max(width, rect.right - rect.left); 
    271280                    height = Math.max(height, rect.bottom - rect.top); 
     
    279288                for (short i = 0; i < max; i++) { 
    280289                    systime.wHour = i; 
    281                     int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); 
     290                    int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 
    282291                    if (size is 0) { 
    283                         buffer = new TCHAR (getCodePage (), size)
    284                         OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); 
     292                        buffer = new TCHAR[size]
     293                        OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 
    285294                    } 
    286295                    rect.left = rect.top = rect.right = rect.bottom = 0; 
    287                     OS.DrawText (hDC, buffer, size, rect, flags); 
     296                    OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 
    288297                    if (rect.right - rect.left > width) { 
    289298                        width = rect.right - rect.left; 
     
    298307                for (short i = 0; i < MAX_MINUTE; i++) { 
    299308                    systime.wMinute = i; 
    300                     int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); 
     309                    int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 
    301310                    if (size is 0) { 
    302                         buffer = new TCHAR (getCodePage (), size)
    303                         OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); 
     311                        buffer = new TCHAR[size]
     312                        OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 
    304313                    } 
    305314                    rect.left = rect.top = rect.right = rect.bottom = 0; 
    306                     OS.DrawText (hDC, buffer, size, rect, flags); 
     315                    OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 
    307316                    if (rect.right - rect.left > width) { 
    308317                        width = rect.right - rect.left; 
     
    315324 
    316325                /* Determine the widest/tallest time string for the widest hour, widest minute, and if applicable, widest second. */ 
    317                 int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); 
     326                int size = OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 
    318327                if (size is 0) { 
    319                     buffer = new TCHAR (getCodePage (), size)
    320                     OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, systime, null, buffer, buffer.length ()); 
     328                    buffer = new TCHAR[size]
     329                    OS.GetTimeFormat(OS.LOCALE_USER_DEFAULT, dwFlags, &systime, null, buffer.ptr, buffer.length); 
    321330                } 
    322331                rect.left = rect.top = rect.right = rect.bottom = 0; 
    323                 OS.DrawText (hDC, buffer, size, rect, flags); 
     332                OS.DrawText (hDC, buffer.ptr, size, &rect, flags); 
    324333                width = rect.right - rect.left; 
    325334                height = Math.max(height, rect.bottom - rect.top); 
    326335            } 
    327             if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     336            if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    328337            OS.ReleaseDC (handle, hDC); 
    329338            int upDownWidth = OS.GetSystemMetrics (OS.SM_CXVSCROLL); 
     
    354363} 
    355364 
    356 String getComputeSizeString () { 
     365char[] getComputeSizeString () { 
    357366    // TODO: Not currently used but might need for WinCE 
    358367    if ((style & DWT.DATE) !is 0) { 
     
    368377} 
    369378 
    370 String getCustomShortDateFormat () { 
     379char[] getCustomShortDateFormat () { 
    371380    if (true) { 
    372         TCHAR tchar = new TCHAR (getCodePage (), 80)
    373         int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SYEARMONTH, tchar, 80); 
    374         return size !is 0 ? tchar.toString (0, size - 1) : "M/yyyy"; //$NON-NLS-1$ 
     381        TCHAR[] tchar = new TCHAR[80]
     382        int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SYEARMONTH, tchar.ptr, 80); 
     383        return size !is 0 ? TCHARsToStr(tchar[0..size - 1]) : "M/yyyy"; //$NON-NLS-1$ 
    375384    } 
    376385 
    377386    //TODO: Not currently used, but may need for WinCE (or if numeric short date is required) 
    378     StringBuffer buffer = new StringBuffer (getShortDateFormat ()); 
    379     int length = buffer.length ()
     387    char[] buffer = getShortDateFormat (); 
     388    int length = buffer.length
    380389    bool inQuotes = false; 
    381390    int start = 0, end = 0; 
     
    406415        start++; 
    407416    } 
    408     if (start < end) buffer.delete (start, end)
    409     return buffer.toString ()
    410 } 
    411  
    412 String getCustomShortTimeFormat () { 
    413     StringBuffer buffer = new StringBuffer (getTimeFormat ()); 
    414     int length = buffer.length ()
     417    if (start < end) buffer.length = start - 1
     418    return buffer
     419} 
     420 
     421char[] getCustomShortTimeFormat () { 
     422    char[] buffer = getTimeFormat (); 
     423    int length = buffer.length
    415424    bool inQuotes = false; 
    416425    int start = 0, end = 0; 
     
    428437        start++; 
    429438    } 
    430     if (start < end) buffer.delete (start, end)
    431     return buffer.toString ()
    432 } 
    433  
    434 String getLongDateFormat () { 
     439    if (start < end) buffer.length = start - 1
     440    return buffer
     441} 
     442 
     443char[] getLongDateFormat () { 
    435444    //TODO: Not currently used, but may need for WinCE 
    436     TCHAR tchar = new TCHAR (getCodePage (), 80)
    437     int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SLONGDATE, tchar, 80); 
    438     return size > 0 ? tchar.toString (0, size - 1) : "dddd, MMMM dd, yyyy"; //$NON-NLS-1$ 
    439 } 
    440  
    441 String getShortDateFormat () { 
     445    TCHAR tchar[80]
     446    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SLONGDATE, tchar.ptr, 80); 
     447    return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "dddd, MMMM dd, yyyy"; //$NON-NLS-1$ 
     448} 
     449 
     450char[] getShortDateFormat () { 
    442451    //TODO: Not currently used, but may need for WinCE 
    443     TCHAR tchar = new TCHAR (getCodePage (), 80)
     452    TCHAR tchar[80]
    444453    //TODO: May need to OR with LOCALE_ICENTURY 
    445     int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SSHORTDATE, tchar, 80); 
    446     return size > 0 ? tchar.toString (0, size - 1) : "M/d/yyyy"; //$NON-NLS-1$ 
     454    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_SSHORTDATE, tchar.ptr, 80); 
     455    return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "M/d/yyyy"; //$NON-NLS-1$ 
    447456} 
    448457 
    449458int getShortDateFormatOrdering () { 
    450459    //TODO: Not currently used, but may need for WinCE 
    451     TCHAR tchar = new TCHAR (getCodePage (), 4)
    452     int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_IDATE, tchar, 4); 
     460    TCHAR tchar[80]
     461    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_IDATE, tchar.ptr, 4); 
    453462    if (size > 0) { 
    454         String number = tchar.toString (0, size - 1); 
    455         return Integer.parseInt (number); 
     463        char[] number = TCHARsToStr(tchar[0..size - 1]); 
     464        return Integer.parse (number); 
    456465    } 
    457466    return 0; 
    458467} 
    459468 
    460 String getTimeFormat () { 
    461     TCHAR tchar = new TCHAR (getCodePage (), 80)
    462     int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_STIMEFORMAT, tchar, 80); 
    463     return size > 0 ? tchar.toString (0, size - 1) : "h:mm:ss tt"; //$NON-NLS-1$ 
     469char[] getTimeFormat () { 
     470    TCHAR tchar[80]
     471    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_STIMEFORMAT, tchar.ptr, 80); 
     472    return size > 0 ? TCHARsToStr(tchar[0..size - 1]) : "h:mm:ss tt"; //$NON-NLS-1$ 
    464473} 
    465474 
    466475bool is24HourTime () { 
    467     TCHAR tchar = new TCHAR (getCodePage (), 4)
    468     int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_ITIME, tchar, 4); 
     476    TCHAR tchar[4]
     477    int size = OS.GetLocaleInfo (OS.LOCALE_USER_DEFAULT, OS.LOCALE_ITIME, tchar.ptr, 4); 
    469478    if (size > 0) { 
    470         String number = tchar.toString (0, size - 1); 
    471         return Integer.parseInt (number) !is 0; 
     479        char[] number = TCHARsToStr(tchar[0..size - 1]); 
     480        return Integer.parse (number) !is 0; 
    472481    } 
    473482    return true; 
     
    489498public int getDay () { 
    490499    checkWidget (); 
    491     SYSTEMTIME systime = new SYSTEMTIME ()
    492     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    493     OS.SendMessage (handle, msg, 0, systime); 
     500    SYSTEMTIME systime
     501    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     502    OS.SendMessage (handle, msg, 0, &systime); 
    494503    return systime.wDay; 
    495504} 
     
    510519public int getHours () { 
    511520    checkWidget (); 
    512     SYSTEMTIME systime = new SYSTEMTIME ()
    513     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    514     OS.SendMessage (handle, msg, 0, systime); 
     521    SYSTEMTIME systime
     522    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     523    OS.SendMessage (handle, msg, 0, &systime); 
    515524    return systime.wHour; 
    516525} 
     
    531540public int getMinutes () { 
    532541    checkWidget (); 
    533     SYSTEMTIME systime = new SYSTEMTIME ()
    534     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    535     OS.SendMessage (handle, msg, 0, systime); 
     542    SYSTEMTIME systime
     543    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     544    OS.SendMessage (handle, msg, 0, &systime); 
    536545    return systime.wMinute; 
    537546} 
     
    552561public int getMonth () { 
    553562    checkWidget (); 
    554     SYSTEMTIME systime = new SYSTEMTIME ()
    555     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    556     OS.SendMessage (handle, msg, 0, systime); 
     563    SYSTEMTIME systime
     564    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     565    OS.SendMessage (handle, msg, 0, &systime); 
    557566    return systime.wMonth - 1; 
    558567} 
    559568 
    560 override String getNameText () { 
     569override char[] getNameText () { 
    561570    return "DateTime"; 
    562571} 
     
    577586public int getSeconds () { 
    578587    checkWidget (); 
    579     SYSTEMTIME systime = new SYSTEMTIME ()
    580     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    581     OS.SendMessage (handle, msg, 0, systime); 
     588    SYSTEMTIME systime
     589    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     590    OS.SendMessage (handle, msg, 0, &systime); 
    582591    return systime.wSecond; 
    583592} 
     
    598607public int getYear () { 
    599608    checkWidget (); 
    600     SYSTEMTIME systime = new SYSTEMTIME ()
    601     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    602     OS.SendMessage (handle, msg, 0, systime); 
     609    SYSTEMTIME systime
     610    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     611    OS.SendMessage (handle, msg, 0, &systime); 
    603612    return systime.wYear; 
    604613} 
     
    644653public void setDay (int day) { 
    645654    checkWidget (); 
    646     SYSTEMTIME systime = new SYSTEMTIME ()
    647     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    648     OS.SendMessage (handle, msg, 0, systime); 
     655    SYSTEMTIME systime
     656    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     657    OS.SendMessage (handle, msg, 0, &systime); 
    649658    msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 
    650     systime.wDay = (short)day; 
    651     OS.SendMessage (handle, msg, 0, systime); 
     659    systime.wDay = cast(short)day; 
     660    OS.SendMessage (handle, msg, 0, &systime); 
    652661} 
    653662 
     
    667676public void setHours (int hours) { 
    668677    checkWidget (); 
    669     SYSTEMTIME systime = new SYSTEMTIME ()
    670     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    671     OS.SendMessage (handle, msg, 0, systime); 
     678    SYSTEMTIME systime
     679    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     680    OS.SendMessage (handle, msg, 0, &systime); 
    672681    msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 
    673     systime.wHour = (short)hours; 
    674     OS.SendMessage (handle, msg, 0, systime); 
     682    systime.wHour = cast(short)hours; 
     683    OS.SendMessage (handle, msg, 0, &systime); 
    675684} 
    676685 
     
    690699public void setMinutes (int minutes) { 
    691700    checkWidget (); 
    692     SYSTEMTIME systime = new SYSTEMTIME ()
    693     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    694     OS.SendMessage (handle, msg, 0, systime); 
     701    SYSTEMTIME systime
     702    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     703    OS.SendMessage (handle, msg, 0, &systime); 
    695704    msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 
    696     systime.wMinute = (short)minutes; 
    697     OS.SendMessage (handle, msg, 0, systime); 
     705    systime.wMinute = cast(short)minutes; 
     706    OS.SendMessage (handle, msg, 0, &systime); 
    698707} 
    699708 
     
    713722public void setMonth (int month) { 
    714723    checkWidget (); 
    715     SYSTEMTIME systime = new SYSTEMTIME ()
    716     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    717     OS.SendMessage (handle, msg, 0, systime); 
     724    SYSTEMTIME systime
     725    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     726    OS.SendMessage (handle, msg, 0, &systime); 
    718727    msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 
    719     systime.wMonth = (short)(month + 1); 
    720     OS.SendMessage (handle, msg, 0, systime); 
     728    systime.wMonth = cast(short)(month + 1); 
     729    OS.SendMessage (handle, msg, 0, &systime); 
    721730} 
    722731 
     
    736745public void setSeconds (int seconds) { 
    737746    checkWidget (); 
    738     SYSTEMTIME systime = new SYSTEMTIME ()
    739     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    740     OS.SendMessage (handle, msg, 0, systime); 
     747    SYSTEMTIME systime
     748    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     749    OS.SendMessage (handle, msg, 0, &systime); 
    741750    msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 
    742     systime.wSecond = (short)seconds; 
    743     OS.SendMessage (handle, msg, 0, systime); 
     751    systime.wSecond = cast(short)seconds; 
     752    OS.SendMessage (handle, msg, 0, &systime); 
    744753} 
    745754 
     
    759768public void setYear (int year) { 
    760769    checkWidget (); 
    761     SYSTEMTIME systime = new SYSTEMTIME ()
    762     int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
    763     OS.SendMessage (handle, msg, 0, systime); 
     770    SYSTEMTIME systime
     771    int msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_GETCURSEL : OS.DTM_GETSYSTEMTIME; 
     772    OS.SendMessage (handle, msg, 0, &systime); 
    764773    msg = (style & DWT.CALENDAR) !is 0 ? OS.MCM_SETCURSEL : OS.DTM_SETSYSTEMTIME; 
    765     systime.wYear = (short)year; 
    766     OS.SendMessage (handle, msg, 0, systime); 
     774    systime.wYear = cast(short)year; 
     775    OS.SendMessage (handle, msg, 0, &systime); 
    767776} 
    768777 
     
    781790} 
    782791 
    783 override TCHAR windowClass () { 
    784     return (style & DWT.CALENDAR) !is 0 ? CalendarClass : DateTimeClass
     792override char[] windowClass () { 
     793    return (style & DWT.CALENDAR) !is 0 ? TCHARzToStr(CalendarClass) : TCHARzToStr(DateTimeClass)
    785794} 
    786795 
    787796override int windowProc () { 
    788     return (style & DWT.CALENDAR) !is 0 ? CalendarProc : DateTimeProc; 
    789 } 
    790  
    791 override LRESULT wmNotifyChild (NMHDR hdr, int wParam, int lParam) { 
     797    return (style & DWT.CALENDAR) !is 0 ? cast(int)CalendarProc : cast(int)DateTimeProc; 
     798} 
     799 
     800override LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) { 
    792801    switch (hdr.code) { 
    793802        case OS.MCN_SELCHANGE: //SENT WHEN YOU SET IT? 
     
    800809} 
    801810} 
    802 ++/ 
     811