Changeset 44:c913756e6950

Show
Ignore:
Timestamp:
02/01/08 19:51:46 (1 year ago)
Author:
Frank Benoit <benoit@tionex.de>
branch:
default
Message:

Combo

Files:

Legend:

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

    r4 r44  
    1 /******************************************************************************* 
     1/******************************************************************************* 
    22 * Copyright (c) 2000, 2007 IBM Corporation and others. 
    33 * All rights reserved. This program and the accompanying materials 
     
    1313import dwt.internal.Platform; 
    1414 
     15static import tango.stdc.string; 
     16 
    1517public class C : Platform { 
    16  
     18    alias tango.stdc.string.memmove MoveMemory; 
    1719//public static final native void free (int /*long*/ ptr); 
    1820//public static final native int /*long*/ getenv (byte[] wcsToMbcs); 
  • dwt/internal/win32/OS.d

    r41 r44  
    38473847version(ANSI) { 
    38483848    alias WINAPI.AddFontResourceExA AddFontResourceEx; 
    3849     alias WINAPI.CallWindowProcA CallWindowProc; 
     3849    alias STDWIN.CallWindowProcA CallWindowProc; 
    38503850    alias WINAPI.CharLowerA CharLower; 
    38513851    alias WINAPI.CharUpperA CharUpper; 
     
    39453945}else{ 
    39463946    alias WINAPI.AddFontResourceExW AddFontResourceEx; 
    3947     alias WINAPI.CallWindowProcW CallWindowProc; 
     3947    alias STDWIN.CallWindowProcW CallWindowProc; 
    39483948    alias WINAPI.CharLowerW CharLower; 
    39493949    alias WINAPI.CharUpperW CharUpper; 
  • dwt/internal/win32/WINTYPES.d

    r41 r44  
    9090 * as int like Eclispe/SWT does. and we alias int to WPARAM_I. 
    9191 */ 
    92 alias LRESULT function(HWND, int, int, int) WNDPROC_I; 
     92alias LRESULT function(HWND, uint, uint, int) WNDPROC_I; 
    9393alias LRESULT function(int code, int wParam, LPARAM lParam) HOOKPROC_I; 
    9494 
  • dwt/widgets/ColorDialog.d

    r43 r44  
    101101} 
    102102 
    103 private static extern(Windows) int CCHookFunc (HWND hdlg, int uiMsg, int lParam, int lpData) { 
     103private static extern(Windows) int CCHookFunc (HWND hdlg, uint uiMsg, uint lParam, int lpData) { 
    104104    ColorDialog dlg = cast(ColorDialog)cast(void*)lpData; 
    105105    return dlg.CCHookProc( hdlg, uiMsg, lParam ); 
    106106} 
    107107 
    108 int CCHookProc (HWND hdlg, int uiMsg, int lParam ) { 
     108int CCHookProc (HWND hdlg, uint uiMsg, uint lParam ) { 
    109109    switch (uiMsg) { 
    110110        case OS.WM_INITDIALOG: { 
  • dwt/widgets/Combo.d

    r31 r44  
    1515import dwt.widgets.Composite; 
    1616 
    17 class Combo : Composite { 
    18 } 
    19 /++ 
    2017import dwt.DWT; 
    2118import dwt.DWTException; 
     
    2623import dwt.graphics.Font; 
    2724import dwt.graphics.Point; 
    28 import dwt.internal.Callback; 
    29 import dwt.internal.win32.COMBOBOXINFO; 
    30 import dwt.internal.win32.LRESULT; 
    31 import dwt.internal.win32.MONITORINFO; 
    32 import dwt.internal.win32.MSG; 
    3325import dwt.internal.win32.OS; 
    34 import dwt.internal.win32.RECT; 
    35 import dwt.internal.win32.TCHAR; 
    36 import dwt.internal.win32.WNDCLASS; 
     26 
     27import dwt.widgets.TypedListener; 
     28import dwt.widgets.Event; 
     29import dwt.widgets.Composite; 
     30import dwt.widgets.Shell; 
     31import dwt.widgets.Display; 
     32 
     33import dwt.dwthelper.utils; 
    3734 
    3835/** 
     
    7269 */ 
    7370 
    74 public class Combo extends Composite { 
     71public class Combo : Composite { 
     72 
     73    alias Composite.sendKeyEvent sendKeyEvent; 
     74 
     75    alias extern(Windows) int function( HWND, uint, uint, int ) TWindowProc; 
     76    private static Combo pThis; 
    7577    bool noSelection, ignoreDefaultSelection, ignoreCharacter, ignoreModify; 
    76     int cbtHook, scrollWidth, visibleCount = 5; 
     78    HHOOK cbtHook; 
     79    int scrollWidth, visibleCount = 5; 
    7780 
    7881    /** 
     
    8083     * that the text field in an instance of this class can hold 
    8184     */ 
    82     public static final int LIMIT
     85    private static int LIMIT_ = 0
    8386 
    8487    /* 
     
    8790     * to stop the compiler from inlining. 
    8891     */ 
    89     static { 
    90         LIMIT = OS.IsWinNT ? 0x7FFFFFFF : 0x7FFF; 
    91     } 
    92  
     92    public static int LIMIT(){ 
     93        if( LIMIT_ is 0 ){ 
     94            synchronized { 
     95                LIMIT_ = OS.IsWinNT ? 0x7FFFFFFF : 0x7FFF; 
     96            } 
     97        } 
     98        return LIMIT_; 
     99    } 
    93100    /* 
    94101     * These are the undocumented control id's for the children of 
     
    97104     * been the same since Windows 3.0). 
    98105     */ 
    99     static final int CBID_LIST = 1000; 
    100     static final int CBID_EDIT = 1001; 
    101     static /*final*/ int EditProc, ListProc; 
    102  
    103     static final int ComboProc; 
    104     static final TCHAR ComboClass = new TCHAR (0, "COMBOBOX", true); 
    105     static { 
    106         WNDCLASS lpWndClass = new WNDCLASS (); 
    107         OS.GetClassInfo (0, ComboClass, lpWndClass); 
     106    static const int CBID_LIST = 1000; 
     107    static const int CBID_EDIT = 1001; 
     108    static /*final*/ TWindowProc EditProc, ListProc; 
     109 
     110    static const TWindowProc ComboProc; 
     111    static const TCHAR* ComboClass = "COMBOBOX\0"; 
     112 
     113    static this() { 
     114        WNDCLASS lpWndClass; 
     115        OS.GetClassInfo (null, ComboClass, &lpWndClass); 
    108116        ComboProc = lpWndClass.lpfnWndProc; 
    109117    } 
     118 
    110119 
    111120/** 
     
    139148 * @see Widget#getStyle 
    140149 */ 
    141 public Combo (Composite parent, int style) { 
     150public this (Composite parent, int style) { 
    142151    super (parent, checkStyle (style)); 
    143152    /* This code is intentionally commented */ 
     
    161170 * @see #add(String,int) 
    162171 */ 
    163 public void add (String string) { 
     172public void add (char[] string) { 
    164173    checkWidget (); 
    165174    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
    166     TCHAR buffer = new TCHAR (getCodePage (), string, true); 
    167     int result = OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer); 
     175    auto buffer = StrToTCHARs( string ); 
     176    int result = OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer.ptr ); 
    168177    if (result is OS.CB_ERR) error (DWT.ERROR_ITEM_NOT_ADDED); 
    169178    if (result is OS.CB_ERRSPACE) error (DWT.ERROR_ITEM_NOT_ADDED); 
     
    194203 * @see #add(String) 
    195204 */ 
    196 public void add (String string, int index) { 
     205public void add (char[] string, int index) { 
    197206    checkWidget (); 
    198207    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    201210        error (DWT.ERROR_INVALID_RANGE); 
    202211    } 
    203     TCHAR buffer = new TCHAR (getCodePage (), string, true); 
    204     int result = OS.SendMessage (handle, OS.CB_INSERTSTRING, index, buffer); 
     212    auto buffer = StrToTCHARs( string ); 
     213    int result = OS.SendMessage (handle, OS.CB_INSERTSTRING, index, buffer.ptr); 
    205214    if (result is OS.CB_ERRSPACE || result is OS.CB_ERR) { 
    206215        error (DWT.ERROR_ITEM_NOT_ADDED); 
     
    295304} 
    296305 
    297 int callWindowProc (int hwnd, int msg, int wParam, int lParam) { 
    298     if (handle is 0) return 0
     306override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 
     307    if (handle is null) return LRESULT.ZERO
    299308    if (hwnd is handle) { 
    300         return OS.CallWindowProc (ComboProc, hwnd, msg, wParam, lParam); 
    301     } 
    302     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     309        return cast(LRESULT) OS.CallWindowProc( ComboProc, hwnd, msg, wParam, lParam); 
     310    } 
     311    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    303312    if (hwnd is hwndText) { 
    304         return OS.CallWindowProc (EditProc, hwnd, msg, wParam, lParam); 
    305     } 
    306     int hwndList = OS.GetDlgItem (handle, CBID_LIST); 
     313        return cast(LRESULT) OS.CallWindowProc( EditProc, hwnd, msg, wParam, lParam); 
     314    } 
     315    auto hwndList = OS.GetDlgItem (handle, CBID_LIST); 
    307316    if (hwnd is hwndList) { 
    308         return OS.CallWindowProc (ListProc, hwnd, msg, wParam, lParam); 
    309     } 
    310     return OS.DefWindowProc (hwnd, msg, wParam, lParam); 
     317        return cast(LRESULT) OS.CallWindowProc( ListProc, hwnd, msg, wParam, lParam); 
     318    } 
     319    return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 
     320
     321 
     322private static extern(Windows) int CBTFunc (int nCode, int wParam, int lParam) { 
     323    return pThis.CBTProc( nCode, wParam, lParam ); 
    311324} 
    312325 
    313326int CBTProc (int nCode, int wParam, int lParam) { 
    314327    if (nCode is OS.HCBT_CREATEWND) { 
    315         TCHAR buffer = new TCHAR (0, 128)
    316         OS.GetClassName (wParam, buffer, buffer.length ()); 
    317         String className = buffer.toString (0, buffer.strlen ()); 
    318         if (className.equals ("Edit") || className.equals ("EDIT")) { //$NON-NLS-1$  //$NON-NLS-2$ 
    319             int bits = OS.GetWindowLong (wParam, OS.GWL_STYLE); 
    320             OS.SetWindowLong (wParam, OS.GWL_STYLE, bits & ~OS.ES_NOHIDESEL); 
     328        TCHAR[128] buffer = 0
     329        OS.GetClassName (cast(HANDLE)wParam, buffer.ptr, buffer.length ); 
     330        char[] className = TCHARzToStr(buffer.ptr); 
     331        if (className=="Edit" || className=="EDIT") { //$NON-NLS-1$  //$NON-NLS-2$ 
     332            int bits = OS.GetWindowLong (cast(HANDLE)wParam, OS.GWL_STYLE); 
     333            OS.SetWindowLong (cast(HANDLE)wParam, OS.GWL_STYLE, bits & ~OS.ES_NOHIDESEL); 
    321334        } 
    322335    } 
     
    324337} 
    325338 
    326 bool checkHandle (int hwnd) { 
     339bool checkHandle (HWND hwnd) { 
    327340    return hwnd is handle || hwnd is OS.GetDlgItem (handle, CBID_EDIT) || hwnd is OS.GetDlgItem (handle, CBID_LIST); 
    328341} 
     
    386399    int width = 0, height = 0; 
    387400    if (wHint is DWT.DEFAULT) { 
    388         int newFont, oldFont = 0
    389         int hDC = OS.GetDC (handle); 
    390         newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    391         if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
     401        HFONT newFont, oldFont
     402        auto hDC = OS.GetDC (handle); 
     403        newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     404        if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
    392405        int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0); 
    393         RECT rect = new RECT ()
     406        RECT rect
    394407        int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX; 
    395408        if ((style & DWT.READ_ONLY) is 0) flags |= OS.DT_EDITCONTROL; 
    396         int length = OS.GetWindowTextLength (handle); 
     409        int length_ = OS.GetWindowTextLength (handle); 
    397410        int cp = getCodePage (); 
    398         TCHAR buffer = new TCHAR (cp, length + 1); 
    399         OS.GetWindowText (handle, buffer, length + 1); 
    400         OS.DrawText (hDC, buffer, length, rect, flags); 
     411        TCHAR[] buffer = new TCHAR[ length_ + 1]; 
     412        buffer[] = 0; 
     413        OS.GetWindowText (handle, buffer.ptr, length_ + 1); 
     414        OS.DrawText (hDC, buffer.ptr, length_, &rect, flags); 
    401415        width = Math.max (width, rect.right - rect.left); 
    402416        if ((style & DWT.H_SCROLL) !is 0) { 
     
    404418        } else { 
    405419            for (int i=0; i<count; i++) { 
    406                 length = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, i, 0); 
    407                 if (length !is OS.CB_ERR) { 
    408                     if (length + 1 > buffer.length ()) buffer = new TCHAR (cp, length + 1)
    409                     int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, i, buffer); 
     420                length_ = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, i, 0); 
     421                if (length_ !is OS.CB_ERR) { 
     422                    if (length_ + 1 > buffer.length ) buffer = new TCHAR[ length_ + 1 ], buffer[] =0
     423                    int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, i, buffer.ptr); 
    410424                    if (result !is OS.CB_ERR) { 
    411                         OS.DrawText (hDC, buffer, length, rect, flags); 
     425                        OS.DrawText (hDC, buffer.ptr, length_, &rect, flags); 
    412426                        width = Math.max (width, rect.right - rect.left); 
    413427                    } 
     
    415429            } 
    416430        } 
    417         if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     431        if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    418432        OS.ReleaseDC (handle, hDC); 
    419433    } 
     
    432446        width += 8; 
    433447    } else { 
    434         int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    435         if (hwndText !is 0) { 
     448        auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     449        if (hwndText !is null) { 
    436450            int margins = OS.SendMessage (hwndText, OS.EM_GETMARGINS, 0, 0); 
    437451            int marginWidth = (margins & 0xFFFF) + ((margins >> 16) & 0xFFFF); 
     
    439453        } 
    440454    } 
    441     COMBOBOXINFO pcbi = new COMBOBOXINFO ()
     455    COMBOBOXINFO pcbi
    442456    pcbi.cbSize = COMBOBOXINFO.sizeof; 
    443     if (((style & DWT.SIMPLE) is 0) && !OS.IsWinCE && OS.GetComboBoxInfo (handle, pcbi)) { 
    444         width += pcbi.itemLeft + (pcbi.buttonRight - pcbi.buttonLeft); 
    445         height = (pcbi.buttonBottom - pcbi.buttonTop) + pcbi.buttonTop * 2; 
     457    if (((style & DWT.SIMPLE) is 0) && !OS.IsWinCE && OS.GetComboBoxInfo (handle, &pcbi)) { 
     458        width += pcbi.rcItem.left + (pcbi.rcButton.right - pcbi.rcButton.left); 
     459        height = (pcbi.rcButton.bottom - pcbi.rcButton.top) + pcbi.rcButton.top * 2; 
    446460    } else { 
    447461        int border = OS.GetSystemMetrics (OS.SM_CXEDGE); 
     
    493507    } else { 
    494508        int threadId = OS.GetCurrentThreadId (); 
    495         Callback cbtCallback = new Callback (this, "CBTProc", 3); //$NON-NLS-1$ 
    496         int cbtProc = cbtCallback.getAddress (); 
    497         if (cbtProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); 
    498         cbtHook = OS.SetWindowsHookEx (OS.WH_CBT, cbtProc, 0, threadId); 
     509        //Callback cbtCallback = new Callback (this, "CBTProc", 3); //$NON-NLS-1$ 
     510        //int cbtProc = cbtCallback.getAddress (); 
     511        //if (cbtProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); 
     512        pThis = this; 
     513        cbtHook = OS.SetWindowsHookEx (OS.WH_CBT, &CBTFunc, null, threadId); 
    499514        super.createHandle (); 
    500         if (cbtHook !is 0) OS.UnhookWindowsHookEx (cbtHook); 
    501         cbtHook = 0; 
    502         cbtCallback.dispose (); 
     515        if (cbtHook !is null) OS.UnhookWindowsHookEx (cbtHook); 
     516        pThis = null; 
     517        //cbtHook = 0; 
     518        //cbtCallback.dispose (); 
    503519    } 
    504520    state &= ~(CANVAS | THEME_BACKGROUND); 
    505521 
    506522    /* Get the text and list window procs */ 
    507     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    508     if (hwndText !is 0 && EditProc is 0) { 
    509         EditProc = OS.GetWindowLong (hwndText, OS.GWL_WNDPROC); 
    510     } 
    511     int hwndList = OS.GetDlgItem (handle, CBID_LIST); 
    512     if (hwndList !is 0 && ListProc is 0) { 
    513         ListProc = OS.GetWindowLong (hwndList, OS.GWL_WNDPROC); 
     523    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     524    if (hwndText !is null && EditProc is null) { 
     525        EditProc = cast(TWindowProc) OS.GetWindowLong (hwndText, OS.GWL_WNDPROC); 
     526    } 
     527    auto hwndList = OS.GetDlgItem (handle, CBID_LIST); 
     528    if (hwndList !is null && ListProc is null) { 
     529        ListProc = cast(TWindowProc) OS.GetWindowLong (hwndList, OS.GWL_WNDPROC); 
    514530    } 
    515531 
     
    522538    if ((style & DWT.SIMPLE) !is 0) { 
    523539        int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE; 
    524         SetWindowPos (handle, 0, 0, 0, 0x3FFF, 0x3FFF, flags); 
    525         SetWindowPos (handle, 0, 0, 0, 0, 0, flags); 
     540        SetWindowPos (handle, null, 0, 0, 0x3FFF, 0x3FFF, flags); 
     541        SetWindowPos (handle, null, 0, 0, 0, 0, flags); 
    526542    } 
    527543} 
     
    553569void deregister () { 
    554570    super.deregister (); 
    555     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    556     if (hwndText !is 0) display.removeControl (hwndText); 
    557     int hwndList = OS.GetDlgItem (handle, CBID_LIST); 
    558     if (hwndList !is 0) display.removeControl (hwndList); 
     571    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     572    if (hwndText !is null) display.removeControl (hwndText); 
     573    auto hwndList = OS.GetDlgItem (handle, CBID_LIST); 
     574    if (hwndList !is null) display.removeControl (hwndList); 
    559575} 
    560576 
     
    601617} 
    602618 
    603 bool dragDetect (int hwnd, int x, int y, bool filter, bool [] detect, bool [] consume) { 
     619bool dragDetect (HWND hwnd, int x, int y, bool filter, bool [] detect, bool [] consume) { 
    604620    if (filter && (style & DWT.READ_ONLY) is 0) { 
    605         int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    606         if (hwndText !is 0) { 
    607             int [] start = new int [1], end = new int [1]
    608             OS.SendMessage (handle, OS.CB_GETEDITSEL, start, end); 
    609             if (start [0] !is end [0]) { 
     621        auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     622        if (hwndText !is null) { 
     623            int start, end
     624            OS.SendMessage (handle, OS.CB_GETEDITSEL, &start, &end); 
     625            if (start !is end ) { 
    610626                int lParam = (x & 0xFFFF) | ((y << 16) & 0xFFFF0000); 
    611627                int position = OS.SendMessage (hwndText, OS.EM_CHARFROMPOS, 0, lParam) & 0xFFFF; 
    612                 if (start [0] <= position && position < end [0]) { 
     628                if (start <= position && position < end ) { 
    613629                    if (super.dragDetect (hwnd, x, y, filter, detect, consume)) { 
    614630                        if (consume !is null) consume [0] = true; 
     
    639655 * </ul> 
    640656 */ 
    641 public String getItem (int index) { 
    642     checkWidget (); 
    643     int length = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0); 
    644     if (length !is OS.CB_ERR) { 
    645         TCHAR buffer = new TCHAR (getCodePage (), length + 1)
    646         int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer); 
    647         if (result !is OS.CB_ERR) return buffer.toString (0, length); 
     657public char[] getItem (int index) { 
     658    checkWidget (); 
     659    int length_ = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0); 
     660    if (length_ !is OS.CB_ERR) { 
     661        TCHAR[] buffer = new TCHAR[ length_ + 1]
     662        int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer.ptr); 
     663        if (result !is OS.CB_ERR) return TCHARzToStr( buffer.ptr ); 
    648664    } 
    649665    int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0); 
     
    704720 * </ul> 
    705721 */ 
    706 public String [] getItems () { 
     722public char[] [] getItems () { 
    707723    checkWidget (); 
    708724    int count = getItemCount (); 
    709     String [] result = new String [count]; 
     725    char[] [] result = new char[] [count]; 
    710726    for (int i=0; i<count; i++) result [i] = getItem (i); 
    711727    return result; 
     
    739755} 
    740756 
    741 String getNameText () { 
     757char[] getNameText () { 
    742758    return getText (); 
    743759} 
     
    784800        return new Point (0, OS.GetWindowTextLength (handle)); 
    785801    } 
    786     int [] start = new int [1], end = new int [1]
    787     OS.SendMessage (handle, OS.CB_GETEDITSEL, start, end); 
     802    int start, end
     803    OS.SendMessage (handle, OS.CB_GETEDITSEL, &start, &end); 
    788804    if (!OS.IsUnicode && OS.IsDBLocale) { 
    789         start [0] = mbcsToWcsPos (start [0]); 
    790         end [0] = mbcsToWcsPos (end [0]); 
    791     } 
    792     return new Point (start [0], end [0]); 
     805        start = mbcsToWcsPos (start); 
     806        end = mbcsToWcsPos (end); 
     807    } 
     808    return new Point (start, end); 
    793809} 
    794810 
     
    822838 * </ul> 
    823839 */ 
    824 public String getText () { 
    825     checkWidget (); 
    826     int length = OS.GetWindowTextLength (handle); 
    827     if (length is 0) return ""; 
    828     TCHAR buffer = new TCHAR (getCodePage (), length + 1)
    829     OS.GetWindowText (handle, buffer, length + 1); 
    830     return buffer.toString (0, length); 
     840public char[] getText () { 
     841    checkWidget (); 
     842    int length_ = OS.GetWindowTextLength (handle); 
     843    if (length_ is 0) return ""; 
     844    TCHAR[] buffer = new TCHAR[ length_ + 1]
     845    OS.GetWindowText (handle, buffer.ptr, length_ + 1); 
     846    return TCHARzToStr( buffer.ptr ); 
    831847} 
    832848 
     
    843859public int getTextHeight () { 
    844860    checkWidget (); 
    845     COMBOBOXINFO pcbi = new COMBOBOXINFO ()
     861    COMBOBOXINFO pcbi
    846862    pcbi.cbSize = COMBOBOXINFO.sizeof; 
    847     if (((style & DWT.SIMPLE) is 0) && !OS.IsWinCE && OS.GetComboBoxInfo (handle, pcbi)) { 
    848         return (pcbi.buttonBottom - pcbi.buttonTop) + pcbi.buttonTop * 2; 
     863    if (((style & DWT.SIMPLE) is 0) && !OS.IsWinCE && OS.GetComboBoxInfo (handle, &pcbi)) { 
     864        return (pcbi.rcButton.bottom - pcbi.rcButton.top) + pcbi.rcButton.top * 2; 
    849865    } 
    850866    int result = OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, -1, 0); 
     
    870886public int getTextLimit () { 
    871887    checkWidget (); 
    872     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    873     if (hwndText is 0) return LIMIT; 
     888    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     889    if (hwndText is null) return LIMIT; 
    874890    return OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0) & 0x7FFFFFFF; 
    875891} 
     
    898914 
    899915bool hasFocus () { 
    900     int hwndFocus = OS.GetFocus (); 
     916    auto hwndFocus = OS.GetFocus (); 
    901917    if (hwndFocus is handle) return true; 
    902     if (hwndFocus is 0) return false; 
    903     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     918    if (hwndFocus is null) return false; 
     919    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    904920    if (hwndFocus is hwndText) return true; 
    905     int hwndList = OS.GetDlgItem (handle, CBID_LIST); 
     921    auto hwndList = OS.GetDlgItem (handle, CBID_LIST); 
    906922    if (hwndFocus is hwndList) return true; 
    907923    return false; 
     
    925941 * </ul> 
    926942 */ 
    927 public int indexOf (String string) { 
     943public int indexOf (char[] string) { 
    928944    return indexOf (string, 0); 
    929945} 
     
    948964 * </ul> 
    949965 */ 
    950 public int indexOf (String string, int start) { 
     966public int indexOf (char[] string, int start) { 
    951967    checkWidget (); 
    952968    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    958974    * to search the combo, an item at a time. 
    959975    */ 
    960     if (string.length () is 0) { 
     976    if (string.length is 0) { 
    961977        int count = getItemCount (); 
    962978        for (int i=start; i<count; i++) { 
    963             if (string.equals (getItem (i))) return i; 
     979            if (string==/*eq*/getItem (i)) return i; 
    964980        } 
    965981        return -1; 
     
    970986    if (!(0 <= start && start < count)) return -1; 
    971987    int index = start - 1, last = 0; 
    972     TCHAR buffer = new TCHAR (getCodePage (), string, true); 
     988    TCHAR* buffer = StrToTCHARz( string ); 
    973989    do { 
    974990        index = OS.SendMessage (handle, OS.CB_FINDSTRINGEXACT, last = index, buffer); 
    975991        if (index is OS.CB_ERR || index <= last) return -1; 
    976     } while (!string.equals (getItem (index))); 
     992    } while (string!=/*eq*/getItem (index)); 
    977993    return index; 
    978994} 
     
    981997    if (mbcsPos <= 0) return 0; 
    982998    if (OS.IsUnicode) return mbcsPos; 
    983     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    984     if (hwndText is 0) return mbcsPos; 
     999    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     1000    if (hwndText is null) return mbcsPos; 
    9851001    int mbcsSize = OS.GetWindowTextLengthA (hwndText); 
    9861002    if (mbcsSize is 0) return 0; 
    9871003    if (mbcsPos >= mbcsSize) return mbcsSize; 
    988     byte [] buffer = new byte [mbcsSize + 1]; 
    989     OS.GetWindowTextA (hwndText, buffer, mbcsSize + 1); 
    990     return OS.MultiByteToWideChar (getCodePage (), OS.MB_PRECOMPOSED, buffer, mbcsPos, null, 0); 
     1004    char [] buffer = new char [mbcsSize + 1]; 
     1005    buffer[] = 0; 
     1006    OS.GetWindowTextA (hwndText, buffer.ptr, mbcsSize + 1); 
     1007    return OS.MultiByteToWideChar (getCodePage (), OS.MB_PRECOMPOSED, buffer.ptr, mbcsPos, null, 0); 
    9911008} 
    9921009 
     
    10131030void register () { 
    10141031    super.register (); 
    1015     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    1016     if (hwndText !is 0) display.addControl (hwndText, this); 
    1017     int hwndList = OS.GetDlgItem (handle, CBID_LIST); 
    1018     if (hwndList !is 0) display.addControl (hwndList, this); 
     1032    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     1033    if (hwndText !is null) display.addControl (hwndText, this); 
     1034    auto hwndList = OS.GetDlgItem (handle, CBID_LIST); 
     1035    if (hwndList !is null) display.addControl (hwndList, this); 
    10191036} 
    10201037 
     
    10391056 
    10401057void remove (int index, bool notify) { 
    1041     TCHAR buffer = null; 
     1058    TCHAR[] buffer = null; 
    10421059    if ((style & DWT.H_SCROLL) !is 0) { 
    1043         int length = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0); 
    1044         if (length is OS.CB_ERR) { 
     1060        int length_ = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0); 
     1061        if (length_ is OS.CB_ERR) { 
    10451062            int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0); 
    10461063            if (0 <= index && index < count) error (DWT.ERROR_ITEM_NOT_REMOVED); 
    10471064            error (DWT.ERROR_INVALID_RANGE); 
    10481065        } 
    1049         buffer = new TCHAR (getCodePage (), length + 1)
    1050         int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer); 
     1066        buffer = new TCHAR[ length_ + 1]
     1067        int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer.ptr); 
    10511068        if (result is OS.CB_ERR) { 
    10521069            int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0); 
     
    10551072        } 
    10561073    } 
    1057     int length = OS.GetWindowTextLength (handle); 
     1074    int length_ = OS.GetWindowTextLength (handle); 
    10581075    int code = OS.SendMessage (handle, OS.CB_DELETESTRING, index, 0); 
    10591076    if (code is OS.CB_ERR) { 
     
    10631080    } 
    10641081    if ((style & DWT.H_SCROLL) !is 0) setScrollWidth (buffer, true); 
    1065     if (notify && length !is OS.GetWindowTextLength (handle)) { 
     1082    if (notify && length_ !is OS.GetWindowTextLength (handle)) { 
    10661083        sendEvent (DWT.Modify); 
    10671084        if (isDisposed ()) return; 
     
    11041121    } 
    11051122    int textLength = OS.GetWindowTextLength (handle); 
    1106     RECT rect = null; 
    1107     int hDC = 0, oldFont = 0, newFont = 0, newWidth = 0; 
     1123    RECT rect; 
     1124    HDC hDC; 
     1125    HFONT oldFont, newFont; 
     1126    int newWidth = 0; 
    11081127    if ((style & DWT.H_SCROLL) !is 0) { 
    1109         rect = new RECT (); 
     1128        //rect = new RECT (); 
    11101129        hDC = OS.GetDC (handle); 
    1111         newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    1112         if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
     1130        newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     1131        if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
    11131132    } 
    11141133    int cp = getCodePage (); 
    11151134    int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX; 
    11161135    for (int i=start; i<=end; i++) { 
    1117         TCHAR buffer = null; 
     1136        TCHAR[] buffer = null; 
    11181137        if ((style & DWT.H_SCROLL) !is 0) { 
    1119             int length = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, start, 0); 
    1120             if (length is OS.CB_ERR) break; 
    1121             buffer = new TCHAR (cp, length + 1)
    1122             int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, start, buffer); 
     1138            int length_ = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, start, 0); 
     1139            if (length_ is OS.CB_ERR) break; 
     1140            buffer = new TCHAR[ length_ + 1]
     1141            int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, start, buffer.ptr); 
    11231142            if (result is OS.CB_ERR) break; 
    11241143        } 
     
    11261145        if (result is OS.CB_ERR) error (DWT.ERROR_ITEM_NOT_REMOVED); 
    11271146        if ((style & DWT.H_SCROLL) !is 0) { 
    1128             OS.DrawText (hDC, buffer, -1, rect, flags); 
     1147            OS.DrawText (hDC, buffer.ptr, -1, &rect, flags); 
    11291148            newWidth = Math.max (newWidth, rect.right - rect.left); 
    11301149        } 
    11311150    } 
    11321151    if ((style & DWT.H_SCROLL) !is 0) { 
    1133         if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     1152        if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    11341153        OS.ReleaseDC (handle, hDC); 
    11351154        setScrollWidth (newWidth, false); 
     
    11681187 * </ul> 
    11691188 */ 
    1170 public void remove (String string) { 
     1189public void remove (char[] string) { 
    11711190    checkWidget (); 
    11721191    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    13041323 
    13051324    /* Verify the character */ 
    1306     String oldText = ""; 
    1307     int [] start = new int [1], end = new int [1]
    1308     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    1309     if (hwndText is 0) return true; 
     1325    char[] oldText = ""; 
     1326    int start, end
     1327    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     1328    if (hwndText is null) return true; 
    13101329    OS.SendMessage (hwndText, OS.EM_GETSEL, start, end); 
    13111330    switch (key) { 
    13121331        case 0x08:  /* Bs */ 
    1313             if (start [0] is end [0]) { 
    1314                 if (start [0] is 0) return true; 
    1315                 start [0] = start [0] - 1; 
     1332            if (start is end ) { 
     1333                if (start is 0) return true; 
     1334                start = start - 1; 
    13161335                if (!OS.IsUnicode && OS.IsDBLocale) { 
    1317                     int [] newStart = new int [1], newEnd = new int [1]
    1318                     OS.SendMessage (hwndText, OS.EM_SETSEL, start [0], end [0]); 
     1336                    int newStart, newEnd
     1337                    OS.SendMessage (hwndText, OS.EM_SETSEL, start , end ); 
    13191338                    OS.SendMessage (hwndText, OS.EM_GETSEL, newStart, newEnd); 
    1320                     if (start [0] !is newStart [0]) start [0] = start [0] - 1; 
     1339                    if (start !is newStart ) start  = start - 1; 
    13211340                } 
    1322                 start [0] = Math.max (start [0], 0); 
     1341                start = Math.max (start , 0); 
    13231342            } 
    13241343            break; 
    13251344        case 0x7F:  /* Del */ 
    1326             if (start [0] is end [0]) { 
    1327                 int length = OS.GetWindowTextLength (hwndText); 
    1328                 if (start [0] is length) return true; 
    1329                 end [0] = end [0] + 1; 
     1345            if (start is end ) { 
     1346                int length_ = OS.GetWindowTextLength (hwndText); 
     1347                if (start is length_) return true; 
     1348                end = end + 1; 
    13301349                if (!OS.IsUnicode && OS.IsDBLocale) { 
    1331                     int [] newStart = new int [1], newEnd = new int [1]
    1332                     OS.SendMessage (hwndText, OS.EM_SETSEL, start [0], end [0]); 
     1350                    int newStart, newEnd
     1351                    OS.SendMessage (hwndText, OS.EM_SETSEL, start , end ); 
    13331352                    OS.SendMessage (hwndText, OS.EM_GETSEL, newStart, newEnd); 
    1334                     if (end [0] !is newEnd [0]) end [0] = end [0] + 1; 
     1353                    if (end !is newEnd ) end  = end + 1; 
    13351354                } 
    1336                 end [0] = Math.min (end [0], length); 
     1355                end = Math.min (end , length_); 
    13371356            } 
    13381357            break; 
     
    13411360        default:    /* Tab and other characters */ 
    13421361            if (key !is '\t' && key < 0x20) return true; 
    1343             oldText = new String (new char [] {key})
     1362            oldText = [key]
    13441363            break; 
    13451364    } 
    1346     String newText = verifyText (oldText, start [0], end [0], event); 
     1365    char[] newText = verifyText (oldText, start, end, event); 
    13471366    if (newText is null) return false; 
    13481367    if (newText is oldText) return true; 
    1349     TCHAR buffer = new TCHAR (getCodePage (), newText, true); 
    1350     OS.SendMessage (hwndText, OS.EM_SETSEL, start [0], end [0]); 
     1368    TCHAR* buffer = StrToTCHARz( newText ); 
     1369    OS.SendMessage (hwndText, OS.EM_SETSEL, start, end); 
    13511370    OS.SendMessage (hwndText, OS.EM_REPLACESEL, 0, buffer); 
    13521371    return false; 
     
    13781397} 
    13791398 
    1380 void setBackgroundImage (int hBitmap) { 
     1399void setBackgroundImage (HBITMAP hBitmap) { 
    13811400    super.setBackgroundImage (hBitmap); 
    1382     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    1383     if (hwndText !is 0) OS.InvalidateRect (hwndText, null, true); 
    1384     int hwndList = OS.GetDlgItem (handle, CBID_LIST); 
    1385     if (hwndList !is 0) OS.InvalidateRect (hwndList, null, true); 
     1401    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     1402    if (hwndText !is null) OS.InvalidateRect (hwndText, null, true); 
     1403    auto hwndList = OS.GetDlgItem (handle, CBID_LIST); 
     1404    if (hwndList !is null) OS.InvalidateRect (hwndList, null, true); 
    13861405} 
    13871406 
    13881407void setBackgroundPixel (int pixel) { 
    13891408    super.setBackgroundPixel (pixel); 
    1390     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    1391     if (hwndText !is 0) OS.InvalidateRect (hwndText, null, true); 
    1392     int hwndList = OS.GetDlgItem (handle, CBID_LIST); 
    1393     if (hwndList !is 0) OS.InvalidateRect (hwndList, null, true); 
     1409    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     1410    if (hwndText !is null) OS.InvalidateRect (hwndText, null, true); 
     1411    auto hwndList = OS.GetDlgItem (handle, CBID_LIST); 
     1412    if (hwndList !is null) OS.InvalidateRect (hwndList, null, true); 
    13941413} 
    13951414 
     
    14271446        * combo box is zero, then do not set SWP_NOSIZE. 
    14281447        */ 
    1429         RECT rect = new RECT ()
    1430         OS.GetWindowRect (handle, rect); 
     1448        RECT rect
     1449        OS.GetWindowRect (handle, &rect); 
    14311450        if (rect.right - rect.left !is 0) { 
    1432             if (OS.SendMessage (handle, OS.CB_GETDROPPEDCONTROLRECT, 0, rect) !is 0) { 
     1451            if (OS.SendMessage (handle, OS.CB_GETDROPPEDCONTROLRECT, 0, &rect) !is 0) { 
    14331452                int oldWidth = rect.right - rect.left, oldHeight = rect.bottom - rect.top; 
    14341453                if (oldWidth is width && oldHeight is height) flags |= OS.SWP_NOSIZE; 
    14351454            } 
    14361455        } 
    1437         SetWindowPos (handle, 0, x, y, width, height, flags); 
     1456        SetWindowPos (handle, null, x, y, width, height, flags); 
    14381457    } else { 
    14391458        super.setBounds (x, y, width, height, flags); 
     
    14491468void setForegroundPixel (int pixel) { 
    14501469    super.setForegroundPixel (pixel); 
    1451     int hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
    1452     if (hwndText !is 0) OS.InvalidateRect (hwndText, null, true); 
    1453     int hwndList = OS.GetDlgItem (handle, CBID_LIST); 
    1454     if (hwndList !is 0) OS.InvalidateRect (hwndList, null, true); 
     1470    auto hwndText = OS.GetDlgItem (handle, CBID_EDIT); 
     1471    if (hwndText !is null) OS.InvalidateRect (hwndText, null, true); 
     1472    auto hwndList = OS.GetDlgItem (handle, CBID_LIST); 
     1473    if (hwndList !is null) OS.InvalidateRect (hwndList, null, true); 
    14551474} 
    14561475 
     
    14711490 * </ul> 
    14721491 */ 
    1473 public void setItem (int index, String string) { 
     1492public void setItem (int index, char[] string) { 
    14741493    checkWidget (); 
    14751494    if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    14951514 * </ul> 
    14961515 */ 
    1497 public void setItems (String [] items) { 
     1516public void setItems (char[] [] items) { 
    14981517    checkWidget (); 
    14991518    if (items is null) error (DWT.ERROR_NULL_ARGUMENT); 
     
    15011520        if (items [i] is null) error (DWT.ERROR_INVALID_ARGUMENT); 
    15021521    } 
    1503     RECT rect = null; 
    1504     int hDC = 0, oldFont = 0, newFont = 0, newWidth = 0; 
     1522    RECT rect; 
     1523    HDC hDC; 
     1524    HFONT oldFont, newFont; 
     1525    int newWidth = 0; 
    15051526    if ((style & DWT.H_SCROLL) !is 0) { 
    1506         rect = new RECT (); 
     1527        //rect = new RECT (); 
    15071528        hDC = OS.GetDC (handle); 
    1508         newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    1509         if (newFont !is 0) oldFont = OS.SelectObject (hDC, newFont); 
     1529        newFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     1530        if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 
    15101531        setScrollWidth (0); 
    15111532    } 
     
    15131534    int codePage = getCodePage (); 
    15141535    for (int i=0; i<items.length; i++) { 
    1515         String string = items [i]; 
    1516         TCHAR buffer = new TCHAR (codePage, string, true); 
     1536        char[] string = items [i]; 
     1537        TCHAR* buffer = StrToTCHARz( string ); 
    15171538        int code = OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer); 
    15181539        if (code is OS.CB_ERR) error (DWT.ERROR_ITEM_NOT_ADDED); 
     
    15201541        if ((style & DWT.H_SCROLL) !is 0) { 
    15211542            int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX; 
    1522             OS.DrawText (hDC, buffer, -1, rect, flags); 
     1543            OS.DrawText (hDC, buffer, -1, &rect, flags); 
    15231544            newWidth = Math.max (newWidth, rect.right - rect.left); 
    15241545        } 
    15251546    } 
    15261547    if ((style & DWT.H_SCROLL) !is 0) { 
    1527         if (newFont !is 0) OS.SelectObject (hDC, oldFont); 
     1548        if (newFont !is null) OS.SelectObject (hDC, oldFont); 
    15281549        OS.ReleaseDC (handle, hDC); 
    15291550        setScrollWidth (newWidth + 3); 
     
    15871608    } 
    15881609    OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits); 
    1589     int hwndText = 0, hwndList = 0
    1590     COMBOBOXINFO pcbi = new COMBOBOXINFO ()
     1610    HWND hwndText, hwndList
     1611    COMBOBOXINFO pcbi
    15911612    pcbi.cbSize = COMBOBOXINFO.sizeof; 
    1592     if (OS.GetComboBoxInfo (handle, pcbi)) { 
     1613    if (OS.GetComboBoxInfo (handle, &pcbi)) { 
    15931614        hwndText = pcbi.hwndItem; 
    15941615        hwndList = pcbi.hwndList; 
    15951616    } 
    1596     if (hwndText !is 0) { 
     1617    if (hwndText !is null) { 
    15971618        int bits1 = OS.GetWindowLong (hwndText, OS.GWL_EXSTYLE); 
    15981619        int bits2 = OS.GetWindowLong (hwndText, OS.GWL_STYLE); 
     
    16131634        * temporarily shrinking and then growing the width and height. 
    16141635        */ 
    1615         RECT rect = new RECT ()
    1616         OS.GetWindowRect (hwndText, rect); 
     1636        RECT rect
     1637        OS.GetWindowRect (hwndText, &rect); 
    16171638        int width = rect.right - rect.left, height = rect.bottom - rect.top; 
    1618         OS.GetWindowRect (handle, rect); 
     1639        OS.GetWindowRect (handle, &rect); 
    16191640        int widthCombo = rect.right - rect.left, heightCombo = rect.bottom - rect.top; 
    16201641        int uFlags = OS.SWP_NOMOVE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE; 
    1621         SetWindowPos (hwndText, 0, 0, 0, width - 1, height - 1, uFlags); 
    1622         SetWindowPos (handle, 0, 0, 0, widthCombo - 1, heightCombo - 1, uFlags); 
    1623         SetWindowPos (hwndText, 0, 0, 0, width, height, uFlags); 
    1624         SetWindowPos (handle, 0, 0, 0, widthCombo, heightCombo, uFlags); 
     1642        SetWindowPos (hwndText, null, 0, 0, width - 1, height - 1, uFlags); 
     1643        SetWindowPos (handle, n