Changeset 55:1bc7c2131617

Show
Ignore:
Timestamp:
02/04/08 05:08:30 (1 year ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

List

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/internal/win32/OS.d

    r52 r55  
    48034803} 
    48044804 
     4805public wchar[] StrToWCHARs(uint codepage , char[] sc) { 
     4806    return StrToWCHARs( sc ); 
     4807} 
    48054808public wchar[] StrToWCHARs(char[] sc) { 
    48064809    wchar[] ret; 
     
    48134816 
    48144817    return ret; 
     4818} 
     4819 
     4820public wchar* StrToWCHARz( uint codepage, char[] sc, uint* length = null ) { 
     4821    return StrToWCHARz( sc, length ); 
    48154822} 
    48164823 
     
    49534960 
    49544961 
    4955  
    4956  
     4962TCHAR[] NewTCHARs( uint codepage, uint len ){ 
     4963    return new TCHAR[ len ]; 
     4964
     4965 
     4966 
     4967 
  • dwt/widgets/List.d

    r54 r55  
    1313module dwt.widgets.List; 
    1414 
    15 import dwt.widgets.Scrollable; 
    16 class List : Scrollable { 
    17 
    18 /++ 
     15 
    1916import dwt.DWT; 
    2017import dwt.DWTException; 
     
    2320import dwt.graphics.Font; 
    2421import dwt.graphics.Point; 
    25 import dwt.internal.win32.LRESULT; 
    2622import dwt.internal.win32.OS; 
    27 import dwt.internal.win32.RECT; 
    28 import dwt.internal.win32.SCROLLINFO; 
    29 import dwt.internal.win32.TCHAR; 
    30 import dwt.internal.win32.WNDCLASS; 
     23 
     24import dwt.widgets.Scrollable; 
     25import dwt.widgets.Composite; 
     26import dwt.widgets.TypedListener; 
     27 
     28import dwt.dwthelper.utils; 
    3129 
    3230/** 
     
    4846 */ 
    4947 
    50 public class List extends Scrollable { 
     48public class List : Scrollable { 
    5149 
    5250    alias Scrollable.computeSize computeSize; 
    5351    alias Scrollable.windowProc windowProc; 
    5452 
    55     static final int INSET = 3; 
    56     static final int ListProc; 
    57     static final TCHAR ListClass = new TCHAR (0, "LISTBOX", true)
    58     static
    59         WNDCLASS lpWndClass = new WNDCLASS ()
    60         OS.GetClassInfo (0, ListClass, lpWndClass); 
     53    static const int INSET = 3; 
     54    static const WNDPROC ListProc; 
     55    static const TCHAR[] ListClass = "LISTBOX"
     56    static this()
     57        WNDCLASS lpWndClass
     58        OS.GetClassInfo (null, ListClass.ptr, &lpWndClass); 
    6159        ListProc = lpWndClass.lpfnWndProc; 
    6260    } 
     
    9189 * @see Widget#getStyle 
    9290 */ 
    93 public List (Composite parent, int style) { 
     91public this (Composite parent, int style) { 
    9492    super (parent, checkStyle (style)); 
    9593} 
     
    109107 * @see #add(String,int) 
    110108 */ 
    111 public void add (String string) { 
     109public void add (char[] string) { 
    112110    checkWidget (); 
    113111    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
    114     TCHAR buffer = new TCHAR (getCodePage (), string, true); 
     112    TCHAR* buffer = StrToTCHARz ( getCodePage (), string); 
    115113    int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer); 
    116114    if (result is OS.LB_ERR) error (DWT.ERROR_ITEM_NOT_ADDED); 
     
    141139 * @see #add(String) 
    142140 */ 
    143 public void add (String string, int index) { 
     141public void add (char[] string, int index) { 
    144142    checkWidget (); 
    145143    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
    146144    if (index is -1) error (DWT.ERROR_INVALID_RANGE); 
    147     TCHAR buffer = new TCHAR (getCodePage (), string, true); 
     145    TCHAR* buffer = StrToTCHARz(getCodePage (), string); 
    148146    int result = OS.SendMessage (handle, OS.LB_INSERTSTRING, index, buffer); 
    149147    if (result is OS.LB_ERRSPACE) error (DWT.ERROR_ITEM_NOT_ADDED); 
     
    191189} 
    192190 
    193 override int callWindowProc (int hwnd, int msg, int wParam, int lParam) { 
    194     if (handle is 0) return 0
    195     return OS.CallWindowProc (ListProc, hwnd, msg, wParam, lParam); 
     191override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 
     192    if (handle is null) return LRESULT.ZERO
     193    return cast(LRESULT) OS.CallWindowProc (ListProc, hwnd, msg, wParam, lParam); 
    196194} 
    197195 
     
    209207        } else { 
    210208            int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0); 
    211             int newFont, oldFont = 0
    212             int hDC = OS.GetDC (handle); 
    213             newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    214             if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
    215             RECT rect = new RECT ()
     209            HFONT newFont, oldFont
     210            auto hDC = OS.GetDC (handle); 
     211            newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     212            if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
     213            RECT rect
    216214            int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX; 
    217215            int cp = getCodePage (); 
    218             TCHAR buffer = new TCHAR (cp, 64 + 1); 
     216            TCHAR[] buffer = NewTCHARs (cp, 64 + 1); 
    219217            for (int i=0; i<count; i++) { 
    220218                int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0); 
    221219                if (length !is OS.LB_ERR) { 
    222                     if (length + 1 > buffer.length ()) { 
    223                         buffer = new TCHAR (cp, length + 1); 
     220                    if (length + 1 > buffer.length) { 
     221                        buffer = NewTCHARs (cp, length + 1); 
    224222                    } 
    225                     int result = OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer); 
     223                    int result = OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer.ptr); 
    226224                    if (result !is OS.LB_ERR) { 
    227                         OS.DrawText (hDC, buffer, length, rect, flags); 
     225                        OS.DrawText (hDC, buffer.ptr, length, &rect, flags); 
    228226                        width = Math.max (width, rect.right - rect.left); 
    229227                    } 
    230228                } 
    231229            } 
    232             if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     230            if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    233231            OS.ReleaseDC (handle, hDC); 
    234232        } 
     
    416414 * </ul> 
    417415 */ 
    418 public String getItem (int index) { 
    419     checkWidget (); 
    420     int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0); 
    421     if (length !is OS.LB_ERR) { 
    422         TCHAR buffer = new TCHAR (getCodePage (), length + 1); 
    423         int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer); 
    424         if (result !is OS.LB_ERR) return buffer.toString (0, length); 
     416public char[] getItem (int index) { 
     417    checkWidget (); 
     418    int length_ = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0); 
     419    if (length_ !is OS.LB_ERR) { 
     420        TCHAR[] buffer = NewTCHARs (getCodePage (), length_ + 1); 
     421        int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer.ptr); 
     422        if (result !is OS.LB_ERR) return TCHARsToStr( buffer[0 .. length_] ); 
    425423    } 
    426424    int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0); 
     
    481479 * </ul> 
    482480 */ 
    483 public String [] getItems () { 
     481public char[] [] getItems () { 
    484482    checkWidget (); 
    485483    int count = getItemCount (); 
    486     String [] result = new String [count]; 
     484    char[] [] result = new char[] [count]; 
    487485    for (int i=0; i<count; i++) result [i] = getItem (i); 
    488486    return result; 
     
    505503 * </ul> 
    506504 */ 
    507 public String [] getSelection () { 
     505public char[] [] getSelection () { 
    508506    checkWidget (); 
    509507    int [] indices = getSelectionIndices (); 
    510     String [] result = new String [indices.length]; 
     508    char[] [] result = new char[] [indices.length]; 
    511509    for (int i=0; i<indices.length; i++) { 
    512510        result [i] = getItem (indices [i]); 
     
    560558    if (result is OS.LB_ERR) error (DWT.ERROR_CANNOT_GET_SELECTION); 
    561559    if (result !is 0) return index; 
    562     int [] buffer = new int [1]
    563     result = OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, buffer); 
     560    int buffer
     561    result = OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, &buffer); 
    564562    if (result !is 1) error (DWT.ERROR_CANNOT_GET_SELECTION); 
    565     return buffer [0]
     563    return buffer
    566564} 
    567565 
     
    587585        int result = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0); 
    588586        if (result is OS.LB_ERR) return new int [0]; 
    589         return new int [] {result}
     587        return [result]
    590588    } 
    591589    int length = OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0); 
    592590    if (length is OS.LB_ERR) error (DWT.ERROR_CANNOT_GET_SELECTION); 
    593591    int [] indices = new int [length]; 
    594     int result = OS.SendMessage (handle, OS.LB_GETSELITEMS, length, indices); 
     592    int result = OS.SendMessage (handle, OS.LB_GETSELITEMS, length, indices.ptr); 
    595593    if (result !is length) error (DWT.ERROR_CANNOT_GET_SELECTION); 
    596594    return indices; 
     
    633631 * </ul> 
    634632 */ 
    635 public int indexOf (String string) { 
     633public int indexOf (char[] string) { 
    636634    return indexOf (string, 0); 
    637635} 
     
    656654 * </ul> 
    657655 */ 
    658 public int indexOf (String string, int start) { 
     656public int indexOf (char[] string, int start) { 
    659657    checkWidget (); 
    660658    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    666664    * to search the list, an item at a time. 
    667665    */ 
    668     if (string.length () is 0) { 
     666    if (string.length is 0) { 
    669667        int count = getItemCount (); 
    670668        for (int i=start; i<count; i++) { 
    671             if (string.equals (getItem (i))) return i; 
     669            if (string ==/*eq*/ getItem (i)) return i; 
    672670        } 
    673671        return -1; 
     
    678676    if (!(0 <= start && start < count)) return -1; 
    679677    int index = start - 1, last; 
    680     TCHAR buffer = new TCHAR (getCodePage (), string, true); 
     678    TCHAR* buffer = StrToTCHARz (getCodePage (), string ); 
    681679    do { 
    682680        index = OS.SendMessage (handle, OS.LB_FINDSTRINGEXACT, last = index, buffer); 
    683681        if (index is OS.LB_ERR || index <= last) return -1; 
    684     } while (!string.equals (getItem (index))); 
     682    } while (string !=/*eq*/ getItem (index)); 
    685683    return index; 
    686684} 
     
    733731    } 
    734732    int topIndex = OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0); 
    735     RECT rect = null; 
    736     int hDC = 0, oldFont = 0, newFont = 0, newWidth = 0; 
     733    RECT rect; 
     734    HDC hDC; 
     735    HFONT oldFont, newFont; 
     736    int newWidth = 0; 
    737737    if ((style & DWT.H_SCROLL) !is 0) { 
    738         rect = new RECT (); 
     738        //rect = new RECT (); 
    739739        hDC = OS.GetDC (handle); 
    740         newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    741         if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
     740        newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     741        if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
    742742    } 
    743743    int cp = getCodePage (); 
     
    746746        int index = newIndices [i]; 
    747747        if (index !is last) { 
    748             TCHAR buffer = null; 
     748            TCHAR[] buffer = null; 
    749749            if ((style & DWT.H_SCROLL) !is 0) { 
    750750                int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0); 
    751751                if (length is OS.LB_ERR) break; 
    752                 buffer = new TCHAR (cp, length + 1); 
    753                 int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer); 
     752                buffer = NewTCHARs (cp, length + 1); 
     753                int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer.ptr); 
    754754                if (result is OS.LB_ERR) break; 
    755755            } 
     
    758758            if ((style & DWT.H_SCROLL) !is 0) { 
    759759                int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX; 
    760                 OS.DrawText (hDC, buffer, -1, rect, flags); 
     760                OS.DrawText (hDC, buffer.ptr, -1, &rect, flags); 
    761761                newWidth = Math.max (newWidth, rect.right - rect.left); 
    762762            } 
     
    767767    } 
    768768    if ((style & DWT.H_SCROLL) !is 0) { 
    769         if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     769        if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    770770        OS.ReleaseDC (handle, hDC); 
    771771        setScrollWidth (newWidth, false); 
     
    794794public void remove (int index) { 
    795795    checkWidget (); 
    796     TCHAR buffer = null; 
     796    TCHAR[] buffer = null; 
    797797    if ((style & DWT.H_SCROLL) !is 0) { 
    798798        int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0); 
     
    802802            error (DWT.ERROR_INVALID_RANGE); 
    803803        } 
    804         buffer = new TCHAR (getCodePage (), length + 1); 
    805         int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer); 
     804        buffer = NewTCHARs (getCodePage (), length + 1); 
     805        int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer.ptr); 
    806806        if (result is OS.LB_ERR) { 
    807807            int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0); 
     
    817817        error (DWT.ERROR_INVALID_RANGE); 
    818818    } 
    819     if ((style & DWT.H_SCROLL) !is 0) setScrollWidth (buffer, false); 
     819    if ((style & DWT.H_SCROLL) !is 0) setScrollWidth (buffer.ptr, false); 
    820820    if (index < topIndex) { 
    821821        OS.SendMessage (handle, OS.LB_SETTOPINDEX, topIndex - 1, 0); 
     
    851851    } 
    852852    int topIndex = OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0); 
    853     RECT rect = null; 
    854     int hDC = 0, oldFont = 0, newFont = 0, newWidth = 0; 
     853    RECT rect; 
     854    HDC hDC; 
     855    HFONT oldFont, newFont; 
     856    int newWidth = 0; 
    855857    if ((style & DWT.H_SCROLL) !is 0) { 
    856         rect = new RECT (); 
     858        //rect = new RECT (); 
    857859        hDC = OS.GetDC (handle); 
    858         newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    859         if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
     860        newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     861        if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
    860862    } 
    861863    int cp = getCodePage (); 
     
    863865    int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX; 
    864866    while (index <= end) { 
    865         TCHAR buffer = null; 
     867        TCHAR[] buffer = null; 
    866868        if ((style & DWT.H_SCROLL) !is 0) { 
    867869            int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, start, 0); 
    868870            if (length is OS.LB_ERR) break; 
    869             buffer = new TCHAR (cp, length + 1); 
    870             int result = OS.SendMessage (handle, OS.LB_GETTEXT, start, buffer); 
     871            buffer = NewTCHARs (cp, length + 1); 
     872            int result = OS.SendMessage (handle, OS.LB_GETTEXT, start, buffer.ptr); 
    871873            if (result is OS.LB_ERR) break; 
    872874        } 
     
    874876        if (result is OS.LB_ERR) break; 
    875877        if ((style & DWT.H_SCROLL) !is 0) { 
    876             OS.DrawText (hDC, buffer, -1, rect, flags); 
     878            OS.DrawText (hDC, buffer.ptr, -1, &rect, flags); 
    877879            newWidth = Math.max (newWidth, rect.right - rect.left); 
    878880        } 
     
    880882    } 
    881883    if ((style & DWT.H_SCROLL) !is 0) { 
    882         if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     884        if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    883885        OS.ReleaseDC (handle, hDC); 
    884886        setScrollWidth (newWidth, false); 
     
    907909 * </ul> 
    908910 */ 
    909 public void remove (String string) { 
     911public void remove (char[] string) { 
    910912    checkWidget (); 
    911913    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    10281030    } 
    10291031    int topIndex = OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0); 
    1030     RECT itemRect = new RECT (), selectedRect = null; 
    1031     OS.SendMessage (handle, OS.LB_GETITEMRECT, index, itemRect); 
     1032    RECT itemRect, selectedRect; 
     1033    bool selectedRectNull = true; 
     1034    OS.SendMessage (handle, OS.LB_GETITEMRECT, index, &itemRect); 
    10321035    bool redraw = drawCount is 0 && OS.IsWindowVisible (handle); 
    10331036    if (redraw) { 
     
    10391042        int oldIndex = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0); 
    10401043        if (oldIndex !is -1) { 
    1041             selectedRect = new RECT (); 
    1042             OS.SendMessage (handle, OS.LB_GETITEMRECT, oldIndex, selectedRect); 
     1044            //selectedRect = new RECT (); 
     1045            selectedRectNull = false; 
     1046            OS.SendMessage (handle, OS.LB_GETITEMRECT, oldIndex, &selectedRect); 
    10431047        } 
    10441048        OS.SendMessage (handle, OS.LB_SETCURSEL, index, 0); 
     
    10561060        OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0); 
    10571061        OS.ValidateRect (handle, null); 
    1058         OS.InvalidateRect (handle, itemRect, true); 
    1059         if (selectedRect !is null) { 
    1060             OS.InvalidateRect (handle, selectedRect, true); 
     1062        OS.InvalidateRect (handle, &itemRect, true); 
     1063        if (!selectedRectNull) { 
     1064            OS.InvalidateRect (handle, &selectedRect, true); 
    10611065        } 
    10621066    } 
     
    11571161 * </ul> 
    11581162 */ 
    1159 public void setItem (int index, String string) { 
     1163public void setItem (int index, char[] string) { 
    11601164    checkWidget (); 
    11611165    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    11821186 * </ul> 
    11831187 */ 
    1184 public void setItems (String [] items) { 
     1188public void setItems (char[] [] items) { 
    11851189    checkWidget (); 
    11861190    if (items is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    11891193    } 
    11901194    int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC); 
    1191     OS.SetWindowLong (handle, OS.GWL_WNDPROC, ListProc); 
     1195    OS.SetWindowLong (handle, OS.GWL_WNDPROC, cast(int) ListProc); 
    11921196    bool redraw = drawCount is 0 && OS.IsWindowVisible (handle); 
    11931197    if (redraw) { 
    11941198        OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0); 
    11951199    } 
    1196     RECT rect = null; 
    1197     int hDC = 0, oldFont = 0, newFont = 0, newWidth = 0; 
     1200    RECT rect; 
     1201    HDC hDC; 
     1202    HFONT oldFont, newFont; 
     1203    int newWidth = 0; 
    11981204    if ((style & DWT.H_SCROLL) !is 0) { 
    1199         rect = new RECT (); 
     1205        //rect = new RECT (); 
    12001206        hDC = OS.GetDC (handle); 
    1201         newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    1202         if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
     1207        newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     1208        if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
    12031209        OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, 0, 0); 
    12041210    } 
     
    12091215    int cp = getCodePage (); 
    12101216    while (index < length) { 
    1211         String string = items [index]; 
    1212         TCHAR buffer = new TCHAR (cp, string, true); 
     1217        char[] string = items [index]; 
     1218        TCHAR* buffer = StrToTCHARz (cp, string); 
    12131219        int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer); 
    12141220        if (result is OS.LB_ERR || result is OS.LB_ERRSPACE) break; 
    12151221        if ((style & DWT.H_SCROLL) !is 0) { 
    12161222            int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX; 
    1217             OS.DrawText (hDC, buffer, -1, rect, flags); 
     1223            OS.DrawText (hDC, buffer, -1, &rect, flags); 
    12181224            newWidth = Math.max (newWidth, rect.right - rect.left); 
    12191225        } 
     
    12211227    } 
    12221228    if ((style & DWT.H_SCROLL) !is 0) { 
    1223         if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     1229        if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    12241230        OS.ReleaseDC (handle, hDC); 
    12251231        OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + INSET, 0); 
     
    12441250void setScrollWidth () { 
    12451251    int newWidth = 0; 
    1246     RECT rect = new RECT ()
    1247     int newFont, oldFont = 0
    1248     int hDC = OS.GetDC (handle); 
    1249     newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    1250     if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
     1252    RECT rect
     1253    HFONT newFont, oldFont
     1254    auto hDC = OS.GetDC (handle); 
     1255    newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     1256    if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
    12511257    int cp = getCodePage (); 
    12521258    int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0); 
     
    12551261        int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0); 
    12561262        if (length !is OS.LB_ERR) { 
    1257             TCHAR buffer = new TCHAR (cp, length + 1); 
    1258             int result = OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer); 
     1263            TCHAR[] buffer = NewTCHARs (cp, length + 1 ); 
     1264            int result = OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer.ptr); 
    12591265            if (result !is OS.LB_ERR) { 
    1260                 OS.DrawText (hDC, buffer, -1, rect, flags); 
     1266                OS.DrawText (hDC, buffer.ptr, -1, &rect, flags); 
    12611267                newWidth = Math.max (newWidth, rect.right - rect.left); 
    12621268            } 
    12631269        } 
    12641270    } 
    1265     if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     1271    if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    12661272    OS.ReleaseDC (handle, hDC); 
    12671273    OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + INSET, 0); 
    12681274} 
    12691275 
    1270 void setScrollWidth (TCHAR buffer, bool grow) { 
    1271     RECT rect = new RECT ()
    1272     int newFont, oldFont = 0
    1273     int hDC = OS.GetDC (handle); 
    1274     newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    1275     if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
     1276void setScrollWidth (TCHAR* buffer, bool grow) { 
     1277    RECT rect
     1278    HFONT newFont, oldFont
     1279    auto hDC = OS.GetDC (handle); 
     1280    newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     1281    if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
    12761282    int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX; 
    1277     OS.DrawText (hDC, buffer, -1, rect, flags); 
    1278     if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     1283    OS.DrawText (hDC, buffer, -1, &rect, flags); 
     1284    if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    12791285    OS.ReleaseDC (handle, hDC); 
    12801286    setScrollWidth (rect.right - rect.left, grow); 
     
    13491355 * @see List#setSelection(int[]) 
    13501356 */ 
    1351 public void setSelection (String [] items) { 
     1357public void setSelection (char[] [] items) { 
    13521358    checkWidget (); 
    13531359    if (items is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    13571363    int focusIndex = -1; 
    13581364    for (int i=length-1; i>=0; --i) { 
    1359         String string = items [i]; 
     1365        char[] string = items [i]; 
    13601366        int index = 0; 
    13611367        if (string !is null) { 
     
    14771483        index = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0); 
    14781484    } else { 
    1479         int [] indices = new int [1]
    1480         int result = OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, indices); 
    1481         index = indices [0]
     1485        int indices
     1486        int result = OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, &indices); 
     1487        index = indices
    14821488        if (result !is 1) index = -1; 
    14831489    } 
     
    14871493    int height = OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0); 
    14881494    forceResize (); 
    1489     RECT rect = new RECT ()
    1490     OS.GetClientRect (handle, rect); 
     1495    RECT rect
     1496    OS.GetClientRect (handle, &rect); 
    14911497    int topIndex = OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0); 
    14921498    int visibleCount = Math.max (rect.bottom / height, 1); 
     
    15071513} 
    15081514 
    1509 override TCHAR windowClass () { 
    1510     return ListClass
     1515override char[] windowClass () { 
     1516    return TCHARsToStr( ListClass )
    15111517} 
    15121518 
    15131519override int windowProc () { 
    1514     return ListProc; 
     1520    return cast(int) ListProc; 
    15151521} 
    15161522 
     
    15311537    LRESULT result = super.WM_SIZE (wParam, lParam); 
    15321538    if (!isDisposed ()) { 
    1533         SCROLLINFO info = new SCROLLINFO ()
     1539        SCROLLINFO info
    15341540        info.cbSize = SCROLLINFO.sizeof; 
    15351541        info.fMask = OS.SIF_POS; 
    1536         if (OS.GetScrollInfo (handle, OS.SB_HORZ, info)) { 
     1542        if (OS.GetScrollInfo (handle, OS.SB_HORZ, &info)) { 
    15371543            if (info.nPos !is 0) OS.InvalidateRect (handle, null, true); 
    15381544        } 
     
    15591565 
    15601566} 
    1561 ++/