Changeset 40:3052439af4b5

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

Shell

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dwt/dwthelper/utils.d

    r33 r40  
    138138} 
    139139 
     140struct GCStats { 
     141    size_t poolsize;        // total size of pool 
     142    size_t usedsize;        // bytes allocated 
     143    size_t freeblocks;      // number of blocks marked FREE 
     144    size_t freelistsize;    // total of memory on free lists 
     145    size_t pageblocks;      // number of blocks marked PAGE 
     146} 
     147 
     148extern(System) GCStats gc_stats(); 
     149 
     150size_t RuntimeTotalMemory(){ 
     151    GCStats s = gc_stats(); 
     152    return s.poolsize; 
     153} 
    140154 
    141155 
    142156 
    143157 
    144  
  • dwt/internal/win32/OS.d

    r39 r40  
    7272    } 
    7373 
    74     public static const BOOL IsPPC_
     74    public static const BOOL IsPPC_ = false
    7575    public static const BOOL IsHPC = false; 
    7676 
     
    120120        IsWinNT = (info.dwPlatformId is VER_PLATFORM_WIN32_NT); 
    121121        //IsSP_ = false; 
    122         IsPPC_ = false; 
     122        //IsPPC_ = false; 
    123123        //IsHPC = false; 
    124124        IsDBLocale = false; 
     
    10001000    public static const int LOGPIXELSX = 0x58; 
    10011001    public static const int LOGPIXELSY = 0x5a; 
    1002     public static const int LPSTR_TEXTCALLBACK = 0xffffffff; 
     1002    public static const TCHAR* LPSTR_TEXTCALLBACK = cast(TCHAR*)0xffffffff; 
    10031003    public static const int LR_DEFAULTCOLOR = 0x0; 
    10041004    public static const int LR_SHARED = 0x8000; 
     
    41954195alias WINAPI.GdiSetBatchLimit GdiSetBatchLimit; 
    41964196alias WINAPI.GetACP GetACP; 
     4197alias STDWIN.GetAsyncKeyState GetAsyncKeyState; 
    41974198alias WINAPI.GetActiveWindow GetActiveWindow; 
    41984199alias WINAPI.GetBkColor GetBkColor; 
  • dwt/widgets/Canvas.d

    r38 r40  
    5151 
    5252    alias Composite.drawBackground drawBackground; 
     53    alias Composite.windowProc windowProc; 
    5354 
    5455    Caret caret; 
  • dwt/widgets/Decorations.d

    r39 r40  
    113113 
    114114public class Decorations : Canvas { 
     115 
     116    alias Canvas.windowProc windowProc; 
     117 
    115118    Image image, smallImage, largeImage; 
    116119    Image [] images; 
  • dwt/widgets/Menu.d

    r39 r40  
    3535void fixMenus (Decorations newParent) ; 
    3636public bool isEnabled () ; 
     37public bool getEnabled () ; 
    3738} 
    3839/++ 
  • dwt/widgets/Shell.d

    r39 r40  
    1111module dwt.widgets.Shell; 
    1212 
    13 import dwt.widgets.Decorations; 
    14 import dwt.widgets.Control; 
    15 import dwt.widgets.Menu; 
    16 import dwt.widgets.ToolTip; 
    17 import dwt.internal.win32.OS; 
    18  
    19 class Shell : Decorations { 
    20     HIMC hIMC; 
    21     HWND hwndMDIClient_; 
    22     //, lpstrTip, toolTipHandle, balloonTipHandle; 
    23     Menu activeMenu; 
    24     void checkWidget (); 
    25     void updateModal () ; 
    26     void fixShell (Shell newShell, Control control) ; 
    27     void setActiveControl (Control control) ; 
    28     void register () ; 
    29     void releaseBrushes () ; 
    30     void releaseChildren (bool destroy) ; 
    31     void setToolTipText (HWND hwnd, char[] text) ; 
    32     void fixToolTip () ; 
    33     ToolTip findToolTip (int id) ; 
    34 void setToolTipTitle (HWND hwndToolTip, char[] text, HICON icon) ; 
    35 HWND hwndMDIClient () ; 
    36 } 
    37 /++ 
    3813import dwt.DWT; 
    3914import dwt.DWTException; 
     
    4419import dwt.graphics.Region; 
    4520import dwt.internal.win32.OS; 
     21 
     22import dwt.widgets.Composite; 
     23import dwt.widgets.Decorations; 
     24import dwt.widgets.Control; 
     25import dwt.widgets.Menu; 
     26import dwt.widgets.ToolTip; 
     27import dwt.widgets.Display; 
     28import dwt.widgets.TypedListener; 
     29 
     30import dwt.dwthelper.utils; 
    4631 
    4732/** 
     
    141126 * @see DWT 
    142127 */ 
    143 public class Shell extends Decorations { 
     128public class Shell : Decorations { 
    144129    Menu activeMenu; 
    145130    ToolTip [] toolTips; 
    146     int hIMC, hwndMDIClient, lpstrTip, toolTipHandle, balloonTipHandle; 
     131    HIMC hIMC; 
     132    HWND hwndMDIClient_; 
     133    TCHAR* lpstrTip; 
     134    HANDLE toolTipHandle_; 
     135    HANDLE balloonTipHandle_; 
    147136    int minWidth = DWT.DEFAULT, minHeight = DWT.DEFAULT; 
    148     int [] brushes; 
     137    HBRUSH [] brushes; 
    149138    bool showWithParent; 
    150     String toolTitle, balloonTitle; 
    151     int toolIcon, balloonIcon; 
    152     int windowProc; 
     139    char[] toolTitle, balloonTitle; 
     140    HICON toolIcon; 
     141    HICON balloonIcon; 
     142    alias extern(Windows) int function(HWND, uint, uint, int) TWindowProc; 
     143    TWindowProc windowProc_; 
    153144    Control lastActive, lockToolTipControl; 
    154     SHACTIVATEINFO psai; 
     145    static if( OS.IsWinCE ){ 
     146        SHACTIVATEINFO psai; 
     147    } 
    155148    Region region; 
    156     static /*final*/ int ToolTipProc; 
    157     static final int DialogProc; 
    158     static final TCHAR DialogClass = new TCHAR (0, OS.IsWinCE ? "Dialog" : "#32770", true); 
    159     final static int [] SYSTEM_COLORS = { 
     149    static /*final*/ TWindowProc ToolTipProc; 
     150    static const TWindowProc DialogProc; 
     151    static if( OS.IsWinCE ){ 
     152        static const TCHAR[] DialogClass = "Dialog\0"; 
     153    } 
     154    else{ 
     155        static const TCHAR[] DialogClass = "#32770\0"; 
     156    } 
     157    const static int [] SYSTEM_COLORS = [ 
    160158        OS.COLOR_BTNFACE, 
    161159        OS.COLOR_WINDOW, 
     
    164162        OS.COLOR_HIGHLIGHT, 
    165163        OS.COLOR_SCROLLBAR, 
    166     }
     164    ]
    167165    final static int BRUSHES_SIZE = 32; 
    168     static
    169         WNDCLASS lpWndClass = new WNDCLASS ()
    170         OS.GetClassInfo (0, DialogClass, lpWndClass); 
     166    static this()
     167        WNDCLASS lpWndClass
     168        OS.GetClassInfo (null, DialogClass.ptr, &lpWndClass); 
    171169        DialogProc = lpWndClass.lpfnWndProc; 
    172170    } 
     
    181179 * </ul> 
    182180 */ 
    183 public Shell () { 
    184     this ((Display) null); 
     181public this () { 
     182    this (cast(Display) null); 
    185183} 
    186184 
     
    220218 * @see DWT#SYSTEM_MODAL 
    221219 */ 
    222 public Shell (int style) { 
    223     this ((Display) null, style); 
     220public this (int style) { 
     221    this (cast(Display) null, style); 
    224222} 
    225223 
     
    243241 * </ul> 
    244242 */ 
    245 public Shell (Display display) { 
     243public this (Display display) { 
    246244    this (display, OS.IsWinCE ? DWT.NONE : DWT.SHELL_TRIM); 
    247245} 
     
    290288 * @see DWT#SYSTEM_MODAL 
    291289 */ 
    292 public Shell (Display display, int style) { 
    293     this (display, null, style, 0, false); 
    294 } 
    295  
    296 Shell (Display display, Shell parent, int style, int handle, bool embedded) { 
     290public this (Display display, int style) { 
     291    this (display, null, style, null, false); 
     292} 
     293 
     294this (Display display, Shell parent, int style, HWND handle, bool embedded) { 
    297295    super (); 
    298296    checkSubclass (); 
     
    309307    this.display = display; 
    310308    this.handle = handle; 
    311     if (handle !is 0 && !embedded) { 
     309    if (handle !is null && !embedded) { 
    312310        state |= FOREIGN_HANDLE; 
    313311    } 
     
    337335 * </ul> 
    338336 */ 
    339 public Shell (Shell parent) { 
     337public this (Shell parent) { 
    340338    this (parent, OS.IsWinCE ? DWT.NONE : DWT.DIALOG_TRIM); 
    341339} 
     
    388386 * @see DWT#SYSTEM_MODAL 
    389387 */ 
    390 public Shell (Shell parent, int style) { 
    391     this (parent !is null ? parent.display : null, parent, style, 0, false); 
     388public this (Shell parent, int style) { 
     389    this (parent !is null ? parent.display : null, parent, style, null, false); 
    392390} 
    393391 
     
    406404 * @return a new shell object containing the specified display and handle 
    407405 */ 
    408 public static Shell win32_new (Display display, int handle) { 
     406public static Shell win32_new (Display display, HWND handle) { 
    409407    return new Shell (display, null, DWT.NO_TRIM, handle, true); 
    410408} 
    411409 
    412 public static Shell internal_new (Display display, int handle) { 
     410public static Shell internal_new (Display display, HWND handle) { 
    413411    return new Shell (display, null, DWT.NO_TRIM, handle, false); 
    414412} 
     
    454452} 
    455453 
    456 int balloonTipHandle () { 
    457     if (balloonTipHandle is 0) createBalloonTipHandle (); 
    458     return balloonTipHandle
    459 } 
    460  
    461 int callWindowProc (int hwnd, int msg, int wParam, int lParam) { 
    462     if (handle is 0) return 0
    463     if (hwnd is toolTipHandle || hwnd is balloonTipHandle) { 
    464         return OS.CallWindowProc (ToolTipProc, hwnd, msg, wParam, lParam); 
    465     } 
    466     if (hwndMDIClient !is 0) { 
    467         return OS.DefFrameProc (hwnd, hwndMDIClient, msg, wParam, lParam); 
    468     } 
    469     if (windowProc !is 0) { 
    470         return OS.CallWindowProc (windowProc, hwnd, msg, wParam, lParam); 
     454HANDLE balloonTipHandle () { 
     455    if (balloonTipHandle_ is null) createBalloonTipHandle (); 
     456    return balloonTipHandle_
     457} 
     458 
     459override LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) { 
     460    if (handle is null) return LRESULT.ZERO
     461    if (hwnd is toolTipHandle_ || hwnd is balloonTipHandle_) { 
     462        return cast(LRESULT) ToolTipProc( hwnd, msg, wParam, lParam); 
     463    } 
     464    if (hwndMDIClient_ !is null) { 
     465        return cast(LRESULT) OS.DefFrameProc (hwnd, hwndMDIClient_, msg, wParam, lParam); 
     466    } 
     467    if (windowProc_ !is null) { 
     468        return cast(LRESULT) windowProc_( hwnd, msg, wParam, lParam); 
    471469    } 
    472470    if ((style & DWT.TOOL) !is 0) { 
    473471        int trim = DWT.TITLE | DWT.CLOSE | DWT.MIN | DWT.MAX | DWT.BORDER | DWT.RESIZE; 
    474         if ((style & trim) is 0) return OS.DefWindowProc (hwnd, msg, wParam, lParam); 
     472        if ((style & trim) is 0) return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 
    475473    } 
    476474    if (parent !is null) { 
     
    478476            case OS.WM_KILLFOCUS: 
    479477            case OS.WM_SETFOCUS: 
    480                 return OS.DefWindowProc (hwnd, msg, wParam, lParam); 
    481         } 
    482         return OS.CallWindowProc (DialogProc, hwnd, msg, wParam, lParam); 
    483     } 
    484     return OS.DefWindowProc (hwnd, msg, wParam, lParam); 
     478                return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 
     479        } 
     480        return cast(LRESULT) DialogProc( hwnd, msg, wParam, lParam); 
     481    } 
     482    return cast(LRESULT) OS.DefWindowProc (hwnd, msg, wParam, lParam); 
    485483} 
    486484 
     
    506504 
    507505void createBalloonTipHandle () { 
    508     balloonTipHandle = OS.CreateWindowEx ( 
     506    balloonTipHandle_ = OS.CreateWindowEx ( 
    509507        0, 
    510         new TCHAR (0, OS.TOOLTIPS_CLASS, true), 
     508        StrToTCHARz( OS.TOOLTIPS_CLASS ), 
    511509        null, 
    512510        OS.TTS_ALWAYSTIP | OS.TTS_BALLOON, 
    513511        OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0, 
    514512        handle, 
    515         0
     513        null
    516514        OS.GetModuleHandle (null), 
    517515        null); 
    518     if (balloonTipHandle is 0) error (DWT.ERROR_NO_HANDLES); 
    519     if (ToolTipProc is 0) { 
    520         ToolTipProc = OS.GetWindowLong (balloonTipHandle, OS.GWL_WNDPROC); 
     516    if (balloonTipHandle_ is null) error (DWT.ERROR_NO_HANDLES); 
     517    if (ToolTipProc is null) { 
     518        ToolTipProc = cast(TWindowProc) OS.GetWindowLong (balloonTipHandle_, OS.GWL_WNDPROC); 
    521519    } 
    522520    /* 
     
    527525    * a large value. 
    528526    */ 
    529     OS.SendMessage (balloonTipHandle, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF); 
    530     display.addControl (balloonTipHandle, this); 
    531     OS.SetWindowLong (balloonTipHandle, OS.GWL_WNDPROC, display.windowProc); 
     527    OS.SendMessage (balloonTipHandle_, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF); 
     528    display.addControl (balloonTipHandle_, this); 
     529    OS.SetWindowLong (balloonTipHandle_, OS.GWL_WNDPROC, display.windowProc); 
    532530} 
    533531 
    534532void createHandle () { 
    535     bool embedded = handle !is 0 && (state & FOREIGN_HANDLE) is 0; 
     533    bool embedded = handle !is null && (state & FOREIGN_HANDLE) is 0; 
    536534 
    537535    /* 
     
    547545    */ 
    548546//  if ((style & DWT.ON_TOP) !is 0) display.lockActiveWindow = true; 
    549     if (handle is 0 || embedded) { 
     547    if (handle is null || embedded) { 
    550548        super.createHandle (); 
    551549    } else { 
     
    554552            state |= THEME_BACKGROUND; 
    555553        } 
    556         windowProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC); 
     554        windowProc_ = cast(TWindowProc) OS.GetWindowLong (handle, OS.GWL_WNDPROC); 
    557555    } 
    558556 
     
    579577        OS.SetWindowLong (handle, OS.GWL_STYLE, bits); 
    580578        int flags = OS.SWP_DRAWFRAME | OS.SWP_NOMOVE | OS.SWP_NOSIZE | OS.SWP_NOZORDER | OS.SWP_NOACTIVATE; 
    581         SetWindowPos (handle, 0, 0, 0, 0, 0, flags); 
    582         if (OS.IsWinCE) _setMaximized (true); 
    583         if (OS.IsPPC) { 
     579        SetWindowPos (handle, null, 0, 0, 0, 0, flags); 
     580        static if (OS.IsWinCE) _setMaximized (true); 
     581        static if (OS.IsPPC_) { 
    584582            psai = new SHACTIVATEINFO (); 
    585583            psai.cbSize = SHACTIVATEINFO.sizeof; 
     
    588586    if (OS.IsDBLocale) { 
    589587        hIMC = OS.ImmCreateContext (); 
    590         if (hIMC !is 0) OS.ImmAssociateContext (handle, hIMC); 
     588        if (hIMC !is null) OS.ImmAssociateContext (handle, hIMC); 
    591589    } 
    592590} 
     
    604602    toolTip.id = id + Display.ID_START; 
    605603    if (OS.IsWinCE) return; 
    606     TOOLINFO lpti = new TOOLINFO ()
     604    TOOLINFO lpti
    607605    lpti.cbSize = TOOLINFO.sizeof; 
    608606    lpti.hwnd = handle; 
     
    610608    lpti.uFlags = OS.TTF_TRACK; 
    611609    lpti.lpszText = OS.LPSTR_TEXTCALLBACK; 
    612     OS.SendMessage (toolTip.hwndToolTip (), OS.TTM_ADDTOOL, 0, lpti); 
     610    OS.SendMessage (toolTip.hwndToolTip (), OS.TTM_ADDTOOL, 0, &lpti); 
    613611} 
    614612 
    615613void createToolTipHandle () { 
    616     toolTipHandle = OS.CreateWindowEx ( 
     614    toolTipHandle_ = OS.CreateWindowEx ( 
    617615        0, 
    618         new TCHAR (0, OS.TOOLTIPS_CLASS, true), 
     616        StrToTCHARz( OS.TOOLTIPS_CLASS ), 
    619617        null, 
    620618        OS.TTS_ALWAYSTIP, 
    621619        OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0, 
    622620        handle, 
    623         0
     621        null
    624622        OS.GetModuleHandle (null), 
    625623        null); 
    626     if (toolTipHandle is 0) error (DWT.ERROR_NO_HANDLES); 
    627     if (ToolTipProc is 0) { 
    628         ToolTipProc = OS.GetWindowLong (toolTipHandle, OS.GWL_WNDPROC); 
     624    if (toolTipHandle_ is null) error (DWT.ERROR_NO_HANDLES); 
     625    if (ToolTipProc is null) { 
     626        ToolTipProc = cast(TWindowProc) OS.GetWindowLong (toolTipHandle_, OS.GWL_WNDPROC); 
    629627    } 
    630628    /* 
     
    635633    * a large value. 
    636634    */ 
    637     OS.SendMessage (toolTipHandle, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF); 
    638     display.addControl (toolTipHandle, this); 
    639     OS.SetWindowLong (toolTipHandle, OS.GWL_WNDPROC, display.windowProc); 
     635    OS.SendMessage (toolTipHandle_, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF); 
     636    display.addControl (toolTipHandle_, this); 
     637    OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, display.windowProc); 
    640638} 
    641639 
    642640void deregister () { 
    643641    super.deregister (); 
    644     if (toolTipHandle !is 0) display.removeControl (toolTipHandle); 
    645     if (balloonTipHandle !is 0) display.removeControl (balloonTipHandle); 
     642    if (toolTipHandle_ !is null) display.removeControl (toolTipHandle_); 
     643    if (balloonTipHandle_ !is null) display.removeControl (balloonTipHandle_); 
    646644} 
    647645 
     
    650648    toolTips [toolTip.id - Display.ID_START] = null; 
    651649    if (OS.IsWinCE) return; 
    652     if (balloonTipHandle !is 0) { 
    653         TOOLINFO lpti = new TOOLINFO ()
     650    if (balloonTipHandle_ !is null) { 
     651        TOOLINFO lpti
    654652        lpti.cbSize = TOOLINFO.sizeof; 
    655653        lpti.uId = toolTip.id; 
    656654        lpti.hwnd = handle; 
    657         OS.SendMessage (balloonTipHandle, OS.TTM_DELTOOL, 0, lpti); 
     655        OS.SendMessage (balloonTipHandle_, OS.TTM_DELTOOL, 0, &lpti); 
    658656    } 
    659657    toolTip.id = -1; 
     
    697695} 
    698696 
    699 int findBrush (int value, int lbStyle) { 
     697HBRUSH findBrush (int value, int lbStyle) { 
    700698    if (lbStyle is OS.BS_SOLID) { 
    701699        for (int i=0; i<SYSTEM_COLORS.length; i++) { 
     
    705703        } 
    706704    } 
    707     if (brushes is null) brushes = new int [BRUSHES_SIZE]; 
    708     LOGBRUSH logBrush = new LOGBRUSH ()
     705    if (brushes is null) brushes = new HBRUSH [BRUSHES_SIZE]; 
     706    LOGBRUSH logBrush
    709707    for (int i=0; i<brushes.length; i++) { 
    710         int hBrush = brushes [i]; 
    711         if (hBrush is 0) break; 
    712         OS.GetObject (hBrush, LOGBRUSH.sizeof, logBrush); 
     708        HBRUSH hBrush = brushes [i]; 
     709        if (hBrush is null) break; 
     710        OS.GetObject (hBrush, LOGBRUSH.sizeof, &logBrush); 
    713711        switch (logBrush.lbStyle) { 
    714712            case OS.BS_SOLID: 
     
    724722        } 
    725723    } 
    726     int length = brushes.length; 
    727     int hBrush = brushes [--length]; 
    728     if (hBrush !is 0) OS.DeleteObject (hBrush); 
    729     System.arraycopy (brushes, 0, brushes, 1, length); 
     724    int length_ = brushes.length; 
     725    HBRUSH hBrush = brushes [--length_]; 
     726    if (hBrush !is null) OS.DeleteObject (hBrush); 
     727    System.arraycopy (brushes, 0, brushes, 1, length_); 
    730728    switch (lbStyle) { 
    731729        case OS.BS_SOLID: 
     
    733731            break; 
    734732        case OS.BS_PATTERN: 
    735             hBrush = OS.CreatePatternBrush (value); 
     733            hBrush = OS.CreatePatternBrush ( cast(HBITMAP) value); 
    736734            break; 
    737735    } 
     
    767765    * shell before disposing or hiding the active shell. 
    768766    */ 
    769     int hwndParent = OS.GetParent (handle); 
    770     if (hwndParent !is 0 && handle is OS.GetActiveWindow ()) { 
     767    auto hwndParent = OS.GetParent (handle); 
     768    if (hwndParent !is null && handle is OS.GetActiveWindow ()) { 
    771769        if (!OS.IsWindowEnabled (hwndParent) && OS.IsWindowVisible (hwndParent)) { 
    772770            OS.SetActiveWindow (hwndParent); 
     
    778776    if (this is newShell) return; 
    779777    if (control is lastActive) setActiveControl (null); 
    780     String toolTipText = control.toolTipText
     778    char[] toolTipText = control.toolTipText_
    781779    if (toolTipText !is null) { 
    782780        control.setToolTipText (this, null); 
     
    798796    */ 
    799797    if (OS.COMCTL32_MAJOR >= 6) { 
    800         if (toolTipHandle is 0) return; 
    801         TOOLINFO lpti = new TOOLINFO ()
     798        if (toolTipHandle_ is null) return; 
     799        TOOLINFO lpti
    802800        lpti.cbSize = TOOLINFO.sizeof; 
    803         if (OS.SendMessage (toolTipHandle, OS.TTM_GETCURRENTTOOL, 0, lpti) !is 0) { 
     801        if (OS.SendMessage (toolTipHandle_, OS.TTM_GETCURRENTTOOL, 0, &lpti) !is 0) { 
    804802            if ((lpti.uFlags & OS.TTF_IDISHWND) !is 0) { 
    805                 OS.SendMessage (toolTipHandle, OS.TTM_DELTOOL, 0, lpti); 
    806                 OS.SendMessage (toolTipHandle, OS.TTM_ADDTOOL, 0, lpti); 
     803                OS.SendMessage (toolTipHandle_, OS.TTM_DELTOOL, 0, &lpti); 
     804                OS.SendMessage (toolTipHandle_, OS.TTM_ADDTOOL, 0, &lpti); 
    807805            } 
    808806        } 
     
    846844        if (OS.IsIconic (handle)) return super.getBounds (); 
    847845    } 
    848     RECT rect = new RECT ()
    849     OS.GetWindowRect (handle, rect); 
     846    RECT rect
     847    OS.GetWindowRect (handle, &rect); 
    850848    int width = rect.right - rect.left; 
    851849    int height = rect.bottom - rect.top; 
     
    854852 
    855853ToolTip getCurrentToolTip () { 
    856     if (toolTipHandle !is 0) { 
    857         ToolTip tip = getCurrentToolTip (toolTipHandle); 
     854    if (toolTipHandle_ !is null) { 
     855        ToolTip tip = getCurrentToolTip (toolTipHandle_); 
    858856        if (tip !is null) return tip; 
    859857    } 
    860     if (balloonTipHandle !is 0) { 
    861         ToolTip tip = getCurrentToolTip (balloonTipHandle); 
     858    if (balloonTipHandle_ !is null) { 
     859        ToolTip tip = getCurrentToolTip (balloonTipHandle_); 
    862860        if (tip !is null) return tip; 
    863861    } 
     
    865863} 
    866864 
    867 ToolTip getCurrentToolTip (int hwndToolTip) { 
    868     if (hwndToolTip is 0) return null; 
     865ToolTip getCurrentToolTip (HWND hwndToolTip) { 
     866    if (hwndToolTip is null) return null; 
    869867    if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, 0) !is 0) { 
    870         TOOLINFO lpti = new TOOLINFO ()
     868        TOOLINFO lpti
    871869        lpti.cbSize = TOOLINFO.sizeof; 
    872         if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, lpti) !is 0) { 
     870        if (OS.SendMessage (hwndToolTip, OS.TTM_GETCURRENTTOOL, 0, &lpti) !is 0) { 
    873871            if ((lpti.uFlags & OS.TTF_IDISHWND) is 0) return findToolTip (lpti.uId); 
    874872        } 
     
    902900    checkWidget (); 
    903901    if (!OS.IsDBLocale) return 0; 
    904     int hIMC = OS.ImmGetContext (handle); 
    905     int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1]
    906     bool open = OS.ImmGetOpenStatus (hIMC); 
    907     if (open) open = OS.ImmGetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence); 
     902    auto hIMC = OS.ImmGetContext (handle); 
     903    uint lpfdwConversion, lpfdwSentence
     904    bool open = cast(bool) OS.ImmGetOpenStatus (hIMC); 
     905    if (open) open = cast(bool) OS.ImmGetConversionStatus (hIMC, &lpfdwConversion, &lpfdwSentence); 
    908906    OS.ImmReleaseContext (handle, hIMC); 
    909907    if (!open) return DWT.NONE; 
    910908    int result = 0; 
    911     if ((lpfdwConversion [0] & OS.IME_CMODE_ROMAN) !is 0) result |= DWT.ROMAN; 
    912     if ((lpfdwConversion [0] & OS.IME_CMODE_FULLSHAPE) !is 0) result |= DWT.DBCS; 
    913     if ((lpfdwConversion [0] & OS.IME_CMODE_KATAKANA) !is 0) return result | DWT.PHONETIC; 
    914     if ((lpfdwConversion [0] & OS.IME_CMODE_NATIVE) !is 0) return result | DWT.NATIVE; 
     909    if ((lpfdwConversion & OS.IME_CMODE_ROMAN) !is 0) result |= DWT.ROMAN; 
     910    if ((lpfdwConversion & OS.IME_CMODE_FULLSHAPE) !is 0) result |= DWT.DBCS; 
     911    if ((lpfdwConversion & OS.IME_CMODE_KATAKANA) !is 0) return result | DWT.PHONETIC; 
     912    if ((lpfdwConversion & OS.IME_CMODE_NATIVE) !is 0) return result | DWT.NATIVE; 
    915913    return result | DWT.ALPHA; 
    916914} 
     
    918916public Point getLocation () { 
    919917    checkWidget (); 
    920     if (!OS.IsWinCE) { 
     918    static if (!OS.IsWinCE) { 
    921919        if (OS.IsIconic (handle)) { 
    922920            return super.getLocation (); 
    923921        } 
    924922    } 
    925     RECT rect = new RECT ()
    926     OS.GetWindowRect (handle, rect); 
     923    RECT rect
     924    OS.GetWindowRect (handle, &rect); 
    927925    return new Point (rect.left, rect.top); 
    928926} 
     
    955953            height = Math.max (height, OS.GetSystemMetrics (OS.SM_CYMINTRACK)); 
    956954        } else { 
    957             RECT rect = new RECT ()
     955            RECT rect
    958956            int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE); 
    959957            int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); 
    960             OS.AdjustWindowRectEx (rect, bits1, false, bits2); 
     958            OS.AdjustWindowRectEx (&rect, bits1, false, bits2); 
    961959            height = Math.max (height, rect.bottom - rect.top); 
    962960        } 
     
    994992        if (OS.IsIconic (handle)) return super.getSize (); 
    995993    } 
    996     RECT rect = new RECT ()
    997     OS.GetWindowRect (handle, rect); 
     994    RECT rect
     995    OS.GetWindowRect (handle, &rect); 
    998996    int width = rect.right - rect.left; 
    999997    int height = rect.bottom - rect.top; 
     
    10511049} 
    10521050 
    1053 int hwndMDIClient () { 
    1054     if (hwndMDIClient is 0) { 
     1051HWND hwndMDIClient () { 
     1052    if (hwndMDIClient_ is null) { 
    10551053        int widgetStyle = OS.MDIS_ALLCHILDSTYLES | OS.WS_CHILD | OS.WS_CLIPCHILDREN | OS.WS_CLIPSIBLINGS; 
    1056         hwndMDIClient = OS.CreateWindowEx ( 
     1054        hwndMDIClient_ = OS.CreateWindowEx ( 
    10571055            0, 
    1058             new TCHAR (0, "MDICLIENT", true), 
     1056            StrToTCHARz("MDICLIENT"), 
    10591057            null, 
    10601058            widgetStyle, 
    10611059            0, 0, 0, 0, 
    10621060            handle, 
    1063             0
     1061            null
    10641062            OS.GetModuleHandle (null), 
    10651063            new CREATESTRUCT ()); 
    1066 //      OS.ShowWindow (hwndMDIClient, OS.SW_SHOW); 
    1067     } 
    1068     return hwndMDIClient
     1064//      OS.ShowWindow (hwndMDIClient_, OS.SW_SHOW); 
     1065    } 
     1066    return hwndMDIClient_
    10691067} 
    10701068 
     
    10921090public void open () { 
    10931091    checkWidget (); 
    1094     STARTUPINFO lpStartUpInfo = Display.lpStartupInfo; 
     1092    STARTUPINFO* lpStartUpInfo = Display.lpStartupInfo; 
    10951093    if (lpStartUpInfo is null || (lpStartUpInfo.dwFlags & OS.STARTF_USESHOWWINDOW) is 0) { 
    10961094        bringToTop (); 
     
    11221120    * most notably WM_ACTIVATE. 
    11231121    */ 
    1124     MSG msg = new MSG ()
     1122    MSG msg
    11251123    int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_SENDMESSAGE; 
    1126     OS.PeekMessage (msg, 0, 0, 0, flags); 
     1124    OS.PeekMessage (&msg, null, 0, 0, flags); 
    11271125    if (!restoreFocus () && !traverseGroup (true)) setFocus (); 
    11281126} 
     
    11301128void register () { 
    11311129    super.register (); 
    1132     if (toolTipHandle !is 0) display.addControl (toolTipHandle, this); 
    1133     if (balloonTipHandle !is 0) display.addControl (balloonTipHandle, this); 
     1130    if (toolTipHandle_ !is null) display.addControl (toolTipHandle_, this); 
     1131    if (balloonTipHandle_ !is null) display.addControl (balloonTipHandle_, this); 
    11341132} 
    11351133 
     
    11371135    if (brushes !is null) { 
    11381136        for (int i=0; i<brushes.length; i++) { 
    1139             if (brushes [i] !is 0) OS.DeleteObject (brushes [i]); 
     1137            if (brushes [i] !is null) OS.DeleteObject (brushes [i]); 
    11401138        } 
    11411139    } 
     
    11651163void releaseHandle () { 
    11661164    super.releaseHandle (); 
    1167     hwndMDIClient = 0
     1165    hwndMDIClient_ = null
    11681166} 
    11691167 
     
    11771175    activeMenu = null; 
    11781176    display.clearModal (this); 
    1179     if (lpstrTip !is 0) { 
    1180         int hHeap = OS.GetProcessHeap (); 
     1177    if (lpstrTip !is null) { 
     1178        auto hHeap = OS.GetProcessHeap (); 
    11811179        OS.HeapFree (hHeap, 0, lpstrTip); 
    11821180    } 
    1183     lpstrTip = 0
    1184     toolTipHandle = balloonTipHandle = 0
     1181    lpstrTip = null
     1182    toolTipHandle_ = balloonTipHandle_ = null
    11851183    if (OS.IsDBLocale) { 
    1186         if (hIMC !is 0) OS.ImmDestroyContext (hIMC); 
     1184        if (hIMC !is null) OS.ImmDestroyContext (hIMC); 
    11871185    } 
    11881186    lastActive = null; 
     
    12251223} 
    12261224 
    1227 LRESULT selectPalette (int hPalette) { 
    1228     int hDC = OS.GetDC (handle); 
    1229     int hOld = OS.SelectPalette (hDC, hPalette, false); 
     1225LRESULT selectPalette (HPALETTE hPalette) { 
     1226    auto hDC = OS.GetDC (handle); 
     1227    auto hOld = OS.SelectPalette (hDC, hPalette, false); 
    12301228    int result = OS.RealizePalette (hDC); 
    12311229    if (result > 0) { 
     
    13371335    if (!OS.IsDBLocale) return; 
    13381336    bool imeOn = mode !is DWT.NONE && mode !is DWT.ROMAN; 
    1339     int hIMC = OS.ImmGetContext (handle); 
     1337    auto hIMC = OS.ImmGetContext (handle); 
    13401338    OS.ImmSetOpenStatus (hIMC, imeOn); 
    13411339    if (imeOn) { 
    1342         int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1]
    1343         if (OS.ImmGetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence)) { 
     1340        uint lpfdwConversion, lpfdwSentence
     1341        if (OS.ImmGetConversionStatus (hIMC, &lpfdwConversion, &lpfdwSentence)) { 
    13441342            int newBits = 0; 
    13451343            int oldBits = OS.IME_CMODE_NATIVE | OS.IME_CMODE_KATAKANA; 
     
    13631361                oldBits |= OS.IME_CMODE_ROMAN; 
    13641362            } 
    1365             lpfdwConversion [0] |= newBits;  lpfdwConversion [0] &= ~oldBits; 
    1366             OS.ImmSetConversionStatus (hIMC, lpfdwConversion [0], lpfdwSentence [0]); 
     1363            lpfdwConversion |= newBits;  lpfdwConversion &= ~oldBits; 
     1364            OS.ImmSetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence); 
    13671365        } 
    13681366    } 
     
    13941392            heightLimit = OS.GetSystemMetrics (OS.SM_CYMINTRACK); 
    13951393        } else { 
    1396             RECT rect = new RECT ()
     1394            RECT rect
    13971395            int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE); 
    13981396            int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE); 
    1399             OS.AdjustWindowRectEx (rect, bits1, false, bits2); 
     1397            OS.AdjustWindowRectEx (&rect, bits1, false, bits2); 
    14001398            heightLimit = rect.bottom - rect.top; 
    14011399        } 
     
    14351433 
    14361434void setItemEnabled (int cmd, bool enabled) { 
    1437     int hMenu = OS.GetSystemMenu (handle, false); 
    1438     if (hMenu is 0) return; 
     1435    auto hMenu = OS.GetSystemMenu (handle, false); 
     1436    if (hMenu is null) return; 
    14391437    int flags = OS.MF_ENABLED; 
    14401438    if (!enabled) flags = OS.MF_DISABLED | OS.MF_GRAYED; 
     
    14701468    if ((style & DWT.NO_TRIM) is 0) return; 
    14711469    if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT); 
    1472     int hRegion = 0
     1470    HRGN hRegion
    14731471    if (region !is null) { 
    14741472        hRegion = OS.CreateRectRgn (0, 0, 0, 0); 
     
    14791477} 
    14801478 
    1481 void setToolTipText (int hwnd, String text) { 
     1479void setToolTipText (HWND hwnd, char[] text) { 
    14821480    if (OS.IsWinCE) return; 
    1483     TOOLINFO lpti = new TOOLINFO ()
     1481    TOOLINFO lpti
    14841482    lpti.cbSize = TOOLINFO.sizeof; 
    14851483    lpti.hwnd = handle; 
    1486     lpti.uId = hwnd; 
    1487     int hwndToolTip = toolTipHandle (); 
     1484    lpti.uId = cast(uint) hwnd; 
     1485    auto hwndToolTip = toolTipHandle (); 
    14881486    if (text is null) { 
    1489         OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, lpti); 
     1487        OS.SendMessage (hwndToolTip, OS.TTM_DELTOOL, 0, cast(int)&lpti); 
    14901488    } else { 
    1491         if (OS.SendMessage (hwndToolTip, OS.TTM_GETTOOLINFO, 0, lpti) !is 0) { 
     1489        if (OS.SendMessage (hwndToolTip, OS.TTM_GETTOOLINFO, 0, cast(int)&lpti) !is 0) { 
    14921490            OS.SendMessage (hwndToolTip, OS.TTM_UPDATE, 0, 0); 
    14931491        } else { 
    14941492            lpti.uFlags = OS.TTF_IDISHWND | OS.TTF_SUBCLASS; 
    14951493            lpti.lpszText = OS.LPSTR_TEXTCALLBACK; 
    1496             OS.SendMessage (hwndToolTip, OS.TTM_ADDTOOL, 0, lpti); 
    1497         } 
    1498     } 
    1499 } 
    1500  
    1501 void setToolTipText (NMTTDISPINFO lpnmtdi, byte [] buffer) { 
     1494            OS.SendMessage (hwndToolTip, OS.TTM_ADDTOOL, 0, cast(int)&lpti); 
     1495        } 
     1496    } 
     1497} 
     1498 
     1499void setToolTipText (NMTTDISPINFO* lpnmtdi, byte [] buffer) { 
    15021500    /* 
    15031501    * Ensure that the current position of the mouse 
     
    15071505    */ 
    15081506    if (!hasCursor ()) return; 
    1509     int hHeap = OS.GetProcessHeap (); 
    1510     if (lpstrTip !is 0) OS.HeapFree (hHeap, 0, lpstrTip); 
     1507    auto hHeap = OS.GetProcessHeap (); 
     1508    if (lpstrTip !is null) OS.HeapFree (hHeap, 0, lpstrTip); 
    15111509    int byteCount = buffer.length; 
    1512     lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
    1513     OS.MoveMemory (lpstrTip, buffer, byteCount); 
     1510    lpstrTip = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
     1511    (cast(byte*)lpstrTip)[ 0 .. byteCount ] = buffer; 
     1512    //OS.MoveMemory (lpstrTip, buffer, byteCount); 
    15141513    lpnmtdi.lpszText = lpstrTip; 
    15151514} 
     
    15231522    */ 
    15241523    if (!hasCursor ()) return; 
    1525     int hHeap = OS.GetProcessHeap (); 
    1526     if (lpstrTip !is 0) OS.HeapFree (hHeap, 0, lpstrTip); 
     1524    auto hHeap = OS.GetProcessHeap (); 
     1525    if (lpstrTip !is null) OS.HeapFree (hHeap, 0, lpstrTip); 
    15271526    int byteCount = buffer.length * 2; 
    1528     lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
    1529     OS.MoveMemory (lpstrTip, buffer, byteCount); 
     1527    lpstrTip = cast(TCHAR*)OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, byteCount); 
     1528    (cast(char*)lpstrTip)[ 0 .. byteCount ] = buffer; 
     1529    //OS.MoveMemory (lpstrTip, buffer, byteCount); 
    15301530    lpnmtdi.lpszText = lpstrTip; 
    15311531} 
    15321532 
    1533 void setToolTipTitle (int hwndToolTip, String text, int icon) { 
     1533void setToolTipTitle (HWND hwndToolTip, char[] text, HICON icon) { 
    15341534    /* 
    15351535    * Bug in Windows.  For some reason, when TTM_SETTITLE 
     
    15481548    * NOTE:  This only happens on Vista. 
    15491549    */ 
    1550     if (hwndToolTip !is toolTipHandle && hwndToolTip !is balloonTipHandle) { 
     1550    if (hwndToolTip !is toolTipHandle_ && hwndToolTip !is balloonTipHandle_) { 
    15511551        return; 
    15521552    } 
    1553     if (hwndToolTip is toolTipHandle) { 
    1554         if (text is toolTitle || (toolTitle !is null && toolTitle.equals (text))) { 
     1553    if (hwndToolTip is toolTipHandle_) { 
     1554        if (text is toolTitle || (toolTitle !is null && toolTitle ==/*eq*/text )) { 
    15551555            if (icon is toolIcon) return; 
    15561556        } 
     
    15581558        toolIcon = icon; 
    15591559    } else { 
    1560         if (hwndToolTip is balloonTipHandle) { 
    1561             if (text is balloonTitle || (balloonTitle !is null && balloonTitle.equals (text))) { 
     1560        if (hwndToolTip is balloonTipHandle_) { 
     1561            if (text is balloonTitle || (balloonTitle !is null && balloonTitle==/*eq*/text)) { 
    15621562                if (icon is toolIcon) return; 
    15631563            } 
     
    15671567    } 
    15681568    if (text !is null) { 
    1569         TCHAR pszTitle = new TCHAR (getCodePage (), text, true); 
    1570         OS.SendMessage (hwndToolTip, OS.TTM_SETTITLE, icon, pszTitle); 
     1569        static if( OS.IsUnicode ){ 
     1570            TCHAR* pszTitle = StrToTCHARz( text); 
     1571        } 
     1572        else { 
     1573            TCHAR* pszTitle = StrToTCHARz( text, getCodePage ()); 
     1574        } 
     1575        OS.SendMessage (hwndToolTip, OS.TTM_SETTITLE, icon, cast(int)pszTitle); 
    15711576    } else { 
    15721577        OS.SendMessage (hwndToolTip, OS.TTM_SETTITLE, 0, 0); 
     
    16001605                if (isDisposed ()) return; 
    16011606            } 
    1602             int hwndShell = OS.GetActiveWindow (); 
    1603             if (hwndShell is 0) { 
     1607            auto hwndShell = OS.GetActiveWindow (); 
     1608            if (hwndShell is null) { 
    16041609                if (parent !is null) hwndShell = parent.handle; 
    16051610            } 
    1606             if (hwndShell !is 0) { 
     1611            if (hwndShell !is null) { 
    16071612                OS.SendMessage (hwndShell, OS.WM_CANCELMODE, 0, 0); 
    16081613            } 
     
    16361641void subclass () { 
    16371642    super.subclass (); 
    1638     if (ToolTipProc !is 0) { 
     1643    if (ToolTipProc !is null) { 
    16391644        int newProc = display.windowProc; 
    1640         if (toolTipHandle !is 0) { 
    1641             OS.SetWindowLong (toolTipHandle, OS.GWL_WNDPROC, newProc); 
    1642         } 
    1643         if (balloonTipHandle !is 0) { 
    1644             OS.SetWindowLong (balloonTipHandle, OS.GWL_WNDPROC, newProc); 
    1645         } 
    1646     } 
    1647 } 
    1648  
    1649 int toolTipHandle () { 
    1650     if (toolTipHandle is 0) createToolTipHandle (); 
    1651     return toolTipHandle
    1652 } 
    1653  
    1654 bool translateAccelerator (MSG msg) { 
     1645        if (toolTipHandle_ !is null) { 
     1646            OS.SetWindowLong (toolTipHandle_, OS.GWL_WNDPROC, newProc); 
     1647        } 
     1648        if (balloonTipHandle_ !is null) { 
     1649            OS.SetWindowLong (balloonTipHandle_, OS.GWL_WNDPROC, newProc); 
     1650        } 
     1651    } 
     1652} 
     1653 
     1654HANDLE toolTipHandle () { 
     1655    if (toolTipHandle_ is null) createToolTipHandle (); 
     1656    return toolTipHandle_
     1657} 
     1658 
     1659bool translateAccelerator (MSG* msg) { 
    16551660    if (!isEnabled () || !isActive ()) return false; 
    16561661