diff dwt/widgets/Widget.d @ 108:6f75fdfa1bcd

Change LRESULT to class, like done in the old DWT.
author Frank Benoit <benoit@tionex.de>
date Mon, 11 Feb 2008 02:44:32 +0100
parents 3926f6c95d6f
children 0a02d6d3466b
line wrap: on
line diff
--- a/dwt/widgets/Widget.d	Mon Feb 11 00:56:33 2008 +0100
+++ b/dwt/widgets/Widget.d	Mon Feb 11 02:44:32 2008 +0100
@@ -32,7 +32,7 @@
 import dwt.dwthelper.utils;
 import tango.util.log.Trace;
 void trc( long line ){
-    //Trace.formatln( "Widget {}", line );
+//    Trace.formatln( "Widget {}", line );
 }
 
 /**
@@ -64,18 +64,13 @@
 
 public abstract class Widget {
 
-    public enum LRESULT {
-        NULL = -1,
-        ZERO = 0,
-        ONE = 1,
-    }
-
-
     int style, state;
     Display display;
     EventTable eventTable;
     Object data;
 
+    public alias dwt.internal.win32.OS.LDWTRESULT LRESULT;
+
     /* Global state flags */
     static const int DISPOSED       = 1<<0;
     static const int CANVAS         = 1<<1;
@@ -237,8 +232,8 @@
     addListener (DWT.Dispose, typedListener);
 }
 
-LRESULT callWindowProc (HWND hwnd, int msg, int wParam, int lParam) {
-    return LRESULT.ZERO;
+int callWindowProc (HWND hwnd, int msg, int wParam, int lParam) {
+    return 0;
 }
 
 /**
@@ -1312,7 +1307,7 @@
 
 LRESULT wmCaptureChanged (HWND hwnd, int wParam, int lParam) {
     display.captureChanged = true;
-    return LRESULT.NULL;
+    return null;
 }
 
 LRESULT wmChar (HWND hwnd, int wParam, int lParam) {
@@ -1321,7 +1316,7 @@
     */
     if (!OS.IsUnicode && OS.IsDBLocale) {
         byte lead = cast(byte) (wParam & 0xFF);
-        if (OS.IsDBCSLeadByte (lead)) return LRESULT.NULL;
+        if (OS.IsDBCSLeadByte (lead)) return null;
     }
     display.lastAscii = wParam;
     display.lastNull = wParam is 0;
@@ -1329,11 +1324,11 @@
         return LRESULT.ONE;
     }
     // widget could be disposed at this point
-    return LRESULT.NULL;
+    return null;
 }
 
 LRESULT wmContextMenu (HWND hwnd, int wParam, int lParam) {
-    if (wParam !is cast(int)hwnd) return LRESULT.NULL;
+    if (wParam !is cast(int)hwnd) return null;
 
     /*
     * Feature in Windows.  SHRecognizeGesture() sends an undocumented
@@ -1346,7 +1341,7 @@
     * NOTE: This only happens on WM2003.  Previous WinCE versions did
     * not support WM_CONTEXTMENU.
     */
-    if (OS.IsWinCE) return LRESULT.NULL;
+    if (OS.IsWinCE) return null;
 
     /*
     * Feature in Windows.  When the user presses  WM_NCRBUTTONUP,
@@ -1367,7 +1362,7 @@
         OS.ScreenToClient (hwnd, &pt);
         RECT rect;
         OS.GetClientRect (hwnd, &rect);
-        if (!OS.PtInRect (&rect, pt)) return LRESULT.NULL;
+        if (!OS.PtInRect (&rect, pt)) return null;
     } else {
         int pos = OS.GetMessagePos ();
         x = cast(short) (pos & 0xFFFF);
@@ -1375,7 +1370,7 @@
     }
 
     /* Show the menu */
-    return showMenu (x, y) ? LRESULT.ZERO : LRESULT.NULL;
+    return showMenu (x, y) ? LRESULT.ZERO : null;
 }
 
 LRESULT wmIMEChar (HWND hwnd, int wParam, int lParam) {
@@ -1402,7 +1397,7 @@
         case OS.VK_CAPITAL:
         case OS.VK_NUMLOCK:
         case OS.VK_SCROLL:
-            if ((lParam & 0x40000000) !is 0) return LRESULT.NULL;
+            if ((lParam & 0x40000000) !is 0) return null;
         default:
     }
 
@@ -1415,7 +1410,7 @@
     */
     if (!OS.IsUnicode && OS.IsDBLocale) {
         byte lead = cast(byte) (wParam & 0xFF);
-        if (OS.IsDBCSLeadByte (lead)) return LRESULT.NULL;
+        if (OS.IsDBCSLeadByte (lead)) return null;
     }
 
     /* Map the virtual key */
@@ -1460,9 +1455,9 @@
     * and avoid issuing the event.
     */
     if (OS.IsWinNT) {
-        if ((mapKey & 0x80000000) !is 0) return LRESULT.NULL;
+        if ((mapKey & 0x80000000) !is 0) return null;
     } else {
-        if ((mapKey & 0x8000) !is 0) return LRESULT.NULL;
+        if ((mapKey & 0x8000) !is 0) return null;
     }
     MSG msg;
     int flags = OS.PM_NOREMOVE | OS.PM_NOYIELD | OS.PM_QS_INPUT | OS.PM_QS_POSTMESSAGE;
@@ -1470,7 +1465,7 @@
         display.lastDead = true;
         display.lastVirtual = mapKey is 0;
         display.lastKey = display.lastVirtual ? wParam : mapKey;
-        return LRESULT.NULL;
+        return null;
     }
 
     /*
@@ -1536,7 +1531,7 @@
             * special Windows keypad sequence when NumLock is down (ie. typing
             * ALT+0231 should gives 'c' with a cedilla when NumLock is down).
             */
-            if (display.asciiKey (display.lastKey) !is 0) return LRESULT.NULL;
+            if (display.asciiKey (display.lastKey) !is 0) return null;
             display.lastAscii = display.numpadKey (display.lastKey);
         }
     } else {
@@ -1574,8 +1569,8 @@
             * To avoid the extra DWT.KeyDown, look for a space and
             * issue the event from WM_CHAR.
             */
-            if (asciiKey is ' ') return LRESULT.NULL;
-            if (asciiKey !is wParam) return LRESULT.NULL;
+            if (asciiKey is ' ') return null;
+            if (asciiKey !is wParam) return null;
             /*
             * Feature in Windows. The virtual key VK_CANCEL is treated
             * as both a virtual key and ASCII key by Windows.  This
@@ -1583,7 +1578,7 @@
             * this key. To avoid the extra DWT.KeyDown, look for
             * VK_CANCEL and issue the event from WM_CHAR.
             */
-            if (wParam is OS.VK_CANCEL) return LRESULT.NULL;
+            if (wParam is OS.VK_CANCEL) return null;
         }
 
         /*
@@ -1592,7 +1587,7 @@
         * key such as 'A' or Shift+A.  In that case, issue the
         * key event from WM_CHAR.
         */
-        if (OS.GetKeyState (OS.VK_CONTROL) >= 0) return LRESULT.NULL;
+        if (OS.GetKeyState (OS.VK_CONTROL) >= 0) return null;
 
         /*
         * Get the shifted state or convert to lower case if necessary.
@@ -1609,14 +1604,14 @@
         }
 
         /* Note that Ctrl+'@' is ASCII NUL and is delivered in WM_CHAR */
-        if (display.lastAscii is '@') return LRESULT.NULL;
+        if (display.lastAscii is '@') return null;
         display.lastAscii = display.controlKey (display.lastAscii);
     }
     if (!sendKeyEvent (DWT.KeyDown, OS.WM_KEYDOWN, wParam, lParam)) {
         return LRESULT.ONE;
     }
     // widget could be disposed at this point
-    return LRESULT.NULL;
+    return null;
 }
 
 LRESULT wmKeyUp (HWND hwnd, int wParam, int lParam) {
@@ -1633,7 +1628,7 @@
             int type = (lParam & 0x40000000) !is 0 ? DWT.HardKeyUp : DWT.HardKeyDown;
             if (setInputState (event, type)) sendEvent (type, event);
             // widget could be disposed at this point
-            return LRESULT.NULL;
+            return null;
         }
     }
 
@@ -1644,7 +1639,7 @@
     if (!hooks (DWT.KeyUp) && !display.filters (DWT.KeyUp)) {
         display.lastKey = display.lastAscii = 0;
         display.lastVirtual = display.lastNull = display.lastDead = false;
-        return LRESULT.NULL;
+        return null;
     }
 
     /* Map the virtual key. */
@@ -1682,11 +1677,11 @@
     * They should both be bit 32.
     */
     if (OS.IsWinNT) {
-        if ((mapKey & 0x80000000) !is 0) return LRESULT.NULL;
+        if ((mapKey & 0x80000000) !is 0) return null;
     } else {
-        if ((mapKey & 0x8000) !is 0) return LRESULT.NULL;
+        if ((mapKey & 0x8000) !is 0) return null;
     }
-    if (display.lastDead) return LRESULT.NULL;
+    if (display.lastDead) return null;
 
     /*
     * NOTE: On Windows 98, keypad keys are virtual despite the
@@ -1709,10 +1704,10 @@
         if (display.lastKey is 0) {
             display.lastAscii = 0;
             display.lastNull = display.lastDead = false;
-            return LRESULT.NULL;
+            return null;
         }
     }
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     if (!sendKeyEvent (DWT.KeyUp, OS.WM_KEYUP, wParam, lParam)) {
         result = LRESULT.ONE;
     }
@@ -1723,8 +1718,7 @@
 }
 
 LRESULT wmKillFocus (HWND hwnd, int wParam, int lParam) {
-    LRESULT code = callWindowProc (hwnd, OS.WM_KILLFOCUS, wParam, lParam);
-    assert( code !is LRESULT.NULL );
+    int code = callWindowProc (hwnd, OS.WM_KILLFOCUS, wParam, lParam);
     sendFocusEvent (DWT.FocusOut);
     // widget could be disposed at this point
 
@@ -1737,7 +1731,7 @@
     */
     if (isDisposed ()) return LRESULT.ZERO;
     if (code is 0) return LRESULT.ZERO;
-    return cast(LRESULT) code;
+    return new LRESULT(code);
 }
 
 LRESULT wmLButtonDblClk (HWND hwnd, int wParam, int lParam) {
@@ -1754,13 +1748,12 @@
     * pairs will not see the second mouse down.  The
     * fix is to send a mouse down event.
     */
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     Display display = this.display;
     display.captureChanged = false;
     sendMouseEvent (DWT.MouseDown, 1, hwnd, OS.WM_LBUTTONDOWN, wParam, lParam);
     if (sendMouseEvent (DWT.MouseDoubleClick, 1, hwnd, OS.WM_LBUTTONDBLCLK, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_LBUTTONDBLCLK, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT( callWindowProc (hwnd, OS.WM_LBUTTONDBLCLK, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }
@@ -1772,7 +1765,7 @@
 
 LRESULT wmLButtonDown (HWND hwnd, int wParam, int lParam) {
     Display display = this.display;
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     int x = cast(short) (lParam & 0xFFFF);
     int y = cast(short) (lParam >> 16);
     bool [] consume = null, detect = null;
@@ -1798,8 +1791,7 @@
     display.captureChanged = false;
     bool dispatch = sendMouseEvent (DWT.MouseDown, 1, count, 0, false, hwnd, OS.WM_LBUTTONDOWN, wParam, lParam);
     if (dispatch && (consume is null || !consume [0])) {
-        result = callWindowProc (hwnd, OS.WM_LBUTTONDOWN, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT( callWindowProc (hwnd, OS.WM_LBUTTONDOWN, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }
@@ -1863,10 +1855,11 @@
 
 LRESULT wmLButtonUp (HWND hwnd, int wParam, int lParam) {
     Display display = this.display;
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
+trc(__LINE__);
     if (sendMouseEvent (DWT.MouseUp, 1, hwnd, OS.WM_LBUTTONUP, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_LBUTTONUP, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+trc(__LINE__);
+        result = new LRESULT( callWindowProc (hwnd, OS.WM_LBUTTONUP, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }
@@ -1881,6 +1874,7 @@
     if (((wParam & 0xFFFF) & mask) is 0) {
         if (OS.GetCapture () is hwnd) OS.ReleaseCapture ();
     }
+Trace.formatln( "result={}", result );
     return result;
 }
 
@@ -1898,13 +1892,12 @@
     * pairs will not see the second mouse down.  The
     * fix is to send a mouse down event.
     */
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     Display display = this.display;
     display.captureChanged = false;
     sendMouseEvent (DWT.MouseDown, 2, hwnd, OS.WM_MBUTTONDOWN, wParam, lParam);
     if (sendMouseEvent (DWT.MouseDoubleClick, 2, hwnd, OS.WM_MBUTTONDBLCLK, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_MBUTTONDBLCLK, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT( callWindowProc (hwnd, OS.WM_MBUTTONDBLCLK, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }
@@ -1915,12 +1908,11 @@
 }
 
 LRESULT wmMButtonDown (HWND hwnd, int wParam, int lParam) {
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     Display display = this.display;
     display.captureChanged = false;
     if (sendMouseEvent (DWT.MouseDown, 2, hwnd, OS.WM_MBUTTONDOWN, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_MBUTTONDOWN, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT( callWindowProc (hwnd, OS.WM_MBUTTONDOWN, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }
@@ -1932,10 +1924,9 @@
 
 LRESULT wmMButtonUp (HWND hwnd, int wParam, int lParam) {
     Display display = this.display;
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     if (sendMouseEvent (DWT.MouseUp, 2, hwnd, OS.WM_MBUTTONUP, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_MBUTTONUP, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT( callWindowProc (hwnd, OS.WM_MBUTTONUP, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }
@@ -1957,11 +1948,11 @@
     if (!sendMouseEvent (DWT.MouseHover, 0, hwnd, OS.WM_MOUSEHOVER, wParam, lParam)) {
         return LRESULT.ZERO;
     }
-    return LRESULT.NULL;
+    return null;
 }
 
 LRESULT wmMouseLeave (HWND hwnd, int wParam, int lParam) {
-    if (!hooks (DWT.MouseExit) && !filters (DWT.MouseExit)) return LRESULT.NULL;
+    if (!hooks (DWT.MouseExit) && !filters (DWT.MouseExit)) return null;
     int pos = OS.GetMessagePos ();
     POINT pt;
     pt.x = cast(short) (pos & 0xFFFF);
@@ -1971,11 +1962,11 @@
     if (!sendMouseEvent (DWT.MouseExit, 0, hwnd, OS.WM_MOUSELEAVE, wParam, lParam)) {
         return LRESULT.ZERO;
     }
-    return LRESULT.NULL;
+    return null;
 }
 
 LRESULT wmMouseMove (HWND hwnd, int wParam, int lParam) {
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     Display display = this.display;
     int pos = OS.GetMessagePos ();
     if (pos !is display.lastMouse || display.captureChanged) {
@@ -2027,7 +2018,7 @@
 }
 
 LRESULT wmMouseWheel (HWND hwnd, int wParam, int lParam) {
-    if (!hooks (DWT.MouseWheel) && !filters (DWT.MouseWheel)) return LRESULT.NULL;
+    if (!hooks (DWT.MouseWheel) && !filters (DWT.MouseWheel)) return null;
     int delta = wParam >> 16;
     int value;
     int count, detail;
@@ -2047,23 +2038,22 @@
     if (!sendMouseEvent (DWT.MouseWheel, 0, count, detail, true, hwnd, OS.WM_MOUSEWHEEL, wParam, lParam)) {
         return LRESULT.ZERO;
     }
-    return LRESULT.NULL;
+    return null;
 }
 
 LRESULT wmPaint (HWND hwnd, int wParam, int lParam) {
 
     /* Exit early - don't draw the background */
     if (!hooks (DWT.Paint) && !filters (DWT.Paint)) {
-        return LRESULT.NULL;
+        return null;
     }
 
     /* Issue a paint event */
-    LRESULT result = LRESULT.NULL;
+    int result = 0;
     if (OS.IsWinCE) {
         RECT rect;
         OS.GetUpdateRect (hwnd, &rect, false);
         result = callWindowProc (hwnd, OS.WM_PAINT, wParam, lParam);
-        assert( result !is LRESULT.NULL );
         /*
         * Bug in Windows.  When InvalidateRgn(), InvalidateRect()
         * or RedrawWindow() with RDW_INVALIDATE is called from
@@ -2100,7 +2090,6 @@
         auto rgn = OS.CreateRectRgn (0, 0, 0, 0);
         OS.GetUpdateRgn (hwnd, rgn, false);
         result = callWindowProc (hwnd, OS.WM_PAINT, wParam, lParam);
-        assert( result !is LRESULT.NULL );
         GCData data = new GCData ();
         data.hwnd = hwnd;
         GC gc = new_GC (data);
@@ -2130,7 +2119,7 @@
         OS.DeleteObject (rgn);
     }
     if (result is 0) return LRESULT.ZERO;
-    return result;
+    return new LRESULT (result);
 }
 
 LRESULT wmPrint (HWND hwnd, int wParam, int lParam) {
@@ -2144,8 +2133,7 @@
         if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
             int bits = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE);
             if ((bits & OS.WS_EX_CLIENTEDGE) !is 0) {
-                LRESULT code = callWindowProc (hwnd, OS.WM_PRINT, wParam, lParam);
-                assert( code !is LRESULT.NULL );
+                int code = callWindowProc (hwnd, OS.WM_PRINT, wParam, lParam);
                 RECT rect;
                 OS.GetWindowRect (hwnd, &rect);
                 rect.right -= rect.left;
@@ -2154,11 +2142,11 @@
                 int border = OS.GetSystemMetrics (OS.SM_CXEDGE);
                 OS.ExcludeClipRect ( cast(void*)wParam, border, border, rect.right - border, rect.bottom - border);
                 OS.DrawThemeBackground (display.hEditTheme (), cast(HDC)wParam, OS.EP_EDITTEXT, OS.ETS_NORMAL, &rect, null);
-                return cast(LRESULT)code;
+                return new LRESULT (code);
             }
         }
     }
-    return LRESULT.NULL;
+    return null;
 }
 
 LRESULT wmRButtonDblClk (HWND hwnd, int wParam, int lParam) {
@@ -2175,13 +2163,12 @@
     * pairs will not see the second mouse down.  The
     * fix is to send a mouse down event.
     */
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     Display display = this.display;
     display.captureChanged = false;
     sendMouseEvent (DWT.MouseDown, 3, hwnd, OS.WM_RBUTTONDOWN, wParam, lParam);
     if (sendMouseEvent (DWT.MouseDoubleClick, 3, hwnd, OS.WM_RBUTTONDBLCLK, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_RBUTTONDBLCLK, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT (callWindowProc (hwnd, OS.WM_RBUTTONDBLCLK, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }
@@ -2192,12 +2179,11 @@
 }
 
 LRESULT wmRButtonDown (HWND hwnd, int wParam, int lParam) {
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     Display display = this.display;
     display.captureChanged = false;
     if (sendMouseEvent (DWT.MouseDown, 3, hwnd, OS.WM_RBUTTONDOWN, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_RBUTTONDOWN, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT (callWindowProc (hwnd, OS.WM_RBUTTONDOWN, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }
@@ -2209,10 +2195,9 @@
 
 LRESULT wmRButtonUp (HWND hwnd, int wParam, int lParam) {
     Display display = this.display;
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     if (sendMouseEvent (DWT.MouseUp, 3, hwnd, OS.WM_RBUTTONUP, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_RBUTTONUP, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT( callWindowProc (hwnd, OS.WM_RBUTTONUP, wParam, lParam));
     } else {
         /* Call the DefWindowProc() to support WM_CONTEXTMENU */
         OS.DefWindowProc (hwnd, OS.WM_RBUTTONUP, wParam, lParam);
@@ -2233,8 +2218,7 @@
 }
 
 LRESULT wmSetFocus (HWND hwnd, int wParam, int lParam) {
-    LRESULT code = callWindowProc (hwnd, OS.WM_SETFOCUS, wParam, lParam);
-    assert( code !is LRESULT.NULL );
+    int code = callWindowProc (hwnd, OS.WM_SETFOCUS, wParam, lParam);
     sendFocusEvent (DWT.FocusIn);
     // widget could be disposed at this point
 
@@ -2247,7 +2231,7 @@
     */
     if (isDisposed ()) return LRESULT.ZERO;
     if (code is 0) return LRESULT.ZERO;
-    return code;
+    return new LRESULT (code);
 }
 
 LRESULT wmSysChar (HWND hwnd, int wParam, int lParam) {
@@ -2257,14 +2241,13 @@
 
     /* Do not issue a key down if a menu bar mnemonic was invoked */
     if (!hooks (DWT.KeyDown) && !display.filters (DWT.KeyDown)) {
-        return LRESULT.NULL;
+        return null;
     }
 
     /* Call the window proc to determine whether it is a system key or mnemonic */
     bool oldKeyHit = display.mnemonicKeyHit;
     display.mnemonicKeyHit = true;
-    LRESULT result = callWindowProc (hwnd, OS.WM_SYSCHAR, wParam, lParam);
-    assert( result !is LRESULT.NULL );
+    int result = callWindowProc (hwnd, OS.WM_SYSCHAR, wParam, lParam);
     bool consumed = false;
     if (!display.mnemonicKeyHit) {
         consumed = !sendKeyEvent (DWT.KeyDown, OS.WM_SYSCHAR, wParam, lParam);
@@ -2272,7 +2255,7 @@
     }
     consumed |= display.mnemonicKeyHit;
     display.mnemonicKeyHit = oldKeyHit;
-    return consumed ? LRESULT.ONE : result;
+    return consumed ? LRESULT.ONE : new LRESULT (result);
 }
 
 LRESULT wmSysKeyDown (HWND hwnd, int wParam, int lParam) {
@@ -2286,7 +2269,7 @@
     */
     if (wParam !is OS.VK_F10) {
         /* Make sure WM_SYSKEYDOWN was sent by ALT-<aKey>. */
-        if ((lParam & 0x20000000) is 0) return LRESULT.NULL;
+        if ((lParam & 0x20000000) is 0) return null;
     }
 
     /* Ignore well known system keys */
@@ -2298,7 +2281,7 @@
                 hwndShell = OS.GetParent (hwndShell);
             }
             int bits = OS.GetWindowLong (hwndShell, OS.GWL_STYLE);
-            if ((bits & OS.WS_SYSMENU) !is 0) return LRESULT.NULL;
+            if ((bits & OS.WS_SYSMENU) !is 0) return null;
         }
         default:
     }
@@ -2311,7 +2294,7 @@
         case OS.VK_CAPITAL:
         case OS.VK_NUMLOCK:
         case OS.VK_SCROLL:
-            if ((lParam & 0x40000000) !is 0) return LRESULT.NULL;
+            if ((lParam & 0x40000000) !is 0) return null;
         default:
     }
 
@@ -2370,7 +2353,7 @@
                 case OS.VK_ADD:
                 case OS.VK_SUBTRACT:
                 case OS.VK_DECIMAL:
-                case OS.VK_DIVIDE: return LRESULT.NULL;
+                case OS.VK_DIVIDE: return null;
                 default:
             }
             display.lastAscii = display.numpadKey (display.lastKey);
@@ -2390,8 +2373,8 @@
         * this message never happens.  The fix is to issue the
         * event from WM_SYSKEYDOWN and map VK_RETURN to '\r'.
         */
-        if (OS.IsWinNT) return LRESULT.NULL;
-        if (wParam !is OS.VK_RETURN) return LRESULT.NULL;
+        if (OS.IsWinNT) return null;
+        if (wParam !is OS.VK_RETURN) return null;
         display.lastAscii = '\r';
     }
 
@@ -2399,7 +2382,7 @@
         return LRESULT.ONE;
     }
     // widget could be disposed at this point
-    return LRESULT.NULL;
+    return null;
 }
 
 LRESULT wmSysKeyUp (HWND hwnd, int wParam, int lParam) {
@@ -2420,14 +2403,13 @@
     * pairs will not see the second mouse down.  The
     * fix is to send a mouse down event.
     */
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     Display display = this.display;
     display.captureChanged = false;
     int button = (wParam >> 16 is OS.XBUTTON1) ? 4 : 5;
     sendMouseEvent (DWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam);
     if (sendMouseEvent (DWT.MouseDoubleClick, button, hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT (callWindowProc (hwnd, OS.WM_XBUTTONDBLCLK, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }
@@ -2438,14 +2420,13 @@
 }
 
 LRESULT wmXButtonDown (HWND hwnd, int wParam, int lParam) {
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     Display display = this.display;
     display.captureChanged = false;
     display.xMouse = true;
     int button = (wParam >> 16 is OS.XBUTTON1) ? 4 : 5;
     if (sendMouseEvent (DWT.MouseDown, button, hwnd, OS.WM_XBUTTONDOWN, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_XBUTTONDOWN, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT (callWindowProc (hwnd, OS.WM_XBUTTONDOWN, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }
@@ -2457,11 +2438,10 @@
 
 LRESULT wmXButtonUp (HWND hwnd, int wParam, int lParam) {
     Display display = this.display;
-    LRESULT result = LRESULT.NULL;
+    LRESULT result = null;
     int button = (wParam >> 16 is OS.XBUTTON1) ? 4 : 5;
     if (sendMouseEvent (DWT.MouseUp, button, hwnd, OS.WM_XBUTTONUP, wParam, lParam)) {
-        result = callWindowProc (hwnd, OS.WM_XBUTTONUP, wParam, lParam);
-        assert( result !is LRESULT.NULL );
+        result = new LRESULT (callWindowProc (hwnd, OS.WM_XBUTTONUP, wParam, lParam));
     } else {
         result = LRESULT.ZERO;
     }