Changeset 37:e3a5d61b33cd

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

Composite

Files:

Legend:

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

    r35 r37  
    4141 
    4242public class OS : C { 
     43 
     44    public static HINSTANCE GetLibraryHandle(){ 
     45        //PORTING_FIXME: GetLibraryHandle 
     46        // is the hInstance of the DLL or null, if not a DLL. 
     47        // At the moment DWT is statically linked but this needs to be fixed 
     48        return null; 
     49    } 
     50 
    4351 
    4452    private static int getNOTIFYICONDATAA_V2_SIZE (){ 
     
    40414049alias WINAPI.AlphaBlend AlphaBlend; 
    40424050alias WINAPI.Arc Arc; 
     4051alias WINAPI.BeginBufferedPaint BeginBufferedPaint; 
    40434052alias WINAPI.BeginDeferWindowPos BeginDeferWindowPos; 
    40444053alias WINAPI.BeginPaint BeginPaint; 
     
    41464155alias WINAPI.EnableWindow EnableWindow; 
    41474156alias WINAPI.EndDeferWindowPos EndDeferWindowPos; 
     4157alias WINAPI.EndBufferedPaint EndBufferedPaint; 
    41484158alias WINAPI.EndDoc EndDoc; 
    41494159alias WINAPI.EndPage EndPage; 
     
    42874297alias WINAPI.GetVersionExW GetVersionExW; 
    42884298alias WINAPI.GetWindow GetWindow; 
     4299alias STDWIN.GetWindowDC GetWindowDC; 
    42894300alias STDWIN.GetWindowOrgEx GetWindowOrgEx; 
    42904301alias WINAPI.GetWindowLongA GetWindowLongA; 
  • dwt/internal/win32/WINAPI.d

    r33 r37  
    1010import tango_sys_win32.Types; 
    1111import STDWIN = tango_sys_win32.UserGdi; 
     12 
     13alias HANDLE HPAINTBUFFER; 
    1214 
    1315extern (Windows){ 
     
    120122    HWND hWnd 
    121123); 
     124HPAINTBUFFER BeginBufferedPaint( 
     125    HDC hdcTarget, 
     126    RECT *prcTarget, 
     127    uint/+BP_BUFFERFORMAT+/ dwFormat, 
     128    void*/+BP_PAINTPARAMS+/ pPaintParams, 
     129    HDC *phdc 
     130); 
     131HRESULT EndBufferedPaint( 
     132    HPAINTBUFFER hBufferedPaint, 
     133    BOOL fUpdateTarget 
     134); 
    122135} 
    123  
     136//-------------------------------------------------------------------------------------- 
    124137 
    125138// Windows API 
  • dwt/widgets/Composite.d

    r35 r37  
    1313module dwt.widgets.Composite; 
    1414 
    15 import dwt.widgets.Scrollable; 
    16 import dwt.widgets.Control; 
    17 import dwt.widgets.Layout; 
    18 import dwt.graphics.Font; 
    19 import dwt.internal.win32.OS; 
    20  
    21 class Composite : Scrollable { 
    22     Layout layout_; 
    23     int font; 
    24     WINDOWPOS* [] lpwp; 
    25     Control [] tabList; 
    26     int layoutCount, backgroundMode; 
    27  
    28 public Control [] getChildren () ; 
    29 void updateFont (Font oldFont, Font newFont) ; 
    30 public void layout () ; 
    31 public void layout (bool ) ; 
    32 public void layout (bool , bool ) ; 
    33 public void layout (Control[]) ; 
    34 Control [] _getTabList () ; 
    35 void removeControl (Control control) ; 
    36 Control [] _getChildren () ; 
    37 
    38 /++ 
     15 
    3916import dwt.DWT; 
    4017import dwt.DWTException; 
     
    4623import dwt.graphics.Rectangle; 
    4724import dwt.internal.win32.OS; 
     25import dwt.widgets.Scrollable; 
     26import dwt.widgets.Control; 
     27import dwt.widgets.Layout; 
     28import dwt.widgets.Menu; 
     29import dwt.widgets.Shell; 
     30import dwt.widgets.Decorations; 
     31import dwt.widgets.Event; 
     32import dwt.widgets.ToolTip; 
     33import dwt.widgets.Display; 
     34 
     35import dwt.dwthelper.System; 
     36import dwt.dwthelper.utils; 
    4837 
    4938/** 
     
    7766 */ 
    7867 
    79 public class Composite extends Scrollable { 
    80     Layout layout
    81     int font; 
     68public class Composite : Scrollable { 
     69    Layout layout_
     70    HFONT font; 
    8271    WINDOWPOS* [] lpwp; 
    8372    Control [] tabList; 
     
    8776 * Prevents uninitialized instances from being created outside the package. 
    8877 */ 
    89 Composite () { 
     78this () { 
    9079} 
    9180 
     
    120109 * @see Widget#getStyle 
    121110 */ 
    122 public Composite (Composite parent, int style) { 
     111public this (Composite parent, int style) { 
    123112    super (parent, style); 
    124113} 
     
    126115Control [] _getChildren () { 
    127116    int count = 0; 
    128     int hwndChild = OS.GetWindow (handle, OS.GW_CHILD); 
    129     if (hwndChild is 0) return new Control [0]; 
    130     while (hwndChild !is 0) { 
     117    auto hwndChild = OS.GetWindow (handle, OS.GW_CHILD); 
     118    if (hwndChild is null) return new Control [0]; 
     119    while (hwndChild !is null) { 
    131120        count++; 
    132121        hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT); 
     
    135124    int index = 0; 
    136125    hwndChild = OS.GetWindow (handle, OS.GW_CHILD); 
    137     while (hwndChild !is 0) { 
     126    while (hwndChild !is null) { 
    138127        Control control = display.getControl (hwndChild); 
    139128        if (control !is null && control !is this) { 
     
    204193        Composite composite = child.parent; 
    205194        while (child !is this) { 
    206             if (composite.layout is null || !composite.layout.flushCache (child)) { 
     195            if (composite.layout_ is null || !composite.layout_.flushCache (child)) { 
    207196                composite.state |= LAYOUT_CHANGED; 
    208197            } 
     
    243232    checkWidget (); 
    244233    Point size; 
    245     if (layout !is null) { 
     234    if (layout_ !is null) { 
    246235        if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) { 
    247236            changed |= (state & LAYOUT_CHANGED) !is 0; 
    248237            state &= ~LAYOUT_CHANGED; 
    249             size = layout.computeSize (this, wHint, hHint, changed); 
     238            size = layout_.computeSize (this, wHint, hHint, changed); 
    250239        } else { 
    251240            size = new Point (wHint, hHint); 
     
    375364    */ 
    376365    int count = 0; 
    377     int hwndChild = OS.GetWindow (handle, OS.GW_CHILD); 
    378     while (hwndChild !is 0) { 
     366    auto hwndChild = OS.GetWindow (handle, OS.GW_CHILD); 
     367    while (hwndChild !is null) { 
    379368        count++; 
    380369        hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT); 
     
    396385public Layout getLayout () { 
    397386    checkWidget (); 
    398     return layout
     387    return layout_
    399388} 
    400389 
     
    536525public void layout (bool changed) { 
    537526    checkWidget (); 
    538     if (layout is null) return; 
     527    if (layout_ is null) return; 
    539528    layout (changed, false); 
    540529} 
     
    577566public void layout (bool changed, bool all) { 
    578567    checkWidget (); 
    579     if (layout is null && !all) return; 
     568    if (layout_ is null && !all) return; 
    580569    markLayout (changed, all); 
    581570    updateLayout (true, all); 
     
    632621        Composite composite = child.parent; 
    633622        while (child !is this) { 
    634             if (composite.layout !is null) { 
     623            if (composite.layout_ !is null) { 
    635624                composite.state |= LAYOUT_NEEDED; 
    636                 if (!composite.layout.flushCache (child)) { 
     625                if (!composite.layout_.flushCache (child)) { 
    637626                    composite.state |= LAYOUT_CHANGED; 
    638627                } 
     
    653642 
    654643void markLayout (bool changed, bool all) { 
    655     if (layout !is null) { 
     644    if (layout_ !is null) { 
    656645        state |= LAYOUT_NEEDED; 
    657646        if (changed) state |= LAYOUT_CHANGED; 
     
    699688    super.releaseWidget (); 
    700689    if ((state & CANVAS) !is 0 && (style & DWT.EMBEDDED) !is 0) { 
    701         int hwndChild = OS.GetWindow (handle, OS.GW_CHILD); 
    702         if (hwndChild !is 0) { 
     690        auto hwndChild = OS.GetWindow (handle, OS.GW_CHILD); 
     691        if (hwndChild !is null) { 
    703692            int threadId = OS.GetWindowThreadProcessId (hwndChild, null); 
    704693            if (threadId !is OS.GetCurrentThreadId ()) { 
    705694                OS.ShowWindow (hwndChild, OS.SW_HIDE); 
    706                 OS.SetParent (hwndChild, 0); 
    707             } 
    708         } 
    709     } 
    710     layout = null; 
     695                OS.SetParent (hwndChild, null); 
     696            } 
     697        } 
     698    } 
     699    layout_ = null; 
    711700    tabList = null; 
    712701    lpwp = null; 
     
    721710    if (lpwp is null) return; 
    722711    do { 
    723         WINDOWPOS [] currentLpwp = lpwp; 
     712        WINDOWPOS* [] currentLpwp = lpwp; 
    724713        lpwp = null; 
    725714        if (!resizeChildren (true, currentLpwp)) { 
     
    729718} 
    730719 
    731 bool resizeChildren (bool defer, WINDOWPOS [] pwp) { 
     720bool resizeChildren (bool defer, WINDOWPOS* [] pwp) { 
    732721    if (pwp is null) return true; 
    733     int hdwp = 0
     722    HDWP hdwp
    734723    if (defer) { 
    735724        hdwp = OS.BeginDeferWindowPos (pwp.length); 
    736         if (hdwp is 0) return false; 
     725        if (hdwp is null) return false; 
    737726    } 
    738727    for (int i=0; i<pwp.length; i++) { 
    739         WINDOWPOS wp = pwp [i]; 
     728        WINDOWPOS* wp = pwp [i]; 
    740729        if (wp !is null) { 
    741730            /* 
     
    750739//          } 
    751740            if (defer) { 
    752                 hdwp = DeferWindowPos (hdwp, wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 
    753                 if (hdwp is 0) return false; 
     741                hdwp = DeferWindowPos (hdwp, wp.hwnd, null, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 
     742                if (hdwp is null) return false; 
    754743            } else { 
    755                 SetWindowPos (wp.hwnd, 0, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 
    756             } 
    757         } 
    758     } 
    759     if (defer) return OS.EndDeferWindowPos (hdwp); 
     744                SetWindowPos (wp.hwnd, null, wp.x, wp.y, wp.cx, wp.cy, wp.flags); 
     745            } 
     746        } 
     747    } 
     748    if (defer) return cast(bool)OS.EndDeferWindowPos (hdwp); 
    760749    return true; 
    761750} 
    762751 
    763 void resizeEmbeddedHandle(int embeddedHandle, int width, int height) { 
    764     if (embeddedHandle is 0) return; 
    765     int [] processID = new int [1]
    766     int threadId = OS.GetWindowThreadProcessId (embeddedHandle, processID); 
     752void resizeEmbeddedHandle(HANDLE embeddedHandle, int width, int height) { 
     753    if (embeddedHandle is null) return; 
     754    uint processID
     755    int threadId = OS.GetWindowThreadProcessId (embeddedHandle, &processID); 
    767756    if (threadId !is OS.GetCurrentThreadId ()) { 
    768         if (processID [0] is OS.GetCurrentProcessId ()) { 
    769             if (display.msgHook is 0) { 
     757        if (processID is OS.GetCurrentProcessId ()) { 
     758            if (display.msgHook is null) { 
    770759                if (!OS.IsWinCE) { 
    771                     display.getMsgCallback = new Callback (display, "getMsgProc", 3); 
    772                     display.getMsgProc = display.getMsgCallback.getAddress (); 
    773                     if (display.getMsgProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); 
    774                     display.msgHook = OS.SetWindowsHookEx (OS.WH_GETMESSAGE, display.getMsgProc, OS.GetLibraryHandle(), threadId); 
     760                    //display.getMsgCallback = new Callback (display, "getMsgProc", 3); 
     761                    //display.getMsgProc = display.getMsgCallback.getAddress (); 
     762                    //if (display.getMsgProc is 0) error (DWT.ERROR_NO_MORE_CALLBACKS); 
     763                    display.msgHook = OS.SetWindowsHookEx (OS.WH_GETMESSAGE, &Display.getMsgFunc, OS.GetLibraryHandle(), threadId); 
    775764                    OS.PostThreadMessage (threadId, OS.WM_NULL, 0, 0); 
    776765                } 
     
    778767        } 
    779768        int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE | OS.SWP_ASYNCWINDOWPOS; 
    780         OS.SetWindowPos (embeddedHandle, 0, 0, 0, width, height, flags); 
     769        OS.SetWindowPos (embeddedHandle, null, 0, 0, width, height, flags); 
    781770    } 
    782771} 
     
    786775    sendEvent (DWT.Resize); 
    787776    if (isDisposed ()) return; 
    788     if (layout !is null) { 
     777    if (layout_ !is null) { 
    789778        markLayout (false, false); 
    790779        updateLayout (false, false); 
     
    858847 * </ul> 
    859848 */ 
    860 public void setLayout (Layout layout) { 
     849public void setLayout (Layout layout_) { 
    861850    checkWidget (); 
    862     this.layout = layout
     851    this.layout_ = layout_
    863852} 
    864853 
     
    933922        int count = getChildrenCount (); 
    934923        if (count > 1 && lpwp is null) { 
    935             lpwp = new WINDOWPOS [count]; 
     924            lpwp = new WINDOWPOS* [count]; 
    936925        } 
    937926    } 
     
    958947} 
    959948 
    960 String toolTipText (NMTTDISPINFO hdr) { 
     949char[] toolTipText (NMTTDISPINFO* hdr) { 
    961950    Shell shell = getShell (); 
    962951    if ((hdr.uFlags & OS.TTF_IDISHWND) is 0) { 
    963         String string = null; 
    964         ToolTip toolTip = shell.findToolTip (hdr.idFrom); 
     952        char[] string = null; 
     953        ToolTip toolTip = shell.findToolTip (hdr.hdr.idFrom); 
    965954        if (toolTip !is null) { 
    966955            string = toolTip.message; 
    967             if (string is null || string.length () is 0) string = " "; 
     956            if (string is null || string.length is 0) string = " "; 
    968957        } 
    969958        return string; 
    970959    } 
    971     shell.setToolTipTitle (hdr.hwndFrom, null, 0); 
    972     OS.SendMessage (hdr.hwndFrom, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF); 
    973     Control control = display.getControl (hdr.idFrom); 
    974     return control !is null ? control.toolTipText : null; 
     960    shell.setToolTipTitle (hdr.hdr.hwndFrom, null, null); 
     961    OS.SendMessage (hdr.hdr.hwndFrom, OS.TTM_SETMAXTIPWIDTH, 0, 0x7FFF); 
     962    Control control = display.getControl ( cast(HANDLE) hdr.hdr.idFrom); 
     963    return control !is null ? control.toolTipText_ : null; 
    975964} 
    976965 
     
    987976} 
    988977 
    989 bool translateTraversal (MSG msg) { 
     978bool translateTraversal (MSG* msg) { 
    990979    if ((state & CANVAS) !is 0 ) { 
    991980        if ((style & DWT.EMBEDDED) !is 0) return false; 
     
    10531042        state &= ~(LAYOUT_NEEDED | LAYOUT_CHANGED); 
    10541043        if (resize) setResizeChildren (false); 
    1055         layout.layout (this, changed); 
     1044        layout_.layout (this, changed); 
    10561045        if (resize) setResizeChildren (true); 
    10571046    } 
     
    10721061LRESULT WM_ERASEBKGND (int wParam, int lParam) { 
    10731062    LRESULT result = super.WM_ERASEBKGND (wParam, lParam); 
    1074     if (result !is null) return result; 
     1063    if (result !is LRESULT.NULL) return result; 
    10751064    if ((state & CANVAS) !is 0) { 
    10761065        /* Return zero to indicate that the background was not erased */ 
     
    10821071LRESULT WM_GETDLGCODE (int wParam, int lParam) { 
    10831072    LRESULT result = super.WM_GETDLGCODE (wParam, lParam); 
    1084     if (result !is null) return result; 
     1073    if (result !is LRESULT.NULL) return result; 
    10851074    if ((state & CANVAS) !is 0) { 
    10861075        int flags = 0; 
     
    10891078        } 
    10901079        if ((style & DWT.NO_FOCUS) !is 0) flags |= OS.DLGC_STATIC; 
    1091         if (OS.GetWindow (handle, OS.GW_CHILD) !is 0) flags |= OS.DLGC_STATIC; 
    1092         if (flags !is 0) return new LRESULT (flags)
     1080        if (OS.GetWindow (handle, OS.GW_CHILD) !is null) flags |= OS.DLGC_STATIC; 
     1081        if (flags !is 0) return cast(LRESULT)flags
    10931082    } 
    10941083    return result; 
     
    10971086LRESULT WM_GETFONT (int wParam, int lParam) { 
    10981087    LRESULT result = super.WM_GETFONT (wParam, lParam); 
    1099     if (result !is null) return result; 
     1088    if (result !is LRESULT.NULL) return result; 
    11001089    int code = callWindowProc (handle, OS.WM_GETFONT, wParam, lParam); 
    1101     if (code !is 0) return new LRESULT (code); 
    1102     if (font is 0) font = defaultFont (); 
    1103     return new LRESULT (font); 
     1090    if (code !is 0) return cast( LRESULT )(code); 
     1091    if (font is null) font = defaultFont (); 
     1092    return cast( LRESULT )(font); 
    11041093} 
    11051094 
     
    11111100    if ((state & CANVAS) !is 0) { 
    11121101        if ((style & DWT.NO_FOCUS) is 0 && hooksKeys ()) { 
    1113             if (OS.GetWindow (handle, OS.GW_CHILD) is 0) setFocus (); 
     1102            if (OS.GetWindow (handle, OS.GW_CHILD) is null) setFocus (); 
    11141103        } 
    11151104    } 
     
    11191108LRESULT WM_NCPAINT (int wParam, int lParam) { 
    11201109    LRESULT result = super.WM_NCPAINT (wParam, lParam); 
    1121     if (result !is null) return result; 
     1110    if (result !is LRESULT.NULL) return result; 
    11221111    if ((state & CANVAS) !is 0) { 
    11231112        result = wmNCPaint (handle, wParam, lParam); 
     
    11291118    if ((state & CANVAS) !is 0 && (style & DWT.EMBEDDED) !is 0) { 
    11301119        if ((wParam & 0xFFFF) is OS.WM_CREATE) { 
    1131             RECT rect = new RECT ()
    1132             OS.GetClientRect (handle, rect); 
    1133             resizeEmbeddedHandle (lParam, rect.right - rect.left, rect.bottom - rect.top); 
     1120            RECT rect
     1121            OS.GetClientRect (handle, &rect); 
     1122            resizeEmbeddedHandle ( cast(HANDLE)lParam, rect.right - rect.left, rect.bottom - rect.top); 
    11341123        } 
    11351124    } 
     
    11511140 
    11521141    /* Paint the control and the background */ 
    1153     PAINTSTRUCT ps = new PAINTSTRUCT ()
     1142    PAINTSTRUCT ps
    11541143    if (hooks (DWT.Paint)) { 
    11551144 
     
    11641153        } 
    11651154        if (bufferedPaint) { 
    1166             int hDC = OS.BeginPaint (handle, ps); 
    1167             int width = ps.right - ps.left; 
    1168             int height = ps.bottom - ps.top; 
     1155            auto hDC = OS.BeginPaint (handle, &ps); 
     1156            int width = ps.rcPaint.right - ps.rcPaint.left; 
     1157            int height = ps.rcPaint.bottom - ps.rcPaint.top; 
    11691158            if (width !is 0 && height !is 0) { 
    1170                 int [] phdc = new int [1]
     1159                HDC phdc
    11711160                int flags = OS.BPBF_COMPATIBLEBITMAP; 
    1172                 RECT prcTarget = new RECT ()
    1173                 OS.SetRect (prcTarget, ps.left, ps.top, ps.right, ps.bottom); 
    1174                 int hBufferedPaint = OS.BeginBufferedPaint (hDC, prcTarget, flags, null, phdc); 
     1161                RECT prcTarget
     1162                OS.SetRect (&prcTarget, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); 
     1163                auto hBufferedPaint = OS.BeginBufferedPaint (hDC, &prcTarget, flags, null, &phdc); 
    11751164                GCData data = new GCData (); 
    11761165                if ((OS.GetLayout (hDC) & OS.LAYOUT_RTL) !is 0) { 
     
    11841173                if (control is null) control = this; 
    11851174                data.background = control.getBackgroundPixel (); 
    1186                 data.hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     1175                data.hFont = cast(HFONT) OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    11871176                data.uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0); 
    11881177                if ((style & DWT.NO_BACKGROUND) !is 0) { 
     
    11901179                    //paintGC.copyArea (image, ps.left, ps.top); 
    11911180                } else { 
    1192                     RECT rect = new RECT ()
    1193                     OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom); 
    1194                     drawBackground (phdc [0], rect); 
     1181                    RECT rect
     1182                    OS.SetRect (&rect, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); 
     1183                    drawBackground (phdc, &rect); 
    11951184                } 
    1196                 GC gc = GC.win32_new (phdc [0], data); 
     1185                GC gc = GC.win32_new (phdc, data); 
    11971186                Event event = new Event (); 
    11981187                event.gc = gc; 
    1199                 event.x = ps.left; 
    1200                 event.y = ps.top; 
     1188                event.x = ps.rcPaint.left; 
     1189                event.y = ps.rcPaint.top; 
    12011190                event.width = width; 
    12021191                event.height = height; 
     
    12051194                OS.EndBufferedPaint (hBufferedPaint, true); 
    12061195            } 
    1207             OS.EndPaint (handle, ps); 
     1196            OS.EndPaint (handle, &ps); 
    12081197        } else { 
    12091198 
    12101199            /* Create the paint GC */ 
    12111200            GCData data = new GCData (); 
    1212             data.ps = ps; 
     1201            data.ps = &ps; 
    12131202            data.hwnd = handle; 
    12141203            GC gc = GC.win32_new (this, data); 
    12151204 
    12161205            /* Get the system region for the paint HDC */ 
    1217             int sysRgn = 0
     1206            HRGN sysRgn
    12181207            if ((style & (DWT.NO_MERGE_PAINTS | DWT.DOUBLE_BUFFERED)) !is 0) { 
    12191208                sysRgn = OS.CreateRectRgn (0, 0, 0, 0); 
     
    12231212                            int nBytes = OS.GetRegionData (sysRgn, 0, null); 
    12241213                            int [] lpRgnData = new int [nBytes / 4]; 
    1225                             OS.GetRegionData (sysRgn, nBytes, lpRgnData); 
    1226                             int newSysRgn = OS.ExtCreateRegion (new float [] {-1, 0, 0, 1, 0, 0}, nBytes, lpRgnData); 
     1214                            OS.GetRegionData (sysRgn, nBytes, cast(RGNDATA*)lpRgnData.ptr); 
     1215                            HRGN newSysRgn = OS.ExtCreateRegion ( cast(XFORM*) [-1.0f, 0, 0, 1, 0, 0].ptr, nBytes, cast(RGNDATA*)lpRgnData.ptr); 
    12271216                            OS.DeleteObject (sysRgn); 
    12281217                            sysRgn = newSysRgn; 
     
    12301219                    } 
    12311220                    if (OS.IsWinNT) { 
    1232                         POINT pt = new POINT()
    1233                         OS.MapWindowPoints (0, handle, pt, 1); 
     1221                        POINT pt
     1222                        OS.MapWindowPoints (null, handle, &pt, 1); 
    12341223                        OS.OffsetRgn (sysRgn, pt.x, pt.y); 
    12351224                    } 
     
    12381227 
    12391228            /* Send the paint event */ 
    1240             int width = ps.right - ps.left; 
    1241             int height = ps.bottom - ps.top; 
     1229            int width = ps.rcPaint.right - ps.rcPaint.left; 
     1230            int height = ps.rcPaint.bottom - ps.rcPaint.top; 
    12421231            if (width !is 0 && height !is 0) { 
    12431232                GC paintGC = null; 
     
    12521241                    gc.setBackground (getBackground ()); 
    12531242                    gc.setFont (getFont ()); 
    1254                     OS.OffsetRgn (sysRgn, -ps.left, -ps.top); 
     1243                    OS.OffsetRgn (sysRgn, -ps.rcPaint.left, -ps.rcPaint.top); 
    12551244                    OS.SelectClipRgn (gc.handle, sysRgn); 
    1256                     OS.OffsetRgn (sysRgn, ps.left, ps.top); 
     1245                    OS.OffsetRgn (sysRgn, ps.rcPaint.left, ps.rcPaint.top); 
    12571246                    OS.SetMetaRgn (gc.handle); 
    1258                     OS.SetWindowOrgEx (gc.handle, ps.left, ps.top, null); 
    1259                     OS.SetBrushOrgEx (gc.handle, ps.left, ps.top, null); 
     1247                    OS.SetWindowOrgEx (gc.handle, ps.rcPaint.left, ps.rcPaint.top, null); 
     1248                    OS.SetBrushOrgEx (gc.handle, ps.rcPaint.left, ps.rcPaint.top, null); 
    12601249                    if ((style & DWT.NO_BACKGROUND) !is 0) { 
    12611250                        /* This code is intentionally commented because it may be slow to copy bits from the screen */ 
    12621251                        //paintGC.copyArea (image, ps.left, ps.top); 
    12631252                    } else { 
    1264                         RECT rect = new RECT ()
    1265                         OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom); 
    1266                         drawBackground (gc.handle, rect); 
     1253                        RECT rect
     1254                        OS.SetRect (&rect, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); 
     1255                        drawBackground (gc.handle, &rect); 
    12671256                    } 
    12681257                } 
    12691258                Event event = new Event (); 
    12701259                event.gc = gc; 
    1271                 RECT rect = null
    1272                 if ((style & DWT.NO_MERGE_PAINTS) !is 0 && OS.GetRgnBox (sysRgn, rect = new RECT ()) is OS.COMPLEXREGION) { 
     1260                RECT rect
     1261                if ((style & DWT.NO_MERGE_PAINTS) !is 0 && OS.GetRgnBox (sysRgn, &rect) is OS.COMPLEXREGION) { 
    12731262                    int nBytes = OS.GetRegionData (sysRgn, 0, null); 
    12741263                    int [] lpRgnData = new int [nBytes / 4]; 
    1275                     OS.GetRegionData (sysRgn, nBytes, lpRgnData); 
     1264                    OS.GetRegionData (sysRgn, nBytes, cast(RGNDATA*)lpRgnData.ptr); 
    12761265                    int count = lpRgnData [2]; 
    12771266                    for (int i=0; i<count; i++) { 
    12781267                        int offset = 8 + (i << 2); 
    1279                         OS.SetRect (rect, lpRgnData [offset], lpRgnData [offset + 1], lpRgnData [offset + 2], lpRgnData [offset + 3]); 
     1268                        OS.SetRect (&rect, lpRgnData [offset], lpRgnData [offset + 1], lpRgnData [offset + 2], lpRgnData [offset + 3]); 
    12801269                        if ((style & (DWT.DOUBLE_BUFFERED | DWT.NO_BACKGROUND)) is 0) { 
    1281                             drawBackground (gc.handle, rect); 
     1270                            drawBackground (gc.handle, &rect); 
    12821271                        } 
    12831272                        event.x = rect.left; 
     
    12901279                } else { 
    12911280                    if ((style & (DWT.DOUBLE_BUFFERED | DWT.NO_BACKGROUND)) is 0) { 
    1292                         if (rect is null) rect = new RECT (); 
    1293                         OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom); 
    1294                         drawBackground (gc.handle, rect); 
     1281                        OS.SetRect (&rect, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); 
     1282                        drawBackground (gc.handle, &rect); 
    12951283                    } 
    1296                     event.x = ps.left; 
    1297                     event.y = ps.top; 
     1284                    event.x = ps.rcPaint.left; 
     1285                    event.y = ps.rcPaint.top; 
    12981286                    event.width = width; 
    12991287                    event.height = height; 
     
    13041292                if ((style & DWT.DOUBLE_BUFFERED) !is 0) { 
    13051293                    gc.dispose(); 
    1306                     if (!isDisposed ()) paintGC.drawImage (image, ps.left, ps.top); 
     1294                    if (!isDisposed ()) paintGC.drawImage (image, ps.rcPaint.left, ps.rcPaint.top); 
    13071295                    image.dispose (); 
    13081296                    gc = paintGC; 
    13091297                } 
    13101298            } 
    1311             if (sysRgn !is 0) OS.DeleteObject (sysRgn); 
     1299            if (sysRgn !is null) OS.DeleteObject (sysRgn); 
    13121300 
    13131301            /* Dispose the paint GC */ 
     
    13151303        } 
    13161304    } else { 
    1317         int hDC = OS.BeginPaint (handle, ps); 
     1305        auto hDC = OS.BeginPaint (handle, &ps); 
    13181306        if ((style & DWT.NO_BACKGROUND) is 0) { 
    1319             RECT rect = new RECT ()
    1320             OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom); 
    1321             drawBackground (hDC, rect); 
    1322         } 
    1323         OS.EndPaint (handle, ps); 
     1307            RECT rect
     1308            OS.SetRect (&rect, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, ps.rcPaint.bottom); 
     1309            drawBackground (hDC, &rect); 
     1310        } 
     1311        OS.EndPaint (handle, &ps); 
    13241312    } 
    13251313 
     
    13431331LRESULT WM_PRINTCLIENT (int wParam, int lParam) { 
    13441332    LRESULT result = super.WM_PRINTCLIENT (wParam, lParam); 
    1345     if (result !is null) return result; 
     1333    if (result !is LRESULT.NULL) return result; 
    13461334    if ((state & CANVAS) !is 0) { 
    13471335        forceResize (); 
    1348         int nSavedDC = OS.SaveDC (wParam); 
    1349         RECT rect = new RECT ()
    1350         OS.GetClientRect (handle, rect); 
     1336        auto nSavedDC = OS.SaveDC (cast(HDC)wParam); 
     1337        RECT rect
     1338        OS.GetClientRect (handle, &rect); 
    13511339        if ((style & DWT.NO_BACKGROUND) is 0) { 
    1352             drawBackground (wParam, rect); 
     1340            drawBackground ( cast(HDC)wParam, &rect); 
    13531341        } 
    13541342        if (hooks (DWT.Paint) || filters (DWT.Paint)) { 
     
    13591347            if (control is null) control = this; 
    13601348            data.background = control.getBackgroundPixel (); 
    1361             data.hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
     1349            data.hFont = cast(HFONT)OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 
    13621350            data.uiState = OS.SendMessage (handle, OS.WM_QUERYUISTATE, 0, 0); 
    1363             GC gc = GC.win32_new (wParam, data); 
     1351            GC gc = GC.win32_new (cast(HDC)wParam, data); 
    13641352            Event event = new Event (); 
    13651353            event.gc = gc; 
     
    13721360            gc.dispose (); 
    13731361        } 
    1374         OS.RestoreDC (wParam, nSavedDC); 
     1362        OS.RestoreDC (cast(HDC)wParam, nSavedDC); 
    13751363    } 
    13761364    return result; 
     
    13791367LRESULT WM_SETFONT (int wParam, int lParam) { 
    13801368    if (lParam !is 0) OS.InvalidateRect (handle, null, true); 
    1381     return super.WM_SETFONT (font = wParam, lParam); 
     1369    font = cast(HFONT)wParam; 
     1370    return super.WM_SETFONT (wParam, lParam); 
    13821371} 
    13831372 
     
    13971386    */ 
    13981387    if (isDisposed ()) return result; 
    1399     if (layout !is null) { 
     1388    if (layout_ !is null) { 
    14001389        markLayout (false, false); 
    14011390        updateLayout (false, false); 
     
    14281417LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) { 
    14291418    LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam); 
    1430     if (result !is null) return result; 
    1431     int hwndChild = OS.GetWindow (handle, OS.GW_CHILD); 
    1432     while (hwndChild !is 0) { 
     1419    if (result !is LRESULT.NULL) return result; 
     1420    auto hwndChild = OS.GetWindow (handle, OS.GW_CHILD); 
     1421    while (hwndChild !is null) { 
    14331422        OS.SendMessage (hwndChild, OS.WM_SYSCOLORCHANGE, 0, 0); 
    14341423        hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT); 
     
    14391428LRESULT WM_SYSCOMMAND (int wParam, int lParam) { 
    14401429    LRESULT result = super.WM_SYSCOMMAND (wParam, lParam); 
    1441     if (result !is null) return result; 
     1430    if (result !is LRESULT.NULL) return result; 
    14421431 
    14431432    /* 
     
    14651454                    (showVBar !is (verticalBar !is null && verticalBar.getVisible ()))) { 
    14661455                        int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_UPDATENOW; 
    1467                         OS.RedrawWindow (handle, null, 0, flags); 
     1456                        OS.RedrawWindow (handle, null, null, flags); 
    14681457                    } 
    14691458                if (code is 0) return LRESULT.ZERO; 
    1470                 return new LRESULT (code); 
     1459                return cast( LRESULT )(code); 
    14711460        } 
    14721461    } 
     
    14771466LRESULT WM_UPDATEUISTATE (int wParam, int lParam) { 
    14781467    LRESULT result = super.WM_UPDATEUISTATE (wParam, lParam); 
    1479     if (result !is null) return result; 
     1468    if (result !is LRESULT.NULL) return result; 
    14801469    if ((state & CANVAS) !is 0) OS.InvalidateRect (handle, null, false); 
    14811470    return result; 
    14821471} 
    14831472 
    1484 LRESULT wmNCPaint (int hwnd, int wParam, int lParam) { 
     1473LRESULT wmNCPaint (HWND hwnd, int wParam, int lParam) { 
    14851474    if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 
    14861475        int bits1 = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE); 
     
    14911480                code = callWindowProc (hwnd, OS.WM_NCPAINT, wParam, lParam); 
    14921481            } 
    1493             int hDC = OS.GetWindowDC (hwnd); 
    1494             RECT rect = new RECT ()
    1495             OS.GetWindowRect (hwnd, rect); 
     1482            auto hDC = OS.GetWindowDC (hwnd); 
     1483            RECT rect
     1484            OS.GetWindowRect (hwnd, &rect); 
    14961485            rect.right -= rect.left; 
    14971486            rect.bottom -= rect.top; 
     
    14991488            int border = OS.GetSystemMetrics (OS.SM_CXEDGE); 
    15001489            OS.ExcludeClipRect (hDC, border, border, rect.right - border, rect.bottom - border); 
    1501             OS.DrawThemeBackground (display.hEditTheme (), hDC, OS.EP_EDITTEXT, OS.ETS_NORMAL, rect, null); 
     1490            OS.DrawThemeBackground (display.hEditTheme (), hDC, OS.EP_EDITTEXT, OS.ETS_NORMAL, &rect, null); 
    15021491            OS.ReleaseDC (hwnd, hDC); 
    1503             return new LRESULT (code); 
    1504         } 
    1505     } 
    1506     return null
    1507 } 
    1508  
    1509 LRESULT wmNotify (NMHDR hdr, int wParam, int lParam) { 
     1492            return cast(LRESULT )(code); 
     1493        } 
     1494    } 
     1495    return LRESULT.NULL
     1496} 
     1497 
     1498LRESULT wmNotify (NMHDR* hdr, int wParam, int lParam) { 
    15101499    if (!OS.IsWinCE) { 
    15111500        switch (hdr.code) { 
     
    15331522                * the topmost status of the tool tip. 
    15341523                */ 
    1535                 int hwndParent = hdr.hwndFrom; 
     1524                auto hwndParent = hdr.hwndFrom; 
    15361525                do { 
    15371526                    hwndParent = OS.GetParent (hwndParent); 
    1538                     if (hwndParent is 0) break; 
     1527                    if (hwndParent is null) break; 
    15391528                    int bits = OS.GetWindowLong (hwndParent, OS.GWL_EXSTYLE); 
    15401529                    if ((bits & OS.WS_EX_TOPMOST) !is 0) break; 
    15411530                } while (true); 
    1542                 if (hwndParent !is 0) break; 
     1531                if (hwndParent !is null) break; 
    15431532                display.lockActiveWindow = true; 
    15441533                int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOSIZE; 
    1545                 int hwndInsertAfter = hdr.code is OS.TTN_SHOW ? OS.HWND_TOPMOST : OS.HWND_NOTOPMOST
     1534                HWND hwndInsertAfter = cast(HWND)( hdr.code is OS.TTN_SHOW ? OS.HWND_TOPMOST : OS.HWND_NOTOPMOST)
    15461535                SetWindowPos (hdr.hwndFrom, hwndInsertAfter, 0, 0, 0, 0, flags); 
    15471536                display.lockActiveWindow = false; 
     
    15621551            case OS.TTN_GETDISPINFOA: 
    15631552            case OS.TTN_GETDISPINFOW: { 
    1564                 NMTTDISPINFO lpnmtdi
    1565                 if (hdr.code is OS.TTN_GETDISPINFOA) { 
    1566                     lpnmtdi = new NMTTDISPINFOA (); 
    1567                     OS.MoveMemory ((NMTTDISPINFOA)lpnmtdi, lParam, NMTTDISPINFOA.sizeof); 
    1568                 } else { 
    1569                     lpnmtdi = new NMTTDISPINFOW (); 
    1570                     OS.MoveMemory ((NMTTDISPINFOW)lpnmtdi, lParam, NMTTDISPINFOW.sizeof); 
    1571                 } 
    1572                 String string = toolTipText (lpnmtdi); 
     1553                NMTTDISPINFO* lpnmtdi = cast(NMTTDISPINFO*)lParam
     1554//                 if (hdr.code is OS.TTN_GETDISPINFOA) { 
     1555//                     lpnmtdi = new NMTTDISPINFOA (); 
     1556//                     OS.MoveMemory (cast(NMTTDISPINFOA)lpnmtdi, lParam, NMTTDISPINFOA.sizeof); 
     1557//                 } else { 
     1558//                     lpnmtdi = new NMTTDISPINFOW (); 
     1559//                     OS.MoveMemory (cast(NMTTDISPINFOW)lpnmtdi, lParam, NMTTDISPINFOW.sizeof); 
     1560//                 } 
     1561                char[] string = toolTipText (lpnmtdi); 
    15731562                if (string !is null) { 
    15741563                    Shell shell = getShell (); 
    15751564                    string = Display.withCrLf (string); 
    1576                     int length = string.length ()
    1577                     char [] chars = new char [length + 1]; 
    1578                     string.getChars (0, length, chars, 0); 
     1565                    int length_ = string.length
     1566                    char [] chars = new char [length_ + 1]; 
     1567                    string.getChars (0, length_, chars, 0); 
    15791568 
    15801569                    /* 
     
    15821571                    * the orientation of the control. 
    15831572                    */ 
    1584                     int hwnd = hdr.idFrom; 
    1585                     if (hwnd !is 0 && ((lpnmtdi.uFlags & OS.TTF_IDISHWND) !is 0)) { 
     1573                    HWND hwnd = cast(HWND)hdr.idFrom; 
     1574                    if (hwnd !is null && ((lpnmtdi.uFlags & OS.TTF_IDISHWND) !is 0)) { 
    15861575                        Control control = display.getControl (hwnd); 
    15871576                        if (control !is null) { 
     
    15951584 
    15961585                    if (hdr.code is OS.TTN_GETDISPINFOA) { 
    1597                         byte [] bytes = new byte [chars.length * 2]; 
    1598                         OS.WideCharToMultiByte (getCodePage (), 0, chars, chars.length, bytes, bytes.length, null, null); 
     1586                        auto bytes = MBCSsToStr( chars, getCodePage () ); 
     1587                        //byte [] bytes = new byte [chars.length * 2]; 
     1588                        //OS.WideCharToMultiByte (getCodePage (), 0, chars.ptr, chars.length, bytes, bytes.length, null, null); 
    15991589                        shell.setToolTipText (lpnmtdi, bytes); 
    1600                         OS.MoveMemory (lParam, (NMTTDISPINFOA)lpnmtdi, NMTTDISPINFOA.sizeof); 
     1590                        //OS.MoveMemory (lParam, cast(NMTTDISPINFOA)lpnmtdi, NMTTDISPINFOA.sizeof); 
    16011591                    } else { 
    16021592                        shell.setToolTipText (lpnmtdi, chars);