Changeset 84:00a333240696

Show
Ignore:
Timestamp:
02/06/08 12:46:23 (10 months ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

FileDialog?, sync dwthelper with dwt-linux, some TCHAR issues

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/DWT.d

    r78 r84  
    2525    pragma(link, "advapi32"); 
    2626    pragma(link, "comctl32"); 
     27    pragma(link, "comdlg32"); 
    2728    pragma(link, "gdi32"); 
    2829    pragma(link, "kernel32"); 
  • dwt/dwthelper/InputStream.d

    r0 r84  
    1919            int c = read(); 
    2020            if( c == -1 ){ 
    21                 return idx; 
     21                return ( idx == 0 ) ? -1 : idx; 
    2222            } 
    2323            b[ idx] = cast(byte)( c & 0xFF ); 
  • dwt/dwthelper/ResourceBundle.d

    r0 r84  
    1 /** 
     1/** 
    22 * Authors: Frank Benoit <keinfarbton@googlemail.com> 
    33 */ 
    44module dwt.dwthelper.ResourceBundle; 
    55 
     6import tango.text.Util; 
     7import tango.io.Stdout; 
     8 
     9 
    610class ResourceBundle { 
    711 
    8     public this( char[] name ){ 
     12    char[][ char[] ] map; 
     13 
     14    public this( char[] data ){ 
     15        char[] line; 
     16        int dataIndex; 
     17 
     18        //tango.io.Stdout.Stdout.formatln( "properties put ..." ); 
     19        void readLine(){ 
     20            line.length = 0; 
     21            char i = data[ dataIndex++ ]; 
     22            while( dataIndex < data.length && i !is '\n' && i !is '\r' ){ 
     23                line ~= i; 
     24                i = data[ dataIndex++ ]; 
     25            } 
     26        } 
     27 
     28        //tango.io.Stdout.Stdout.formatln( "properties put {}", __LINE__ ); 
     29        bool linecontinue = false; 
     30        bool iskeypart = true; 
     31        char[] key; 
     32        char[] value; 
     33nextline: 
     34        while( dataIndex < data.length ){ 
     35            //tango.io.Stdout.Stdout.formatln( "properties put {} startline", __LINE__ ); 
     36            readLine(); 
     37            line = tango.text.Util.trim( line ); 
     38            if( line.length is 0 ){ 
     39                //tango.io.Stdout.Stdout.formatln( "properties put {} was 0 length", __LINE__ ); 
     40                continue; 
     41            } 
     42            if( line[0] == '#' ){ 
     43                //tango.io.Stdout.Stdout.formatln( "properties put {} was comment", __LINE__ ); 
     44                continue; 
     45            } 
     46            int pos = 0; 
     47            bool esc = false; 
     48            if( !linecontinue ){ 
     49                iskeypart = true; 
     50                key = null; 
     51                value = null; 
     52            } 
     53            else{ 
     54                linecontinue = false; 
     55            } 
     56            while( pos < line.length ){ 
     57                char c = line[pos]; 
     58                if( esc ){ 
     59                    esc = false; 
     60                    switch( c ){ 
     61                    case 't': c = '\t'; break; 
     62                    case 'n': c = '\n'; break; 
     63                    case '\\': c = '\\'; break; 
     64                    default:  c = '?'; break; 
     65                    } 
     66                } 
     67                else{ 
     68                    if( c == '\\' ){ 
     69                        if( pos == line.length -1 ){ 
     70                            linecontinue = true; 
     71                            goto nextline; 
     72                        } 
     73                        esc = true; 
     74                        pos++; 
     75                        continue; 
     76                    } 
     77                    else if( iskeypart && c == '=' ){ 
     78                        pos++; 
     79                        iskeypart = false; 
     80                        continue; 
     81                    } 
     82                } 
     83                pos++; 
     84                if( iskeypart ){ 
     85                    key ~= c; 
     86                } 
     87                else{ 
     88                    value ~= c; 
     89                } 
     90            } 
     91            if( iskeypart ){ 
     92                tango.io.Stdout.Stdout.formatln( "dwt.dwthelper.ResourceBundle ctor cannot find '='." ); 
     93                continue; 
     94            } 
     95            key = tango.text.Util.trim( key ); 
     96            value = tango.text.Util.trim(value); 
     97            //tango.io.Stdout.Stdout.formatln( "properties put {}=>{}", key, value ); 
     98 
     99            map[ key.dup ] = value.dup; 
     100            //tango.io.Stdout.Stdout.formatln( "properties put {}", __LINE__ ); 
     101        } 
    9102    } 
    10103 
    11104    public char[] getString( char[] key ){ 
     105        if( auto v = key in map ){ 
     106            return (*v).dup; 
     107        } 
    12108        return key; 
    13109    } 
    14110 
    15111    public static ResourceBundle getBundle( char[] name ){ 
    16         return new ResourceBundle( name ); 
     112        return new ResourceBundle( null ); 
    17113    } 
    18  
     114    public static ResourceBundle getBundleFromData( char[] data ){ 
     115        return new ResourceBundle( data ); 
     116    } 
    19117} 
    20118 
  • dwt/dwthelper/System.d

    r33 r84  
    55 
    66import tango.core.Exception; 
     7import tango.time.Clock; 
    78import tango.stdc.stdlib : exit; 
    89 
     
    122123 
    123124    static long currentTimeMillis(){ 
    124         //PORTING_FIXMe 
    125         return 0; 
     125        return Clock.now().ticks() / 10000; 
    126126    } 
    127127 
  • dwt/dwthelper/utils.d

    r79 r84  
    8989} 
    9090 
     91public char[] replace( char[] str, char from, char to ){ 
     92    return tango.text.Util.replace( str.dup, from, to ); 
     93} 
     94 
    9195public char[] substring( char[] str, int start ){ 
    9296    return str[ start .. $ ].dup; 
  • dwt/graphics/Device.d

    r81 r84  
    512512             */ 
    513513            cbdata.scalable = scalable; 
    514             if (OS.IsUnicode) { 
     514            static if (OS.IsUnicode) { 
    515515                OS.EnumFontFamiliesW (hDC, (cast(LOGFONTW*)lf).lfFaceName.ptr, &EnumFontFamFunc, cast(int)&cbdata); 
    516516            } else { 
  • dwt/graphics/FontData.d

    r48 r84  
    324324} 
    325325 
    326 //PORTING_FIXME: tango has this callback defined always with char*, needs fix 
    327 extern (Windows) static 
    328 //int EnumLocalesProc(TCHAR* lpLocaleString) { 
    329 int EnumLocalesProc(char* lpLocaleString) { 
     326extern (Windows) static int EnumLocalesProc(TCHAR* lpLocaleString) { 
    330327 
    331328    /* Get the locale ID */ 
  • dwt/internal/win32/OS.d

    r83 r84  
    231231                pActCtx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_SET_PROCESS_DEFAULT; 
    232232                pActCtx.lpSource = pszText; 
    233                 pActCtx.lpResourceName = cast(char*)MANIFEST_RESOURCE_ID; 
     233                pActCtx.lpResourceName = cast(TCHAR*)MANIFEST_RESOURCE_ID; 
    234234                HANDLE hActCtx = OS.CreateActCtx (&pActCtx); 
    235235                if (pszText !is null) OS.HeapFree (hHeap, 0, pszText); 
  • dwt/widgets/FileDialog.d

    r82 r84  
    1313module dwt.widgets.FileDialog; 
    1414 
     15 
     16import dwt.DWT; 
     17import dwt.DWTException; 
     18import dwt.internal.win32.OS; 
    1519import dwt.widgets.Dialog; 
    1620import dwt.widgets.Shell; 
    17  
    18 class FileDialog : Dialog { 
    19     public this (Shell parent) { 
    20         this (parent, 0); 
    21     } 
    22     public this (Shell parent, int style) { 
    23         super (parent, style); 
    24     } 
    25  
    26 
    27  
    28 /++ 
    29 import dwt.DWT; 
    30 import dwt.DWTException; 
    31 import dwt.internal.Callback; 
    32 import dwt.internal.win32.OFNOTIFY; 
    33 import dwt.internal.win32.OPENFILENAME; 
    34 import dwt.internal.win32.OS; 
    35 import dwt.internal.win32.TCHAR; 
     21import dwt.widgets.Display; 
     22 
     23import dwt.dwthelper.utils; 
    3624 
    3725/** 
     
    5139 * </p> 
    5240 */ 
    53 public class FileDialog extends Dialog { 
    54     String [] filterNames = new String [0]
    55     String [] filterExtensions = new String [0]
    56     String [] fileNames = new String [0]
    57     String filterPath = "", fileName = ""; 
    58     static final String FILTER = "*.*"; 
     41public class FileDialog : Dialog { 
     42    char[] [] filterNames
     43    char[] [] filterExtensions
     44    char[] [] fileNames
     45    char[] filterPath = "", fileName = ""; 
     46    static final char[] FILTER = "*.*"; 
    5947    static int BUFFER_SIZE = 1024 * 32; 
    6048    static bool USE_HOOK; 
     
    7361 * </ul> 
    7462 */ 
    75 public FileDialog (Shell parent) { 
     63public this (Shell parent) { 
    7664    this (parent, DWT.PRIMARY_MODAL); 
    7765} 
     
    10189 * </ul> 
    10290 */ 
    103 public FileDialog (Shell parent, int style) { 
     91public this (Shell parent, int style) { 
    10492    super (parent, style); 
    10593    checkSubclass (); 
     
    113101 * @return the relative path of the file 
    114102 */ 
    115 public String getFileName () { 
     103public char[] getFileName () { 
    116104    return fileName; 
    117105} 
     
    123111 * @return the relative paths of the files 
    124112 */ 
    125 public String [] getFileNames () { 
     113public char[] [] getFileNames () { 
    126114    return fileNames; 
    127115} 
     
    133121 * @return the file extensions filter 
    134122 */ 
    135 public String [] getFilterExtensions () { 
     123public char[] [] getFilterExtensions () { 
    136124    return filterExtensions; 
    137125} 
     
    143131 * @return the list of filter names 
    144132 */ 
    145 public String [] getFilterNames () { 
     133public char[] [] getFilterNames () { 
    146134    return filterNames; 
    147135} 
     
    156144 * @see #setFilterExtensions 
    157145 */ 
    158 public String getFilterPath () { 
     146public char[] getFilterPath () { 
    159147    return filterPath; 
    160148} 
    161149 
    162 int OFNHookProc (int hdlg, int uiMsg, int wParam, int lParam) { 
     150private static extern(Windows) uint OFNHookProc (HWND hdlg, uint uiMsg, uint wParam, int lParam) { 
    163151    switch (uiMsg) { 
    164152        case OS.WM_NOTIFY: 
    165             OFNOTIFY ofn = new OFNOTIFY ()
    166             OS.MoveMemory (ofn, lParam, OFNOTIFY.sizeof); 
    167             if (ofn.code is OS.CDN_SELCHANGE) { 
    168                 int lResult = OS.SendMessage (ofn.hwndFrom, OS.CDM_GETSPEC, 0, 0); 
     153            OFNOTIFY* ofn = cast(OFNOTIFY*)lParam
     154            //OS.MoveMemory (ofn, lParam, OFNOTIFY.sizeof); 
     155            if (ofn.hdr.code is OS.CDN_SELCHANGE) { 
     156                int lResult = OS.SendMessage (ofn.hdr.hwndFrom, OS.CDM_GETSPEC, 0, 0); 
    169157                if (lResult > 0) { 
    170158                    lResult += OS.MAX_PATH; 
    171                     OPENFILENAME lpofn = new OPENFILENAME ()
    172                     OS.MoveMemory (lpofn, ofn.lpOFN, OPENFILENAME.sizeof); 
     159                    OPENFILENAME* lpofn = ofn.lpOFN
     160                    //OS.MoveMemory (lpofn, ofn.lpOFN, OPENFILENAME.sizeof); 
    173161                    if (lpofn.nMaxFile < lResult) { 
    174                         int hHeap = OS.GetProcessHeap (); 
    175                         int lpstrFile = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, lResult * TCHAR.sizeof); 
    176                         if (lpstrFile !is 0) { 
    177                             if (lpofn.lpstrFile !is 0) OS.HeapFree (hHeap, 0, lpofn.lpstrFile); 
     162                        auto hHeap = OS.GetProcessHeap (); 
     163                        auto lpstrFile = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, lResult * TCHAR.sizeof); 
     164                        if (lpstrFile !is null) { 
     165                            if (lpofn.lpstrFile !is null) OS.HeapFree (hHeap, 0, lpofn.lpstrFile); 
    178166                            lpofn.lpstrFile = lpstrFile; 
    179167                            lpofn.nMaxFile = lResult; 
    180                             OS.MoveMemory (ofn.lpOFN, lpofn, OPENFILENAME.sizeof); 
     168                            //OS.MoveMemory (ofn.lpOFN, lpofn, OPENFILENAME.sizeof); 
    181169                        } 
    182170                    } 
     
    201189 * </ul> 
    202190 */ 
    203 public String open () { 
    204     int hHeap = OS.GetProcessHeap (); 
     191public char[] open () { 
     192    auto hHeap = OS.GetProcessHeap (); 
    205193 
    206194    /* Get the owner HWND for the dialog */ 
    207     int hwndOwner = 0
     195    HWND hwndOwner
    208196    if (parent !is null) hwndOwner = parent.handle; 
    209197 
     
    211199    if (title is null) title = ""; 
    212200    /* Use the character encoding for the default locale */ 
    213     TCHAR buffer3 = new TCHAR (0, title, true); 
    214     int byteCount3 = buffer3.length () * TCHAR.sizeof; 
    215     int lpstrTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount3); 
    216     OS.MoveMemory (lpstrTitle, buffer3, byteCount3); 
     201    TCHAR[] buffer3 = StrToTCHARs (0, title, true); 
     202    int byteCount3 = buffer3.length * TCHAR.sizeof; 
     203    auto lpstrTitle = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount3); 
     204    OS.MoveMemory (lpstrTitle, buffer3.ptr, byteCount3); 
    217205 
    218206    /* Compute filters and copy into lpstrFilter */ 
    219     String strFilter = ""; 
    220     if (filterNames is null) filterNames = new String [0]
    221     if (filterExtensions is null) filterExtensions = new String [0]
     207    char[] strFilter = ""; 
     208    if (filterNames is null) filterNames = null
     209    if (filterExtensions is null) filterExtensions = null
    222210    for (int i=0; i<filterExtensions.length; i++) { 
    223         String filterName = filterExtensions [i]; 
     211        char[] filterName = filterExtensions [i]; 
    224212        if (i < filterNames.length) filterName = filterNames [i]; 
    225         strFilter = strFilter + filterName + '\0' + filterExtensions [i] + '\0'; 
     213        strFilter = strFilter ~ filterName ~ '\0' ~ filterExtensions [i] ~ '\0'; 
    226214    } 
    227215    if (filterExtensions.length is 0) { 
    228         strFilter = strFilter + FILTER + '\0' + FILTER + '\0'; 
     216        strFilter = strFilter ~ FILTER ~ '\0' ~ FILTER ~ '\0'; 
    229217    } 
    230218    /* Use the character encoding for the default locale */ 
    231     TCHAR buffer4 = new TCHAR (0, strFilter, true); 
    232     int byteCount4 = buffer4.length () * TCHAR.sizeof; 
    233     int lpstrFilter = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount4); 
    234     OS.MoveMemory (lpstrFilter, buffer4, byteCount4); 
     219    TCHAR[] buffer4 = StrToTCHARs (0, strFilter, true); 
     220    int byteCount4 = buffer4.length * TCHAR.sizeof; 
     221    auto lpstrFilter = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount4); 
     222    OS.MoveMemory (lpstrFilter, buffer4.ptr, byteCount4); 
    235223 
    236224    /* Convert the fileName and filterName to C strings */ 
    237225    if (fileName is null) fileName = ""; 
    238226    /* Use the character encoding for the default locale */ 
    239     TCHAR name = new TCHAR (0, fileName, true); 
     227    TCHAR[] name = StrToTCHARs (0, fileName, true); 
    240228 
    241229    /* 
     
    246234    if ((style & DWT.MULTI) !is 0) nMaxFile = Math.max (nMaxFile, BUFFER_SIZE); 
    247235    int byteCount = nMaxFile * TCHAR.sizeof; 
    248     int lpstrFile = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
    249     int byteCountFile = Math.min (name.length () * TCHAR.sizeof, byteCount - TCHAR.sizeof); 
    250     OS.MoveMemory (lpstrFile, name, byteCountFile); 
     236    auto lpstrFile = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
     237    int byteCountFile = Math.min (name.length * TCHAR.sizeof, byteCount - TCHAR.sizeof); 
     238    OS.MoveMemory (lpstrFile, name.ptr, byteCountFile); 
    251239 
    252240    /* 
     
    256244    if (filterPath is null) filterPath = ""; 
    257245    /* Use the character encoding for the default locale */ 
    258     TCHAR path = new TCHAR (0, filterPath.replace ('/', '\\'), true); 
     246    TCHAR[] path = StrToTCHARs (0, filterPath.replace ('/', '\\'), true); 
    259247    int byteCount5 = OS.MAX_PATH * TCHAR.sizeof; 
    260     int lpstrInitialDir = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount5); 
    261     int byteCountDir = Math.min (path.length () * TCHAR.sizeof, byteCount5 - TCHAR.sizeof); 
    262     OS.MoveMemory (lpstrInitialDir, path, byteCountDir); 
     248    auto lpstrInitialDir = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount5); 
     249    int byteCountDir = Math.min (path.length * TCHAR.sizeof, byteCount5 - TCHAR.sizeof); 
     250    OS.MoveMemory (lpstrInitialDir, path.ptr, byteCountDir); 
    263251 
    264252    /* Create the file dialog struct */ 
    265     OPENFILENAME struct = new OPENFILENAME ()
    266     struct.lStructSize = OPENFILENAME.sizeof; 
    267     struct.Flags = OS.OFN_HIDEREADONLY | OS.OFN_NOCHANGEDIR; 
    268     Callback callback = null; 
     253    OPENFILENAME struct_
     254    struct_.lStructSize = OPENFILENAME.sizeof; 
     255    struct_.Flags = OS.OFN_HIDEREADONLY | OS.OFN_NOCHANGEDIR; 
     256    //Callback callback = null; 
    269257    if ((style & DWT.MULTI) !is 0) { 
    270         struct.Flags |= OS.OFN_ALLOWMULTISELECT | OS.OFN_EXPLORER; 
     258        struct_.Flags |= OS.OFN_ALLOWMULTISELECT | OS.OFN_EXPLORER; 
    271259        if (!OS.IsWinCE && USE_HOOK) { 
    272             callback = new Callback (this, "OFNHookProc", 4); //$NON-NLS-1$ 
    273             int lpfnHook = callback.getAddress (); 
    274             if (lpfnHook is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS); 
    275             struct.lpfnHook = lpfnHook; 
    276             struct.Flags |= OS.OFN_ENABLEHOOK; 
     260            //callback = new Callback (this, "OFNHookProc", 4); //$NON-NLS-1$ 
     261            //int lpfnHook = callback.getAddress (); 
     262            //if (lpfnHook is 0) DWT.error (DWT.ERROR_NO_MORE_CALLBACKS); 
     263            struct_.lCustData = cast(uint) cast(void*) this; 
     264            struct_.lpfnHook = &OFNHookProc; 
     265            struct_.Flags |= OS.OFN_ENABLEHOOK; 
    277266        } 
    278267    } 
    279     struct.hwndOwner = hwndOwner; 
    280     struct.lpstrTitle = lpstrTitle; 
    281     struct.lpstrFile = lpstrFile; 
    282     struct.nMaxFile = nMaxFile; 
    283     struct.lpstrInitialDir = lpstrInitialDir; 
    284     struct.lpstrFilter = lpstrFilter; 
    285     struct.nFilterIndex = 0; 
     268    struct_.hwndOwner = hwndOwner; 
     269    struct_.lpstrTitle = lpstrTitle; 
     270    struct_.lpstrFile = lpstrFile; 
     271    struct_.nMaxFile = nMaxFile; 
     272    struct_.lpstrInitialDir = lpstrInitialDir; 
     273    struct_.lpstrFilter = lpstrFilter; 
     274    struct_.nFilterIndex = 0; 
    286275 
    287276    /* 
     
    291280    * extension at the time that the dialog is closed. 
    292281    */ 
    293     int lpstrDefExt = 0
     282    TCHAR* lpstrDefExt
    294283    bool save = (style & DWT.SAVE) !is 0; 
    295284    if (save) { 
    296         lpstrDefExt = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof); 
    297         struct.lpstrDefExt = lpstrDefExt; 
     285        lpstrDefExt = cast(TCHAR*) OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TCHAR.sizeof); 
     286        struct_.lpstrDefExt = lpstrDefExt; 
    298287    } 
    299288 
     
    324313    * file name, use an empty file name and open it again. 
    325314    */ 
    326     bool success = (save) ? OS.GetSaveFileName (struct) : OS.GetOpenFileName (struct); 
     315    bool success = cast(bool)( (save) ? OS.GetSaveFileName (&struct_) : OS.GetOpenFileName (&struct_)); 
    327316    switch (OS.CommDlgExtendedError ()) { 
    328317        case OS.FNERR_INVALIDFILENAME: 
    329             OS.MoveMemory (lpstrFile, new TCHAR (0, "", true), TCHAR.sizeof); 
    330             success = (save) ? OS.GetSaveFileName (struct) : OS.GetOpenFileName (struct); 
     318            OS.MoveMemory (lpstrFile, StrToTCHARz ( "" ), TCHAR.sizeof); 
     319            success = cast(bool)((save) ? OS.GetSaveFileName (&struct_) : OS.GetOpenFileName (&struct_)); 
    331320            break; 
    332321        case OS.FNERR_BUFFERTOOSMALL: 
     
    343332 
    344333    /* Dispose the callback and reassign the buffer */ 
    345     if (callback !is null) callback.dispose (); 
    346     lpstrFile = struct.lpstrFile; 
     334    //if (callback !is null) callback.dispose (); 
     335    lpstrFile = struct_.lpstrFile; 
    347336 
    348337    /* Set the new path, file name and filter */ 
    349     fileNames = new String [0]; 
    350     String fullPath = null; 
     338    fileNames = new char[] [0]; 
     339    char[] fullPath = null; 
    351340    if (success) { 
    352341 
    353342        /* Use the character encoding for the default locale */ 
    354         TCHAR buffer = new TCHAR (0, struct.nMaxFile); 
    355         int byteCount1 = buffer.length () * TCHAR.sizeof; 
    356         OS.MoveMemory (buffer, lpstrFile, byteCount1); 
     343        TCHAR[] buffer = NewTCHARs (0, struct_.nMaxFile); 
     344        int byteCount1 = buffer.length * TCHAR.sizeof; 
     345        OS.MoveMemory (buffer.ptr, lpstrFile, byteCount1); 
    357346 
    358347        /* 
     
    365354        * Note: WinCE does not support multi-select file dialogs. 
    366355        */ 
    367         int nFileOffset = struct.nFileOffset; 
     356        int nFileOffset = struct_.nFileOffset; 
    368357        if (OS.IsWinCE && nFileOffset is 0) { 
    369358            int index = 0; 
    370             while (index < buffer.length ()) { 
    371                 int ch = buffer.tcharAt (index)
     359            while (index < buffer.length ) { 
     360                int ch = buffer[index]
    372361                if (ch is 0) break; 
    373362                if (ch is '\\') nFileOffset = index + 1; 
     
    378367 
    379368            /* Use the character encoding for the default locale */ 
    380             TCHAR prefix = new TCHAR (0, nFileOffset - 1); 
    381             int byteCount2 = prefix.length () * TCHAR.sizeof; 
    382             OS.MoveMemory (prefix, lpstrFile, byteCount2); 
    383             filterPath = prefix.toString (0, prefix.length ()); 
     369            TCHAR[] prefix = NewTCHARs (0, nFileOffset - 1); 
     370            int byteCount2 = prefix.length * TCHAR.sizeof; 
     371            OS.MoveMemory (prefix.ptr, lpstrFile, byteCount2); 
     372            filterPath = TCHARsToStr( prefix ); 
    384373 
    385374            /* 
     
    388377            */ 
    389378            int count = 0; 
    390             fileNames = new String [(style & DWT.MULTI) !is 0 ? 4 : 1]
     379            fileNames = new char[][]( (style & DWT.MULTI) !is 0 ? 4 : 1 )
    391380            int start = nFileOffset; 
    392381            do { 
    393382                int end = start; 
    394                 while (end < buffer.length () && buffer.tcharAt (end) !is 0) end++; 
    395                 String string = buffer.toString (start, end - start); 
     383                while (end < buffer.length && buffer[end] !is 0) end++; 
     384                char[] string = TCHARsToStr( buffer[ start .. end - start ] ); 
    396385                start = end; 
    397386                if (count is fileNames.length) { 
    398                     String [] newFileNames = new String [fileNames.length + 4]
     387                    char[] [] newFileNames = new char[][]( fileNames.length + 4 )
    399388                    System.arraycopy (fileNames, 0, newFileNames, 0, fileNames.length); 
    400389                    fileNames = newFileNames; 
     
    403392                if ((style & DWT.MULTI) is 0) break; 
    404393                start++; 
    405             } while (start < buffer.length () && buffer.tcharAt (start) !is 0); 
     394            } while (start < buffer.length && buffer[start] !is 0); 
    406395 
    407396            if (fileNames.length > 0) fileName = fileNames  [0]; 
    408             String separator = ""; 
    409             int length = filterPath.length ()
    410             if (length > 0 && filterPath.charAt (length - 1) !is '\\') { 
     397            char[] separator = ""; 
     398            int length_ = filterPath.length
     399            if (length_ > 0 && filterPath[length_ - 1] !is '\\') { 
    411400                separator = "\\"; 
    412401            } 
    413             fullPath = filterPath + separator + fileName; 
     402            fullPath = filterPath ~ separator ~ fileName; 
    414403            if (count < fileNames.length) { 
    415                 String [] newFileNames = new String [count]
     404                char[] [] newFileNames = new char[][]( count )
    416405                System.arraycopy (fileNames, 0, newFileNames, 0, count); 
    417406                fileNames = newFileNames; 
     
    425414    OS.HeapFree (hHeap, 0, lpstrInitialDir); 
    426415    OS.HeapFree (hHeap, 0, lpstrTitle); 
    427     if (lpstrDefExt !is 0) OS.HeapFree (hHeap, 0, lpstrDefExt); 
     416    if (lpstrDefExt !is null) OS.HeapFree (hHeap, 0, lpstrDefExt); 
    428417 
    429418    /* 
     
    447436 * @param string the file name 
    448437 */ 
    449 public void setFileName (String string) { 
     438public void setFileName (char[] string) { 
    450439    fileName = string; 
    451440} 
     
    466455 * names corresponding to the extensions 
    467456 */ 
    468 public void setFilterExtensions (String [] extensions) { 
     457public void setFilterExtensions (char[] [] extensions) { 
    469458    filterExtensions = extensions; 
    470459} 
     
    484473 * @see #setFilterExtensions 
    485474 */ 
    486 public void setFilterNames (String [] names) { 
     475public void setFilterNames (char[] [] names) { 
    487476    filterNames = names; 
    488477} 
     
    505494 * @see #setFilterExtensions 
    506495 */ 
    507 public void setFilterPath (String string) { 
     496public void setFilterPath (char[] string) { 
    508497    filterPath = string; 
    509498} 
    510499 
    511500} 
    512 ++/ 
     501 
  • dwt/widgets/Tracker.d

    r82 r84  
    499499        hwndTransparent = OS.CreateWindowEx ( 
    500500            isVista ? OS.WS_EX_LAYERED | OS.WS_EX_NOACTIVATE : OS.WS_EX_TRANSPARENT, 
    501             display.windowClass_
     501            display.windowClass_.ptr
    502502            null, 
    503503            OS.WS_POPUP, 
  • tango_sys_win32/Types.d

    r78 r84  
    9898alias COLORREF* LPCOLORREF; 
    9999alias PCHAR LPCSTR; 
    100 alias PCHAR LPCTSTR; 
     100alias TCHAR* LPCTSTR; 
    101101alias wchar* LPCWCH; 
    102102alias wchar* LPCWSTR; 
     
    107107alias PCHAR LPSTR; 
    108108alias PCHAR LPTCH; 
    109 alias PCHAR LPTSTR; 
     109alias TCHAR* LPTSTR; 
    110110alias int LRESULT; 
    111111alias POINTER LPVOID; 
     
    151151alias DWORD SERVICE_STATUS_HANDLE; 
    152152alias ubyte TBYTE; 
    153 alias char TCHAR; 
     153 
     154// version dependent 
     155alias wchar TCHAR; 
     156 
    154157alias ubyte BCHAR; 
    155158alias ubyte UCHAR;