comparison dwt/widgets/Control.d @ 213:36f5cb12e1a2

Update to SWT 3.4M7
author Frank Benoit <benoit@tionex.de>
date Sat, 17 May 2008 17:34:28 +0200
parents ab60f3309436
children fd9c62a2998e
comparison
equal deleted inserted replaced
212:ab60f3309436 213:36f5cb12e1a2
35 import dwt.graphics.GC; 35 import dwt.graphics.GC;
36 import dwt.graphics.GCData; 36 import dwt.graphics.GCData;
37 import dwt.graphics.Image; 37 import dwt.graphics.Image;
38 import dwt.graphics.Point; 38 import dwt.graphics.Point;
39 import dwt.graphics.Rectangle; 39 import dwt.graphics.Rectangle;
40 import dwt.graphics.Region;
40 import dwt.internal.win32.OS; 41 import dwt.internal.win32.OS;
41 import dwt.widgets.Widget; 42 import dwt.widgets.Widget;
42 import dwt.widgets.Composite; 43 import dwt.widgets.Composite;
44 import dwt.widgets.Dialog;
43 import dwt.widgets.Event; 45 import dwt.widgets.Event;
44 import dwt.widgets.Shell; 46 import dwt.widgets.Shell;
45 import dwt.widgets.Menu; 47 import dwt.widgets.Menu;
46 import dwt.widgets.MenuItem; 48 import dwt.widgets.MenuItem;
47 import dwt.widgets.Decorations; 49 import dwt.widgets.Decorations;
99 Menu menu; 101 Menu menu;
100 String toolTipText_; 102 String toolTipText_;
101 Object layoutData; 103 Object layoutData;
102 Accessible accessible; 104 Accessible accessible;
103 Image backgroundImage; 105 Image backgroundImage;
106 Region region;
107 Font font;
104 int drawCount, foreground, background; 108 int drawCount, foreground, background;
105 109
106 /** 110 /**
107 * Prevents uninitialized instances from being created outside the package. 111 * Prevents uninitialized instances from being created outside the package.
108 */ 112 */
514 518
515 void checkBuffered () { 519 void checkBuffered () {
516 style &= ~DWT.DOUBLE_BUFFERED; 520 style &= ~DWT.DOUBLE_BUFFERED;
517 } 521 }
518 522
523 void checkComposited () {
524 /* Do nothing */
525 }
526
519 bool checkHandle (HWND hwnd) { 527 bool checkHandle (HWND hwnd) {
520 return hwnd is handle; 528 return hwnd is handle;
521 } 529 }
522 530
523 void checkMirrored () { 531 void checkMirrored () {
646 OS.GetModuleHandle (null), 654 OS.GetModuleHandle (null),
647 widgetCreateStruct ()); 655 widgetCreateStruct ());
648 if (handle is null) error (DWT.ERROR_NO_HANDLES); 656 if (handle is null) error (DWT.ERROR_NO_HANDLES);
649 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 657 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
650 if ((bits & OS.WS_CHILD) !is 0) { 658 if ((bits & OS.WS_CHILD) !is 0) {
651 OS.SetWindowLong (handle, OS.GWL_ID, cast(int)handle); 659 OS.SetWindowLongPtr (handle, OS.GWLP_ID, cast(LONG_PTR)handle);
652 } 660 }
653 if (OS.IsDBLocale && hwndParent !is null) { 661 if (OS.IsDBLocale && hwndParent !is null) {
654 auto hIMC = OS.ImmGetContext (hwndParent); 662 auto hIMC = OS.ImmGetContext (hwndParent);
655 OS.ImmAssociateContext (handle, hIMC); 663 OS.ImmAssociateContext (handle, hIMC);
656 OS.ImmReleaseContext (hwndParent, hIMC); 664 OS.ImmReleaseContext (hwndParent, hIMC);
662 foreground = background = -1; 670 foreground = background = -1;
663 checkOrientation (parent); 671 checkOrientation (parent);
664 createHandle (); 672 createHandle ();
665 checkBackground (); 673 checkBackground ();
666 checkBuffered (); 674 checkBuffered ();
675 checkComposited ();
667 register (); 676 register ();
668 subclass (); 677 subclass ();
669 setDefaultFont (); 678 setDefaultFont ();
670 checkMirrored (); 679 checkMirrored ();
671 checkBorder (); 680 checkBorder ();
818 if ((stateMask & DWT.BUTTON1) !is 0) wParam |= OS.MK_LBUTTON; 827 if ((stateMask & DWT.BUTTON1) !is 0) wParam |= OS.MK_LBUTTON;
819 if ((stateMask & DWT.BUTTON2) !is 0) wParam |= OS.MK_MBUTTON; 828 if ((stateMask & DWT.BUTTON2) !is 0) wParam |= OS.MK_MBUTTON;
820 if ((stateMask & DWT.BUTTON3) !is 0) wParam |= OS.MK_RBUTTON; 829 if ((stateMask & DWT.BUTTON3) !is 0) wParam |= OS.MK_RBUTTON;
821 if ((stateMask & DWT.BUTTON4) !is 0) wParam |= OS.MK_XBUTTON1; 830 if ((stateMask & DWT.BUTTON4) !is 0) wParam |= OS.MK_XBUTTON1;
822 if ((stateMask & DWT.BUTTON5) !is 0) wParam |= OS.MK_XBUTTON2; 831 if ((stateMask & DWT.BUTTON5) !is 0) wParam |= OS.MK_XBUTTON2;
823 int lParam = (x & 0xFFFF) | ((y << 16) & 0xFFFF0000); 832 int /*long*/ lParam = OS.MAKELPARAM (x, y);
824 OS.SendMessage (handle, OS.WM_LBUTTONUP, wParam, lParam); 833 OS.SendMessage (handle, OS.WM_LBUTTONUP, wParam, lParam);
825 } 834 }
826 return false; 835 return false;
827 } 836 }
828 return sendDragEvent (button, stateMask, x, y); 837 return sendDragEvent (button, stateMask, x, y);
1244 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 1253 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1245 * </ul> 1254 * </ul>
1246 */ 1255 */
1247 public Font getFont () { 1256 public Font getFont () {
1248 checkWidget (); 1257 checkWidget ();
1258 if (font !is null) return font;
1249 auto hFont = cast(HFONT)OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); 1259 auto hFont = cast(HFONT)OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
1250 if (hFont is null) hFont = defaultFont (); 1260 if (hFont is null) hFont = defaultFont ();
1251 return Font.win32_new (display, hFont); 1261 return Font.win32_new (display, hFont);
1252 } 1262 }
1253 1263
1387 while (control !is shell) { 1397 while (control !is shell) {
1388 result [--count] = control; 1398 result [--count] = control;
1389 control = control.parent; 1399 control = control.parent;
1390 } 1400 }
1391 return result; 1401 return result;
1402 }
1403
1404 /**
1405 * Returns the region that defines the shape of the control,
1406 * or null if the control has the default shape.
1407 *
1408 * @return the region that defines the shape of the shell (or null)
1409 *
1410 * @exception DWTException <ul>
1411 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1412 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1413 * </ul>
1414 *
1415 * @since 3.4
1416 *
1417 */
1418 public Region getRegion () {
1419 checkWidget ();
1420 return region;
1392 } 1421 }
1393 1422
1394 /** 1423 /**
1395 * Returns the receiver's shell. For all controls other than 1424 * Returns the receiver's shell. For all controls other than
1396 * shells, this simply returns the control's nearest ancestor 1425 * shells, this simply returns the control's nearest ancestor
1545 if (foreground !is OS.GetTextColor (hDC)) data.foreground = foreground; 1574 if (foreground !is OS.GetTextColor (hDC)) data.foreground = foreground;
1546 Control control = findBackgroundControl (); 1575 Control control = findBackgroundControl ();
1547 if (control is null) control = this; 1576 if (control is null) control = this;
1548 auto background = control.getBackgroundPixel (); 1577 auto background = control.getBackgroundPixel ();
1549 if (background !is OS.GetBkColor (hDC)) data.background = background; 1578 if (background !is OS.GetBkColor (hDC)) data.background = background;
1550 data.hFont = cast(HFONT) OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0); 1579 data.font = font !is null ? font : Font.win32_new (display, cast(HFONT)OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0));
1551 data.uiState = OS.SendMessage (hwnd, OS.WM_QUERYUISTATE, 0, 0); 1580 data.uiState = OS.SendMessage (hwnd, OS.WM_QUERYUISTATE, 0, 0);
1552 } 1581 }
1553 return hDC; 1582 return hDC;
1554 } 1583 }
1555 1584
1578 OS.EndPaint (hwnd, data.ps); 1607 OS.EndPaint (hwnd, data.ps);
1579 } 1608 }
1580 } 1609 }
1581 1610
1582 bool isActive () { 1611 bool isActive () {
1583 Shell dialogShell = display.getModalDialogShell (); 1612 Dialog dialog = display.getModalDialog ();
1584 if (dialogShell !is null && dialogShell !is getShell ()) { 1613 if (dialog !is null) {
1585 return false; 1614 Shell dialogShell = dialog.parent;
1615 if (dialogShell !is null && !dialogShell.isDisposed ()) {
1616 if (dialogShell !is getShell ()) return false;
1617 }
1586 } 1618 }
1587 Shell shell = null; 1619 Shell shell = null;
1588 Shell [] modalShells = display.modalShells; 1620 Shell [] modalShells = display.modalShells;
1589 if (modalShells !is null) { 1621 if (modalShells !is null) {
1590 int bits = DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL; 1622 int bits = DWT.APPLICATION_MODAL | DWT.SYSTEM_MODAL;
1694 /* 1726 /*
1695 * Check to see if current damage is included. 1727 * Check to see if current damage is included.
1696 */ 1728 */
1697 // if (!OS.IsWindowVisible (handle)) return false; 1729 // if (!OS.IsWindowVisible (handle)) return false;
1698 // int flags = OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS; 1730 // int flags = OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS;
1699 // int hDC = OS.GetDCEx (handle, 0, flags); 1731 // int /*long*/ hDC = OS.GetDCEx (handle, 0, flags);
1700 // int result = OS.GetClipBox (hDC, new RECT ()); 1732 // int result = OS.GetClipBox (hDC, new RECT ());
1701 // OS.ReleaseDC (handle, hDC); 1733 // OS.ReleaseDC (handle, hDC);
1702 // return result !is OS.NULLREGION; 1734 // return result !is OS.NULLREGION;
1703 } 1735 }
1704 1736
1720 if (tabList [i] is this) return false; 1752 if (tabList [i] is this) return false;
1721 } 1753 }
1722 } 1754 }
1723 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); 1755 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
1724 if ((bits & OS.WS_TABSTOP) !is 0) return false; 1756 if ((bits & OS.WS_TABSTOP) !is 0) return false;
1725 int code = OS.SendMessage (handle, OS.WM_GETDLGCODE, 0, 0); 1757 int /*long*/ code = OS.SendMessage (handle, OS.WM_GETDLGCODE, 0, 0);
1726 if ((code & OS.DLGC_STATIC) !is 0) return false; 1758 if ((code & OS.DLGC_STATIC) !is 0) return false;
1727 if ((code & OS.DLGC_WANTALLKEYS) !is 0) return false; 1759 if ((code & OS.DLGC_WANTALLKEYS) !is 0) return false;
1728 if ((code & OS.DLGC_WANTARROWS) !is 0) return false; 1760 if ((code & OS.DLGC_WANTARROWS) !is 0) return false;
1729 if ((code & OS.DLGC_WANTTAB) !is 0) return false; 1761 if ((code & OS.DLGC_WANTTAB) !is 0) return false;
1730 return true; 1762 return true;
1934 checkWidget (); 1966 checkWidget ();
1935 setSize (computeSize (DWT.DEFAULT, DWT.DEFAULT, changed)); 1967 setSize (computeSize (DWT.DEFAULT, DWT.DEFAULT, changed));
1936 } 1968 }
1937 1969
1938 /** 1970 /**
1971 * Prints the receiver and all children.
1972 *
1973 * @param gc the gc where the drawing occurs
1974 *
1975 * @exception IllegalArgumentException <ul>
1976 * <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
1977 * <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li>
1978 * </ul>
1979 * @exception DWTException <ul>
1980 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
1981 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
1982 * </ul>
1983 *
1984 * @since 3.4
1985 */
1986 public bool print (GC gc) {
1987 checkWidget ();
1988 if (gc is null) error (DWT.ERROR_NULL_ARGUMENT);
1989 if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
1990 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (5, 1)) {
1991 auto topHandle = topHandle ();
1992 int bits = OS.GetWindowLong (topHandle, OS.GWL_STYLE);
1993 if ((bits & OS.WS_VISIBLE) is 0) {
1994 OS.DefWindowProc (topHandle, OS.WM_SETREDRAW, 1, 0);
1995 }
1996 printWidget (topHandle, gc.handle);
1997 if ((bits & OS.WS_VISIBLE) is 0) {
1998 OS.DefWindowProc (topHandle, OS.WM_SETREDRAW, 0, 0);
1999 }
2000 return true;
2001 }
2002 return false;
2003 }
2004
2005 void printWidget (HWND hwnd, HDC hDC) {
2006 OS.PrintWindow (hwnd, hDC, 0);
2007 }
2008
2009 /**
1939 * Causes the entire bounds of the receiver to be marked 2010 * Causes the entire bounds of the receiver to be marked
1940 * as needing to be redrawn. The next time a paint request 2011 * as needing to be redrawn. The next time a paint request
1941 * is processed, the control will be completely painted, 2012 * is processed, the control will be completely painted,
1942 * including the background. 2013 * including the background.
1943 * 2014 *
2068 layoutData = null; 2139 layoutData = null;
2069 if (accessible !is null) { 2140 if (accessible !is null) {
2070 accessible.internal_dispose_Accessible (); 2141 accessible.internal_dispose_Accessible ();
2071 } 2142 }
2072 accessible = null; 2143 accessible = null;
2144 region = null;
2145 font = null;
2073 } 2146 }
2074 2147
2075 /** 2148 /**
2076 * Removes the listener from the collection of listeners who will 2149 * Removes the listener from the collection of listeners who will
2077 * be notified when the control is moved or resized. 2150 * be notified when the control is moved or resized.
2421 } 2494 }
2422 } 2495 }
2423 return true; 2496 return true;
2424 } 2497 }
2425 2498
2499 void sendMove () {
2500 sendEvent (DWT.Move);
2501 }
2502
2503 void sendResize () {
2504 sendEvent (DWT.Resize);
2505 }
2506
2426 void setBackground () { 2507 void setBackground () {
2427 Control control = findBackgroundControl (); 2508 Control control = findBackgroundControl ();
2428 if (control is null) control = this; 2509 if (control is null) control = this;
2429 if (control.backgroundImage !is null) { 2510 if (control.backgroundImage !is null) {
2430 Shell shell = getShell (); 2511 Shell shell = getShell ();
2550 void setBounds (int x, int y, int width, int height, int flags) { 2631 void setBounds (int x, int y, int width, int height, int flags) {
2551 setBounds (x, y, width, height, flags, true); 2632 setBounds (x, y, width, height, flags, true);
2552 } 2633 }
2553 2634
2554 void setBounds (int x, int y, int width, int height, int flags, bool defer) { 2635 void setBounds (int x, int y, int width, int height, int flags, bool defer) {
2636 if (findImageControl () !is null) {
2637 if (backgroundImage is null) flags |= OS.SWP_NOCOPYBITS;
2638 } else {
2639 if (OS.GetWindow (handle, OS.GW_CHILD) is null) {
2640 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
2641 if (findThemeControl () !is null) flags |= OS.SWP_NOCOPYBITS;
2642 }
2643 }
2644 }
2555 auto topHandle_ = topHandle (); 2645 auto topHandle_ = topHandle ();
2556 if (defer && parent !is null) { 2646 if (defer && parent !is null) {
2557 forceResize (); 2647 forceResize ();
2558 if (OS.GetWindow (handle, OS.GW_CHILD) is null) { 2648 if (parent.lpwp !is null) {
2559 if (findImageControl () !is null) {
2560 flags |= OS.SWP_NOCOPYBITS;
2561 } else {
2562 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
2563 if (findThemeControl () !is null) flags |= OS.SWP_NOCOPYBITS;
2564 }
2565 }
2566 }
2567 WINDOWPOS* [] lpwp = parent.lpwp;
2568 if (lpwp is null) {
2569 SetWindowPos (topHandle_, null, x, y, width, height, flags);
2570 } else {
2571 int index = 0; 2649 int index = 0;
2650 auto lpwp = parent.lpwp;
2572 while (index < lpwp.length) { 2651 while (index < lpwp.length) {
2573 if (lpwp [index] is null) break; 2652 if (lpwp [index] is null) break;
2574 index ++; 2653 index ++;
2575 } 2654 }
2576 if (index is lpwp.length) { 2655 if (index is lpwp.length) {
2584 wp.y = y; 2663 wp.y = y;
2585 wp.cx = width; 2664 wp.cx = width;
2586 wp.cy = height; 2665 wp.cy = height;
2587 wp.flags = flags; 2666 wp.flags = flags;
2588 lpwp [index] = wp; 2667 lpwp [index] = wp;
2589 } 2668 return;
2590 } else { 2669 }
2591 SetWindowPos (topHandle_, null, x, y, width, height, flags); 2670 }
2592 } 2671 SetWindowPos (topHandle_, null, x, y, width, height, flags);
2593 } 2672 }
2594 2673
2595 /** 2674 /**
2596 * Sets the receiver's size and location to the rectangular 2675 * Sets the receiver's size and location to the rectangular
2597 * area specified by the argument. The <code>x</code> and 2676 * area specified by the argument. The <code>x</code> and
2617 } 2696 }
2618 2697
2619 /** 2698 /**
2620 * If the argument is <code>true</code>, causes the receiver to have 2699 * If the argument is <code>true</code>, causes the receiver to have
2621 * all mouse events delivered to it until the method is called with 2700 * all mouse events delivered to it until the method is called with
2622 * <code>false</code> as the argument. 2701 * <code>false</code> as the argument. Note that on some platforms,
2702 * a mouse button must currently be down for capture to be assigned.
2623 * 2703 *
2624 * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it 2704 * @param capture <code>true</code> to capture the mouse, and <code>false</code> to release it
2625 * 2705 *
2626 * @exception DWTException <ul> 2706 * @exception DWTException <ul>
2627 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 2707 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
2638 } 2718 }
2639 } 2719 }
2640 } 2720 }
2641 2721
2642 void setCursor () { 2722 void setCursor () {
2643 int lParam = OS.HTCLIENT | (OS.WM_MOUSEMOVE << 16); 2723 int /*long*/ lParam = OS.MAKELPARAM (OS.HTCLIENT, OS.WM_MOUSEMOVE);
2644 OS.SendMessage (handle, OS.WM_SETCURSOR, handle, lParam); 2724 OS.SendMessage (handle, OS.WM_SETCURSOR, handle, lParam);
2645 } 2725 }
2646 2726
2647 /** 2727 /**
2648 * Sets the receiver's cursor to the cursor specified by the 2728 * Sets the receiver's cursor to the cursor specified by the
2666 public void setCursor (Cursor cursor) { 2746 public void setCursor (Cursor cursor) {
2667 checkWidget (); 2747 checkWidget ();
2668 if (cursor !is null && cursor.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 2748 if (cursor !is null && cursor.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
2669 this.cursor = cursor; 2749 this.cursor = cursor;
2670 static if (OS.IsWinCE) { 2750 static if (OS.IsWinCE) {
2671 int hCursor = cursor !is null ? cursor.handle : 0; 2751 int /*long*/ hCursor = cursor !is null ? cursor.handle : 0;
2672 OS.SetCursor (hCursor); 2752 OS.SetCursor (hCursor);
2673 return; 2753 return;
2674 } 2754 }
2675 auto hwndCursor = OS.GetCapture (); 2755 auto hwndCursor = OS.GetCapture ();
2676 if (hwndCursor is null) { 2756 if (hwndCursor is null) {
2795 HFONT hFont; 2875 HFONT hFont;
2796 if (font !is null) { 2876 if (font !is null) {
2797 if (font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT); 2877 if (font.isDisposed()) DWT.error(DWT.ERROR_INVALID_ARGUMENT);
2798 hFont = font.handle; 2878 hFont = font.handle;
2799 } 2879 }
2880 this.font = font;
2800 if (hFont is null) hFont = defaultFont (); 2881 if (hFont is null) hFont = defaultFont ();
2801 OS.SendMessage (handle, OS.WM_SETFONT, hFont, 1); 2882 OS.SendMessage (handle, OS.WM_SETFONT, hFont, 1);
2802 } 2883 }
2803 2884
2804 /** 2885 /**
3008 if (handle !is topHandle_) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0); 3089 if (handle !is topHandle_) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
3009 } 3090 }
3010 } 3091 }
3011 } 3092 }
3012 3093
3094 /**
3095 * Sets the shape of the control to the region specified
3096 * by the argument. When the argument is null, the
3097 * default shape of the control is restored.
3098 *
3099 * @param region the region that defines the shape of the control (or null)
3100 *
3101 * @exception IllegalArgumentException <ul>
3102 * <li>ERROR_INVALID_ARGUMENT - if the region has been disposed</li>
3103 * </ul>
3104 * @exception DWTException <ul>
3105 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
3106 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
3107 * </ul>
3108 *
3109 * @since 3.4
3110 *
3111 */
3112 public void setRegion (Region region) {
3113 checkWidget ();
3114 if (region !is null && region.isDisposed()) error (DWT.ERROR_INVALID_ARGUMENT);
3115 HRGN hRegion;
3116 if (region !is null) {
3117 hRegion = OS.CreateRectRgn (0, 0, 0, 0);
3118 OS.CombineRgn (hRegion, region.handle, hRegion, OS.RGN_OR);
3119 }
3120 OS.SetWindowRgn (handle, hRegion, true);
3121 this.region = region;
3122 }
3123
3013 bool setSavedFocus () { 3124 bool setSavedFocus () {
3014 return forceFocus (); 3125 return forceFocus ();
3015 } 3126 }
3016 3127
3017 /** 3128 /**
3162 } 3273 }
3163 } 3274 }
3164 } 3275 }
3165 3276
3166 void subclass () { 3277 void subclass () {
3167 int oldProc = windowProc (); 3278 int /*long*/ oldProc = windowProc ();
3168 int newProc = display.windowProc(); 3279 int newProc = display.windowProc();
3169 if (oldProc is newProc) return; 3280 if (oldProc is newProc) return;
3170 OS.SetWindowLong (handle, OS.GWL_WNDPROC, newProc); 3281 OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, newProc);
3171 } 3282 }
3172 3283
3173 /** 3284 /**
3174 * Returns a point which is the result of converting the 3285 * Returns a point which is the result of converting the
3175 * argument, which is specified in display relative coordinates, 3286 * argument, which is specified in display relative coordinates,
3279 3390
3280 bool translateMnemonic (MSG* msg) { 3391 bool translateMnemonic (MSG* msg) {
3281 if (msg.wParam < 0x20) return false; 3392 if (msg.wParam < 0x20) return false;
3282 auto hwnd = msg.hwnd; 3393 auto hwnd = msg.hwnd;
3283 if (OS.GetKeyState (OS.VK_MENU) >= 0) { 3394 if (OS.GetKeyState (OS.VK_MENU) >= 0) {
3284 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3395 int /*long*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
3285 if ((code & OS.DLGC_WANTALLKEYS) !is 0) return false; 3396 if ((code & OS.DLGC_WANTALLKEYS) !is 0) return false;
3286 if ((code & OS.DLGC_BUTTON) is 0) return false; 3397 if ((code & OS.DLGC_BUTTON) is 0) return false;
3287 } 3398 }
3288 Decorations shell = menuShell (); 3399 Decorations shell = menuShell ();
3289 if (shell.isVisible () && shell.isEnabled ()) { 3400 if (shell.isVisible () && shell.isEnabled ()) {
3311 int lastKey = key, lastAscii = 0; 3422 int lastKey = key, lastAscii = 0;
3312 switch (key) { 3423 switch (key) {
3313 case OS.VK_ESCAPE: { 3424 case OS.VK_ESCAPE: {
3314 all = true; 3425 all = true;
3315 lastAscii = 27; 3426 lastAscii = 27;
3316 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3427 int /*long*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
3317 if ((code & OS.DLGC_WANTALLKEYS) !is 0) { 3428 if ((code & OS.DLGC_WANTALLKEYS) !is 0) {
3318 /* 3429 /*
3319 * Use DLGC_HASSETSEL to determine that the control 3430 * Use DLGC_HASSETSEL to determine that the control
3320 * is a text widget. A text widget normally wants 3431 * is a text widget. A text widget normally wants
3321 * all keys except VK_ESCAPE. If this bit is not 3432 * all keys except VK_ESCAPE. If this bit is not
3328 break; 3439 break;
3329 } 3440 }
3330 case OS.VK_RETURN: { 3441 case OS.VK_RETURN: {
3331 all = true; 3442 all = true;
3332 lastAscii = '\r'; 3443 lastAscii = '\r';
3333 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3444 int /*long*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
3334 if ((code & OS.DLGC_WANTALLKEYS) !is 0) doit = false; 3445 if ((code & OS.DLGC_WANTALLKEYS) !is 0) doit = false;
3335 detail = DWT.TRAVERSE_RETURN; 3446 detail = DWT.TRAVERSE_RETURN;
3336 break; 3447 break;
3337 } 3448 }
3338 case OS.VK_TAB: { 3449 case OS.VK_TAB: {
3339 lastAscii = '\t'; 3450 lastAscii = '\t';
3340 bool next = OS.GetKeyState (OS.VK_SHIFT) >= 0; 3451 bool next = OS.GetKeyState (OS.VK_SHIFT) >= 0;
3341 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3452 int /*long*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
3342 if ((code & (OS.DLGC_WANTTAB | OS.DLGC_WANTALLKEYS)) !is 0) { 3453 if ((code & (OS.DLGC_WANTTAB | OS.DLGC_WANTALLKEYS)) !is 0) {
3343 /* 3454 /*
3344 * Use DLGC_HASSETSEL to determine that the control is a 3455 * Use DLGC_HASSETSEL to determine that the control is a
3345 * text widget. If the control is a text widget, then 3456 * text widget. If the control is a text widget, then
3346 * Ctrl+Tab and Shift+Tab should traverse out of the widget. 3457 * Ctrl+Tab and Shift+Tab should traverse out of the widget.
3354 } 3465 }
3355 } else { 3466 } else {
3356 doit = false; 3467 doit = false;
3357 } 3468 }
3358 } 3469 }
3359 if (parent !is null && (parent.style & DWT.MIRRORED) !is 0) {
3360 if (key is OS.VK_LEFT || key is OS.VK_RIGHT) next = !next;
3361 }
3362 detail = next ? DWT.TRAVERSE_TAB_NEXT : DWT.TRAVERSE_TAB_PREVIOUS; 3470 detail = next ? DWT.TRAVERSE_TAB_NEXT : DWT.TRAVERSE_TAB_PREVIOUS;
3363 break; 3471 break;
3364 } 3472 }
3365 case OS.VK_UP: 3473 case OS.VK_UP:
3366 case OS.VK_LEFT: 3474 case OS.VK_LEFT:
3373 */ 3481 */
3374 if (OS.IsSP) { 3482 if (OS.IsSP) {
3375 if (key is OS.VK_LEFT || key is OS.VK_RIGHT) return false; 3483 if (key is OS.VK_LEFT || key is OS.VK_RIGHT) return false;
3376 } 3484 }
3377 lastVirtual = true; 3485 lastVirtual = true;
3378 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3486 int /*long*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
3379 if ((code & (OS.DLGC_WANTARROWS /*| OS.DLGC_WANTALLKEYS*/)) !is 0) doit = false; 3487 if ((code & (OS.DLGC_WANTARROWS /*| OS.DLGC_WANTALLKEYS*/)) !is 0) doit = false;
3380 bool next = key is OS.VK_DOWN || key is OS.VK_RIGHT; 3488 bool next = key is OS.VK_DOWN || key is OS.VK_RIGHT;
3489 if (parent !is null && (parent.style & DWT.MIRRORED) !is 0) {
3490 if (key is OS.VK_LEFT || key is OS.VK_RIGHT) next = !next;
3491 }
3381 detail = next ? DWT.TRAVERSE_ARROW_NEXT : DWT.TRAVERSE_ARROW_PREVIOUS; 3492 detail = next ? DWT.TRAVERSE_ARROW_NEXT : DWT.TRAVERSE_ARROW_PREVIOUS;
3382 break; 3493 break;
3383 } 3494 }
3384 case OS.VK_PRIOR: 3495 case OS.VK_PRIOR:
3385 case OS.VK_NEXT: { 3496 case OS.VK_NEXT: {
3386 all = true; 3497 all = true;
3387 lastVirtual = true; 3498 lastVirtual = true;
3388 if (OS.GetKeyState (OS.VK_CONTROL) >= 0) return false; 3499 if (OS.GetKeyState (OS.VK_CONTROL) >= 0) return false;
3389 int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0); 3500 int /*long*/ code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
3390 if ((code & OS.DLGC_WANTALLKEYS) !is 0) { 3501 if ((code & OS.DLGC_WANTALLKEYS) !is 0) {
3391 /* 3502 /*
3392 * Use DLGC_HASSETSEL to determine that the control is a 3503 * Use DLGC_HASSETSEL to determine that the control is a
3393 * text widget. If the control is a text widget, then 3504 * text widget. If the control is a text widget, then
3394 * Ctrl+PgUp and Ctrl+PgDn should traverse out of the widget. 3505 * Ctrl+PgUp and Ctrl+PgDn should traverse out of the widget.
3544 bool traverseReturn () { 3655 bool traverseReturn () {
3545 return false; 3656 return false;
3546 } 3657 }
3547 3658
3548 void unsubclass () { 3659 void unsubclass () {
3549 int newProc = windowProc (); 3660 int /*long*/ newProc = windowProc ();
3550 int oldProc = display.windowProc; 3661 int /*long*/ oldProc = display.windowProc;
3551 if (oldProc is newProc) return; 3662 if (oldProc is newProc) return;
3552 OS.SetWindowLong (handle, OS.GWL_WNDPROC, newProc); 3663 OS.SetWindowLongPtr (handle, OS.GWLP_WNDPROC, newProc);
3553 } 3664 }
3554 3665
3555 /** 3666 /**
3556 * Forces all outstanding paint requests for the widget 3667 * Forces all outstanding paint requests for the widget
3557 * to be processed before this method returns. If there 3668 * to be processed before this method returns. If there
3709 return true; 3820 return true;
3710 } 3821 }
3711 3822
3712 abstract String windowClass (); 3823 abstract String windowClass ();
3713 3824
3714 abstract int windowProc (); 3825 abstract int /*long*/ windowProc ();
3715 3826
3716 int windowProc (HWND hwnd, int msg, int wParam, int lParam) { 3827 int windowProc (HWND hwnd, int msg, int wParam, int lParam) {
3717 LRESULT result = null; 3828 LRESULT result = null;
3718 switch (msg) { 3829 switch (msg) {
3719 case OS.WM_ACTIVATE: result = WM_ACTIVATE (wParam, lParam); break; 3830 case OS.WM_ACTIVATE: result = WM_ACTIVATE (wParam, lParam); break;
3720 case OS.WM_CAPTURECHANGED: result = WM_CAPTURECHANGED (wParam, lParam); break; 3831 case OS.WM_CAPTURECHANGED: result = WM_CAPTURECHANGED (wParam, lParam); break;
3832 case OS.WM_CHANGEUISTATE: result = WM_CHANGEUISTATE (wParam, lParam); break;
3721 case OS.WM_CHAR: result = WM_CHAR (wParam, lParam); break; 3833 case OS.WM_CHAR: result = WM_CHAR (wParam, lParam); break;
3722 case OS.WM_CLEAR: result = WM_CLEAR (wParam, lParam); break; 3834 case OS.WM_CLEAR: result = WM_CLEAR (wParam, lParam); break;
3723 case OS.WM_CLOSE: result = WM_CLOSE (wParam, lParam); break; 3835 case OS.WM_CLOSE: result = WM_CLOSE (wParam, lParam); break;
3724 case OS.WM_COMMAND: result = WM_COMMAND (wParam, lParam); break; 3836 case OS.WM_COMMAND: result = WM_COMMAND (wParam, lParam); break;
3725 case OS.WM_CONTEXTMENU: result = WM_CONTEXTMENU (wParam, lParam); break; 3837 case OS.WM_CONTEXTMENU: result = WM_CONTEXTMENU (wParam, lParam); break;
3742 case OS.WM_GETMINMAXINFO: result = WM_GETMINMAXINFO (wParam, lParam); break; 3854 case OS.WM_GETMINMAXINFO: result = WM_GETMINMAXINFO (wParam, lParam); break;
3743 case OS.WM_HELP: result = WM_HELP (wParam, lParam); break; 3855 case OS.WM_HELP: result = WM_HELP (wParam, lParam); break;
3744 case OS.WM_HSCROLL: result = WM_HSCROLL (wParam, lParam); break; 3856 case OS.WM_HSCROLL: result = WM_HSCROLL (wParam, lParam); break;
3745 case OS.WM_IME_CHAR: result = WM_IME_CHAR (wParam, lParam); break; 3857 case OS.WM_IME_CHAR: result = WM_IME_CHAR (wParam, lParam); break;
3746 case OS.WM_IME_COMPOSITION: result = WM_IME_COMPOSITION (wParam, lParam); break; 3858 case OS.WM_IME_COMPOSITION: result = WM_IME_COMPOSITION (wParam, lParam); break;
3859 case OS.WM_IME_COMPOSITION_START: result = WM_IME_COMPOSITION_START (wParam, lParam); break;
3860 case OS.WM_IME_ENDCOMPOSITION: result = WM_IME_ENDCOMPOSITION (wParam, lParam); break;
3747 case OS.WM_INITMENUPOPUP: result = WM_INITMENUPOPUP (wParam, lParam); break; 3861 case OS.WM_INITMENUPOPUP: result = WM_INITMENUPOPUP (wParam, lParam); break;
3748 case OS.WM_INPUTLANGCHANGE: result = WM_INPUTLANGCHANGE (wParam, lParam); break; 3862 case OS.WM_INPUTLANGCHANGE: result = WM_INPUTLANGCHANGE (wParam, lParam); break;
3749 case OS.WM_HOTKEY: result = WM_HOTKEY (wParam, lParam); break; 3863 case OS.WM_HOTKEY: result = WM_HOTKEY (wParam, lParam); break;
3750 case OS.WM_KEYDOWN: result = WM_KEYDOWN (wParam, lParam); break; 3864 case OS.WM_KEYDOWN: result = WM_KEYDOWN (wParam, lParam); break;
3751 case OS.WM_KEYUP: result = WM_KEYUP (wParam, lParam); break; 3865 case OS.WM_KEYUP: result = WM_KEYUP (wParam, lParam); break;
3808 } 3922 }
3809 if (result !is null) return result.value; 3923 if (result !is null) return result.value;
3810 return callWindowProc (hwnd, msg, wParam, lParam); 3924 return callWindowProc (hwnd, msg, wParam, lParam);
3811 } 3925 }
3812 3926
3813 LRESULT WM_ACTIVATE (int wParam, int lParam) { 3927 LRESULT WM_ACTIVATE (int /*long*/ wParam, int /*long*/ lParam) {
3814 return null; 3928 return null;
3815 } 3929 }
3816 3930
3817 LRESULT WM_CAPTURECHANGED (int wParam, int lParam) { 3931 LRESULT WM_CAPTURECHANGED (int /*long*/ wParam, int /*long*/ lParam) {
3818 return wmCaptureChanged (handle, wParam, lParam); 3932 return wmCaptureChanged (handle, wParam, lParam);
3819 } 3933 }
3820 3934
3821 LRESULT WM_CHAR (int wParam, int lParam) { 3935 LRESULT WM_CHANGEUISTATE (int /*long*/ wParam, int /*long*/ lParam) {
3936 if ((state & IGNORE_WM_CHANGEUISTATE) !is 0) return LRESULT.ZERO;
3937 return null;
3938 }
3939
3940 LRESULT WM_CHAR (int /*long*/ wParam, int /*long*/ lParam) {
3822 return wmChar (handle, wParam, lParam); 3941 return wmChar (handle, wParam, lParam);
3823 } 3942 }
3824 3943
3825 LRESULT WM_CLEAR (int wParam, int lParam) { 3944 LRESULT WM_CLEAR (int /*long*/ wParam, int /*long*/ lParam) {
3826 return null; 3945 return null;
3827 } 3946 }
3828 3947
3829 LRESULT WM_CLOSE (int wParam, int lParam) { 3948 LRESULT WM_CLOSE (int /*long*/ wParam, int /*long*/ lParam) {
3830 return null; 3949 return null;
3831 } 3950 }
3832 3951
3833 LRESULT WM_COMMAND (int wParam, int lParam) { 3952 LRESULT WM_COMMAND (int /*long*/ wParam, int /*long*/ lParam) {
3834 /* 3953 /*
3835 * When the WM_COMMAND message is sent from a 3954 * When the WM_COMMAND message is sent from a
3836 * menu, the HWND parameter in LPARAM is zero. 3955 * menu, the HWND parameter in LPARAM is zero.
3837 */ 3956 */
3838 if (lParam is 0) { 3957 if (lParam is 0) {
3839 Decorations shell = menuShell (); 3958 Decorations shell = menuShell ();
3840 if (shell.isEnabled ()) { 3959 if (shell.isEnabled ()) {
3841 int id = wParam & 0xFFFF; 3960 int id = OS.LOWORD (wParam);
3842 MenuItem item = display.getMenuItem (id); 3961 MenuItem item = display.getMenuItem (id);
3843 if (item !is null && item.isEnabled ()) { 3962 if (item !is null && item.isEnabled ()) {
3844 return item.wmCommandChild (wParam, lParam); 3963 return item.wmCommandChild (wParam, lParam);
3845 } 3964 }
3846 } 3965 }
3849 Control control = display.getControl (cast(HANDLE)lParam); 3968 Control control = display.getControl (cast(HANDLE)lParam);
3850 if (control is null) return null; 3969 if (control is null) return null;
3851 return control.wmCommandChild (wParam, lParam); 3970 return control.wmCommandChild (wParam, lParam);
3852 } 3971 }
3853 3972
3854 LRESULT WM_CONTEXTMENU (int wParam, int lParam) { 3973 LRESULT WM_CONTEXTMENU (int /*long*/ wParam, int /*long*/ lParam) {
3855 return wmContextMenu (handle, wParam, lParam); 3974 return wmContextMenu (handle, wParam, lParam);
3856 } 3975 }
3857 3976
3858 LRESULT WM_CTLCOLOR (int wParam, int lParam) { 3977 LRESULT WM_CTLCOLOR (int /*long*/ wParam, int /*long*/ lParam) {
3859 auto hPalette = display.hPalette; 3978 auto hPalette = display.hPalette;
3860 if (hPalette !is null) { 3979 if (hPalette !is null) {
3861 OS.SelectPalette ( cast(HPALETTE)wParam, hPalette, false); 3980 OS.SelectPalette ( cast(HPALETTE)wParam, hPalette, false);
3862 OS.RealizePalette (cast(HPALETTE)wParam); 3981 OS.RealizePalette (cast(HPALETTE)wParam);
3863 } 3982 }
3864 Control control = display.getControl (cast(HANDLE)lParam); 3983 Control control = display.getControl (cast(HANDLE)lParam);
3865 if (control is null) return null; 3984 if (control is null) return null;
3866 return control.wmColorChild (wParam, lParam); 3985 return control.wmColorChild (wParam, lParam);
3867 } 3986 }
3868 3987
3869 LRESULT WM_CUT (int wParam, int lParam) { 3988 LRESULT WM_CUT (int /*long*/ wParam, int /*long*/ lParam) {
3870 return null; 3989 return null;
3871 } 3990 }
3872 3991
3873 LRESULT WM_DESTROY (int wParam, int lParam) { 3992 LRESULT WM_DESTROY (int /*long*/ wParam, int /*long*/ lParam) {
3874 return null; 3993 return null;
3875 } 3994 }
3876 3995
3877 LRESULT WM_DRAWITEM (int wParam, int lParam) { 3996 LRESULT WM_DRAWITEM (int /*long*/ wParam, int /*long*/ lParam) {
3878 DRAWITEMSTRUCT* struct_ = cast(DRAWITEMSTRUCT*)lParam; 3997 DRAWITEMSTRUCT* struct_ = cast(DRAWITEMSTRUCT*)lParam;
3879 if (struct_.CtlType is OS.ODT_MENU) { 3998 if (struct_.CtlType is OS.ODT_MENU) {
3880 MenuItem item = display.getMenuItem (struct_.itemID); 3999 MenuItem item = display.getMenuItem (struct_.itemID);
3881 if (item is null) return null; 4000 if (item is null) return null;
3882 return item.wmDrawChild (wParam, lParam); 4001 return item.wmDrawChild (wParam, lParam);
3884 Control control = display.getControl (struct_.hwndItem); 4003 Control control = display.getControl (struct_.hwndItem);
3885 if (control is null) return null; 4004 if (control is null) return null;
3886 return control.wmDrawChild (wParam, lParam); 4005 return control.wmDrawChild (wParam, lParam);
3887 } 4006 }
3888 4007
3889 LRESULT WM_ENDSESSION (int wParam, int lParam) { 4008 LRESULT WM_ENDSESSION (int /*long*/ wParam, int /*long*/ lParam) {
3890 return null; 4009 return null;
3891 } 4010 }
3892 4011
3893 LRESULT WM_ENTERIDLE (int wParam, int lParam) { 4012 LRESULT WM_ENTERIDLE (int /*long*/ wParam, int /*long*/ lParam) {
3894 return null; 4013 return null;
3895 } 4014 }
3896 4015
3897 LRESULT WM_ERASEBKGND (int wParam, int lParam) { 4016 LRESULT WM_ERASEBKGND (int /*long*/ wParam, int /*long*/ lParam) {
3898 if ((state & DRAW_BACKGROUND) !is 0) { 4017 if ((state & DRAW_BACKGROUND) !is 0) {
3899 if (findImageControl () !is null) return LRESULT.ONE; 4018 if (findImageControl () !is null) return LRESULT.ONE;
3900 } 4019 }
3901 if ((state & THEME_BACKGROUND) !is 0) { 4020 if ((state & THEME_BACKGROUND) !is 0) {
3902 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 4021 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
3904 } 4023 }
3905 } 4024 }
3906 return null; 4025 return null;
3907 } 4026 }
3908 4027
3909 LRESULT WM_GETDLGCODE (int wParam, int lParam) { 4028 LRESULT WM_GETDLGCODE (int /*long*/ wParam, int /*long*/ lParam) {
3910 return null; 4029 return null;
3911 } 4030 }
3912 4031
3913 LRESULT WM_GETFONT (int wParam, int lParam) { 4032 LRESULT WM_GETFONT (int /*long*/ wParam, int /*long*/ lParam) {
3914 return null; 4033 return null;
3915 } 4034 }
3916 4035
3917 LRESULT WM_GETOBJECT (int wParam, int lParam) { 4036 LRESULT WM_GETOBJECT (int /*long*/ wParam, int /*long*/ lParam) {
3918 if (accessible !is null) { 4037 if (accessible !is null) {
3919 int result = accessible.internal_WM_GETOBJECT (wParam, lParam); 4038 int /*long*/ result = accessible.internal_WM_GETOBJECT (wParam, lParam);
3920 if (result !is 0) return new LRESULT (result); 4039 if (result !is 0) return new LRESULT (result);
3921 } 4040 }
3922 return null; 4041 return null;
3923 } 4042 }
3924 4043
3925 LRESULT WM_GETMINMAXINFO (int wParam, int lParam) { 4044 LRESULT WM_GETMINMAXINFO (int /*long*/ wParam, int /*long*/ lParam) {
3926 return null; 4045 return null;
3927 } 4046 }
3928 4047
3929 LRESULT WM_HOTKEY (int wParam, int lParam) { 4048 LRESULT WM_HOTKEY (int /*long*/ wParam, int /*long*/ lParam) {
3930 return null; 4049 return null;
3931 } 4050 }
3932 4051
3933 LRESULT WM_HELP (int wParam, int lParam) { 4052 LRESULT WM_HELP (int /*long*/ wParam, int /*long*/ lParam) {
3934 static if (OS.IsWinCE) return null; 4053 static if (OS.IsWinCE) return null;
3935 HELPINFO* lphi = cast(HELPINFO*)lParam; 4054 HELPINFO* lphi = cast(HELPINFO*)lParam;
3936 Decorations shell = menuShell (); 4055 Decorations shell = menuShell ();
3937 if (!shell.isEnabled ()) return null; 4056 if (!shell.isEnabled ()) return null;
3938 if (lphi.iContextType is OS.HELPINFO_MENUITEM) { 4057 if (lphi.iContextType is OS.HELPINFO_MENUITEM) {
3959 return LRESULT.ONE; 4078 return LRESULT.ONE;
3960 } 4079 }
3961 return null; 4080 return null;
3962 } 4081 }
3963 4082
3964 LRESULT WM_HSCROLL (int wParam, int lParam) { 4083 LRESULT WM_HSCROLL (int /*long*/ wParam, int /*long*/ lParam) {
3965 Control control = display.getControl (cast(HANDLE)lParam); 4084 Control control = display.getControl (cast(HANDLE)lParam);
3966 if (control is null) return null; 4085 if (control is null) return null;
3967 return control.wmScrollChild (wParam, lParam); 4086 return control.wmScrollChild (wParam, lParam);
3968 } 4087 }
3969 4088
3970 LRESULT WM_IME_CHAR (int wParam, int lParam) { 4089 LRESULT WM_IME_CHAR (int /*long*/ wParam, int /*long*/ lParam) {
3971 return wmIMEChar (handle, wParam, lParam); 4090 return wmIMEChar (handle, wParam, lParam);
3972 } 4091 }
3973 4092
3974 LRESULT WM_IME_COMPOSITION (int wParam, int lParam) { 4093 LRESULT WM_IME_COMPOSITION (int /*long*/ wParam, int /*long*/ lParam) {
3975 return null; 4094 return null;
3976 } 4095 }
3977 4096
3978 LRESULT WM_INITMENUPOPUP (int wParam, int lParam) { 4097 LRESULT WM_IME_COMPOSITION_START (int /*long*/ wParam, int /*long*/ lParam) {
4098 return null;
4099 }
4100
4101 LRESULT WM_IME_ENDCOMPOSITION (int /*long*/ wParam, int /*long*/ lParam) {
4102 return null;
4103 }
4104
4105 LRESULT WM_INITMENUPOPUP (int /*long*/ wParam, int /*long*/ lParam) {
3979 4106
3980 /* Ignore WM_INITMENUPOPUP for an accelerator */ 4107 /* Ignore WM_INITMENUPOPUP for an accelerator */
3981 if (display.accelKeyHit) return null; 4108 if (display.accelKeyHit) return null;
3982 4109
3983 /* 4110 /*
3985 * the menu is the system menu and we can ignore 4112 * the menu is the system menu and we can ignore
3986 * WPARAM. Otherwise, use WPARAM to find the menu. 4113 * WPARAM. Otherwise, use WPARAM to find the menu.
3987 */ 4114 */
3988 Shell shell = getShell (); 4115 Shell shell = getShell ();
3989 Menu oldMenu = shell.activeMenu, newMenu = null; 4116 Menu oldMenu = shell.activeMenu, newMenu = null;
3990 if ((lParam >> 16) is 0) { 4117 if (OS.HIWORD (lParam) is 0) {
3991 newMenu = menuShell ().findMenu (cast(HANDLE)wParam); 4118 newMenu = menuShell ().findMenu (cast(HANDLE)wParam);
3992 if (newMenu !is null) newMenu.update (); 4119 if (newMenu !is null) newMenu.update ();
3993 } 4120 }
3994 Menu menu = newMenu; 4121 Menu menu = newMenu;
3995 while (menu !is null && menu !is oldMenu) { 4122 while (menu !is null && menu !is oldMenu) {
4030 // widget could be disposed at this point 4157 // widget could be disposed at this point
4031 } 4158 }
4032 return null; 4159 return null;
4033 } 4160 }
4034 4161
4035 LRESULT WM_INPUTLANGCHANGE (int wParam, int lParam) { 4162 LRESULT WM_INPUTLANGCHANGE (int /*long*/ wParam, int /*long*/ lParam) {
4036 return null; 4163 return null;
4037 } 4164 }
4038 4165
4039 LRESULT WM_KEYDOWN (int wParam, int lParam) { 4166 LRESULT WM_KEYDOWN (int /*long*/ wParam, int /*long*/ lParam) {
4040 return wmKeyDown (handle, wParam, lParam); 4167 return wmKeyDown (handle, wParam, lParam);
4041 } 4168 }
4042 4169
4043 LRESULT WM_KEYUP (int wParam, int lParam) { 4170 LRESULT WM_KEYUP (int /*long*/ wParam, int /*long*/ lParam) {
4044 return wmKeyUp (handle, wParam, lParam); 4171 return wmKeyUp (handle, wParam, lParam);
4045 } 4172 }
4046 4173
4047 LRESULT WM_KILLFOCUS (int wParam, int lParam) { 4174 LRESULT WM_KILLFOCUS (int /*long*/ wParam, int /*long*/ lParam) {
4048 return wmKillFocus (handle, wParam, lParam); 4175 return wmKillFocus (handle, wParam, lParam);
4049 } 4176 }
4050 4177
4051 LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) { 4178 LRESULT WM_LBUTTONDBLCLK (int /*long*/ wParam, int /*long*/ lParam) {
4052 return wmLButtonDblClk (handle, wParam, lParam); 4179 return wmLButtonDblClk (handle, wParam, lParam);
4053 } 4180 }
4054 4181
4055 LRESULT WM_LBUTTONDOWN (int wParam, int lParam) { 4182 LRESULT WM_LBUTTONDOWN (int /*long*/ wParam, int /*long*/ lParam) {
4056 return wmLButtonDown (handle, wParam, lParam); 4183 return wmLButtonDown (handle, wParam, lParam);
4057 } 4184 }
4058 4185
4059 LRESULT WM_LBUTTONUP (int wParam, int lParam) { 4186 LRESULT WM_LBUTTONUP (int /*long*/ wParam, int /*long*/ lParam) {
4060 return wmLButtonUp (handle, wParam, lParam); 4187 return wmLButtonUp (handle, wParam, lParam);
4061 } 4188 }
4062 4189
4063 LRESULT WM_MBUTTONDBLCLK (int wParam, int lParam) { 4190 LRESULT WM_MBUTTONDBLCLK (int /*long*/ wParam, int /*long*/ lParam) {
4064 return wmMButtonDblClk (handle, wParam, lParam); 4191 return wmMButtonDblClk (handle, wParam, lParam);
4065 } 4192 }
4066 4193
4067 LRESULT WM_MBUTTONDOWN (int wParam, int lParam) { 4194 LRESULT WM_MBUTTONDOWN (int /*long*/ wParam, int /*long*/ lParam) {
4068 return wmMButtonDown (handle, wParam, lParam); 4195 return wmMButtonDown (handle, wParam, lParam);
4069 } 4196 }
4070 4197
4071 LRESULT WM_MBUTTONUP (int wParam, int lParam) { 4198 LRESULT WM_MBUTTONUP (int /*long*/ wParam, int /*long*/ lParam) {
4072 return wmMButtonUp (handle, wParam, lParam); 4199 return wmMButtonUp (handle, wParam, lParam);
4073 } 4200 }
4074 4201
4075 LRESULT WM_MEASUREITEM (int wParam, int lParam) { 4202 LRESULT WM_MEASUREITEM (int /*long*/ wParam, int /*long*/ lParam) {
4076 MEASUREITEMSTRUCT* struct_ = cast(MEASUREITEMSTRUCT*)lParam;; 4203 MEASUREITEMSTRUCT* struct_ = cast(MEASUREITEMSTRUCT*)lParam;;
4077 if (struct_.CtlType is OS.ODT_MENU) { 4204 if (struct_.CtlType is OS.ODT_MENU) {
4078 MenuItem item = display.getMenuItem (struct_.itemID); 4205 MenuItem item = display.getMenuItem (struct_.itemID);
4079 if (item is null) return null; 4206 if (item is null) return null;
4080 return item.wmMeasureChild (wParam, lParam); 4207 return item.wmMeasureChild (wParam, lParam);
4083 Control control = display.getControl (hwnd); 4210 Control control = display.getControl (hwnd);
4084 if (control is null) return null; 4211 if (control is null) return null;
4085 return control.wmMeasureChild (wParam, lParam); 4212 return control.wmMeasureChild (wParam, lParam);
4086 } 4213 }
4087 4214
4088 LRESULT WM_MENUCHAR (int wParam, int lParam) { 4215 LRESULT WM_MENUCHAR (int /*long*/ wParam, int /*long*/ lParam) {
4089 /* 4216 /*
4090 * Feature in Windows. When the user types Alt+<key> 4217 * Feature in Windows. When the user types Alt+<key>
4091 * and <key> does not match a mnemonic in the System 4218 * and <key> does not match a mnemonic in the System
4092 * menu or the menu bar, Windows beeps. This beep is 4219 * menu or the menu bar, Windows beeps. This beep is
4093 * unexpected and unwanted by applications that look 4220 * unexpected and unwanted by applications that look
4094 * for Alt+<key>. The fix is to detect the case and 4221 * for Alt+<key>. The fix is to detect the case and
4095 * stop Windows from beeping by closing the menu. 4222 * stop Windows from beeping by closing the menu.
4096 */ 4223 */
4097 int type = wParam >> 16; 4224 int type = OS.HIWORD (wParam);
4098 if (type is 0 || type is OS.MF_SYSMENU) { 4225 if (type is 0 || type is OS.MF_SYSMENU) {
4099 display.mnemonicKeyHit = false; 4226 display.mnemonicKeyHit = false;
4100 return new LRESULT (OS.MNC_CLOSE << 16); 4227 return new LRESULT (OS.MAKELRESULT (0, OS.MNC_CLOSE));
4101 } 4228 }
4102 return null; 4229 return null;
4103 } 4230 }
4104 4231
4105 LRESULT WM_MENUSELECT (int wParam, int lParam) { 4232 LRESULT WM_MENUSELECT (int /*long*/ wParam, int /*long*/ lParam) {
4106 int code = wParam >> 16; 4233 int code = OS.HIWORD (wParam);
4107 Shell shell = getShell (); 4234 Shell shell = getShell ();
4108 if (code is -1 && lParam is 0) { 4235 if (code is 0xFFFF && lParam is 0) {
4109 Menu menu = shell.activeMenu; 4236 Menu menu = shell.activeMenu;
4110 while (menu !is null) { 4237 while (menu !is null) {
4111 /* 4238 /*
4112 * When the user cancels any menu that is not the 4239 * When the user cancels any menu that is not the
4113 * menu bar, assume a mnemonic key was pressed to open 4240 * menu bar, assume a mnemonic key was pressed to open
4140 if ((code & OS.MF_SYSMENU) !is 0) return null; 4267 if ((code & OS.MF_SYSMENU) !is 0) return null;
4141 if ((code & OS.MF_HILITE) !is 0) { 4268 if ((code & OS.MF_HILITE) !is 0) {
4142 MenuItem item = null; 4269 MenuItem item = null;
4143 Decorations menuShell = menuShell (); 4270 Decorations menuShell = menuShell ();
4144 if ((code & OS.MF_POPUP) !is 0) { 4271 if ((code & OS.MF_POPUP) !is 0) {
4145 int index = wParam & 0xFFFF; 4272 int index = OS.LOWORD (wParam);
4146 MENUITEMINFO info; 4273 MENUITEMINFO info;
4147 info.cbSize = MENUITEMINFO.sizeof; 4274 info.cbSize = MENUITEMINFO.sizeof;
4148 info.fMask = OS.MIIM_SUBMENU; 4275 info.fMask = OS.MIIM_SUBMENU;
4149 if (OS.GetMenuItemInfo (cast(HANDLE)lParam, index, true, &info)) { 4276 if (OS.GetMenuItemInfo (cast(HANDLE)lParam, index, true, &info)) {
4150 Menu newMenu = menuShell.findMenu (info.hSubMenu); 4277 Menu newMenu = menuShell.findMenu (info.hSubMenu);
4151 if (newMenu !is null) item = newMenu.cascade; 4278 if (newMenu !is null) item = newMenu.cascade;
4152 } 4279 }
4153 } else { 4280 } else {
4154 Menu newMenu = menuShell.findMenu (cast(HANDLE)lParam); 4281 Menu newMenu = menuShell.findMenu (cast(HANDLE)lParam);
4155 if (newMenu !is null) { 4282 if (newMenu !is null) {
4156 int id = wParam & 0xFFFF; 4283 int id = OS.LOWORD (wParam);
4157 item = display.getMenuItem (id); 4284 item = display.getMenuItem (id);
4158 } 4285 }
4159 Menu oldMenu = shell.activeMenu; 4286 Menu oldMenu = shell.activeMenu;
4160 if (oldMenu !is null) { 4287 if (oldMenu !is null) {
4161 Menu ancestor = oldMenu; 4288 Menu ancestor = oldMenu;
4173 * because there is no longer a link to follow. 4300 * because there is no longer a link to follow.
4174 */ 4301 */
4175 ancestor.sendEvent (DWT.Hide); 4302 ancestor.sendEvent (DWT.Hide);
4176 if (ancestor.isDisposed ()) break; 4303 if (ancestor.isDisposed ()) break;
4177 ancestor = ancestor.getParentMenu (); 4304 ancestor = ancestor.getParentMenu ();
4305 if (ancestor is null) break;
4178 } 4306 }
4179 /* 4307 /*
4180 * The shell and/or the item could be disposed when 4308 * The shell and/or the item could be disposed when
4181 * processing hide events from above. If this happens, 4309 * processing hide events from above. If this happens,
4182 * ensure that the shell is not accessed and that no 4310 * ensure that the shell is not accessed and that no
4195 if (item !is null) item.sendEvent (DWT.Arm); 4323 if (item !is null) item.sendEvent (DWT.Arm);
4196 } 4324 }
4197 return null; 4325 return null;
4198 } 4326 }
4199 4327
4200 LRESULT WM_MOUSEACTIVATE (int wParam, int lParam) { 4328 LRESULT WM_MOUSEACTIVATE (int /*long*/ wParam, int /*long*/ lParam) {
4201 return null; 4329 return null;
4202 } 4330 }
4203 4331
4204 LRESULT WM_MOUSEHOVER (int wParam, int lParam) { 4332 LRESULT WM_MOUSEHOVER (int /*long*/ wParam, int /*long*/ lParam) {
4205 return wmMouseHover (handle, wParam, lParam); 4333 return wmMouseHover (handle, wParam, lParam);
4206 } 4334 }
4207 4335
4208 LRESULT WM_MOUSELEAVE (int wParam, int lParam) { 4336 LRESULT WM_MOUSELEAVE (int /*long*/ wParam, int /*long*/ lParam) {
4209 if (OS.COMCTL32_MAJOR >= 6) getShell ().fixToolTip (); 4337 if (OS.COMCTL32_MAJOR >= 6) getShell ().fixToolTip ();
4210 return wmMouseLeave (handle, wParam, lParam); 4338 return wmMouseLeave (handle, wParam, lParam);
4211 } 4339 }
4212 4340
4213 LRESULT WM_MOUSEMOVE (int wParam, int lParam) { 4341 LRESULT WM_MOUSEMOVE (int /*long*/ wParam, int /*long*/ lParam) {
4214 return wmMouseMove (handle, wParam, lParam); 4342 return wmMouseMove (handle, wParam, lParam);
4215 } 4343 }
4216 4344
4217 LRESULT WM_MOUSEWHEEL (int wParam, int lParam) { 4345 LRESULT WM_MOUSEWHEEL (int /*long*/ wParam, int /*long*/ lParam) {
4218 return wmMouseWheel (handle, wParam, lParam); 4346 return wmMouseWheel (handle, wParam, lParam);
4219 } 4347 }
4220 4348
4221 LRESULT WM_MOVE (int wParam, int lParam) { 4349 LRESULT WM_MOVE (int /*long*/ wParam, int /*long*/ lParam) {
4350 state |= MOVE_OCCURRED;
4222 if (findImageControl () !is null) { 4351 if (findImageControl () !is null) {
4223 if (this !is getShell ()) redrawChildren (); 4352 if (this !is getShell ()) redrawChildren ();
4224 } else { 4353 } else {
4225 if ((state & THEME_BACKGROUND) !is 0) { 4354 if ((state & THEME_BACKGROUND) !is 0) {
4226 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 4355 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
4228 if (findThemeControl () !is null) redrawChildren (); 4357 if (findThemeControl () !is null) redrawChildren ();
4229 } 4358 }
4230 } 4359 }
4231 } 4360 }
4232 } 4361 }
4233 sendEvent (DWT.Move); 4362 if ((state & MOVE_DEFERRED) is 0) sendEvent (DWT.Move);
4234 // widget could be disposed at this point 4363 // widget could be disposed at this point
4235 return null; 4364 return null;
4236 } 4365 }
4237 4366
4238 LRESULT WM_NCACTIVATE (int wParam, int lParam) { 4367 LRESULT WM_NCACTIVATE (int /*long*/ wParam, int /*long*/ lParam) {
4239 return null; 4368 return null;
4240 } 4369 }
4241 4370
4242 LRESULT WM_NCCALCSIZE (int wParam, int lParam) { 4371 LRESULT WM_NCCALCSIZE (int /*long*/ wParam, int /*long*/ lParam) {
4243 return null; 4372 return null;
4244 } 4373 }
4245 4374
4246 LRESULT WM_NCHITTEST (int wParam, int lParam) { 4375 LRESULT WM_NCHITTEST (int /*long*/ wParam, int /*long*/ lParam) {
4247 if (!OS.IsWindowEnabled (handle)) return null; 4376 if (!OS.IsWindowEnabled (handle)) return null;
4248 if (!isActive ()) return new LRESULT (OS.HTTRANSPARENT); 4377 if (!isActive ()) return new LRESULT (OS.HTTRANSPARENT);
4249 return null; 4378 return null;
4250 } 4379 }
4251 4380
4252 LRESULT WM_NCLBUTTONDOWN (int wParam, int lParam) { 4381 LRESULT WM_NCLBUTTONDOWN (int /*long*/ wParam, int /*long*/ lParam) {
4253 return null; 4382 return null;
4254 } 4383 }
4255 4384
4256 LRESULT WM_NCPAINT (int wParam, int lParam) { 4385 LRESULT WM_NCPAINT (int /*long*/ wParam, int /*long*/ lParam) {
4257 return null; 4386 return wmNCPaint (handle, wParam, lParam);
4258 } 4387 }
4259 4388
4260 LRESULT WM_NOTIFY (int wParam, int lParam) { 4389 LRESULT WM_NOTIFY (int /*long*/ wParam, int /*long*/ lParam) {
4261 NMHDR* hdr = cast(NMHDR*)lParam; 4390 NMHDR* hdr = cast(NMHDR*)lParam;
4262 return wmNotify (hdr, wParam, lParam); 4391 return wmNotify (hdr, wParam, lParam);
4263 } 4392 }
4264 4393
4265 LRESULT WM_PAINT (int wParam, int lParam) { 4394 LRESULT WM_PAINT (int /*long*/ wParam, int /*long*/ lParam) {
4266 return super.wmPaint (handle, wParam, lParam); 4395 return wmPaint (handle, wParam, lParam);
4267 } 4396 }
4268 4397
4269 LRESULT WM_PALETTECHANGED (int wParam, int lParam) { 4398 LRESULT WM_PALETTECHANGED (int /*long*/ wParam, int /*long*/ lParam) {
4270 return null; 4399 return null;
4271 } 4400 }
4272 4401
4273 LRESULT WM_PARENTNOTIFY (int wParam, int lParam) { 4402 LRESULT WM_PARENTNOTIFY (int /*long*/ wParam, int /*long*/ lParam) {
4274 return null; 4403 return null;
4275 } 4404 }
4276 4405
4277 LRESULT WM_PASTE (int wParam, int lParam) { 4406 LRESULT WM_PASTE (int /*long*/ wParam, int /*long*/ lParam) {
4278 return null; 4407 return null;
4279 } 4408 }
4280 4409
4281 LRESULT WM_PRINT (int wParam, int lParam) { 4410 LRESULT WM_PRINT (int /*long*/ wParam, int /*long*/ lParam) {
4282 return wmPrint (handle, wParam, lParam); 4411 return wmPrint (handle, wParam, lParam);
4283 } 4412 }
4284 4413
4285 LRESULT WM_PRINTCLIENT (int wParam, int lParam) { 4414 LRESULT WM_PRINTCLIENT (int /*long*/ wParam, int /*long*/ lParam) {
4286 return null; 4415 return null;
4287 } 4416 }
4288 4417
4289 LRESULT WM_QUERYENDSESSION (int wParam, int lParam) { 4418 LRESULT WM_QUERYENDSESSION (int /*long*/ wParam, int /*long*/ lParam) {
4290 return null; 4419 return null;
4291 } 4420 }
4292 4421
4293 LRESULT WM_QUERYNEWPALETTE (int wParam, int lParam) { 4422 LRESULT WM_QUERYNEWPALETTE (int /*long*/ wParam, int /*long*/ lParam) {
4294 return null; 4423 return null;
4295 } 4424 }
4296 4425
4297 LRESULT WM_QUERYOPEN (int wParam, int lParam) { 4426 LRESULT WM_QUERYOPEN (int /*long*/ wParam, int /*long*/ lParam) {
4298 return null; 4427 return null;
4299 } 4428 }
4300 4429
4301 LRESULT WM_RBUTTONDBLCLK (int wParam, int lParam) { 4430 LRESULT WM_RBUTTONDBLCLK (int /*long*/ wParam, int /*long*/ lParam) {
4302 return wmRButtonDblClk (handle, wParam, lParam); 4431 return wmRButtonDblClk (handle, wParam, lParam);
4303 } 4432 }
4304 4433
4305 LRESULT WM_RBUTTONDOWN (int wParam, int lParam) { 4434 LRESULT WM_RBUTTONDOWN (int /*long*/ wParam, int /*long*/ lParam) {
4306 return wmRButtonDown (handle, wParam, lParam); 4435 return wmRButtonDown (handle, wParam, lParam);
4307 } 4436 }
4308 4437
4309 LRESULT WM_RBUTTONUP (int wParam, int lParam) { 4438 LRESULT WM_RBUTTONUP (int /*long*/ wParam, int /*long*/ lParam) {
4310 return wmRButtonUp (handle, wParam, lParam); 4439 return wmRButtonUp (handle, wParam, lParam);
4311 } 4440 }
4312 4441
4313 LRESULT WM_SETCURSOR (int wParam, int lParam) { 4442 LRESULT WM_SETCURSOR (int /*long*/ wParam, int /*long*/ lParam) {
4314 int hitTest = cast(short) (lParam & 0xFFFF); 4443 int hitTest = cast(short) OS.LOWORD (lParam);
4315 if (hitTest is OS.HTCLIENT) { 4444 if (hitTest is OS.HTCLIENT) {
4316 Control control = display.getControl (cast(HANDLE)wParam); 4445 Control control = display.getControl (cast(HANDLE)wParam);
4317 if (control is null) return null; 4446 if (control is null) return null;
4318 Cursor cursor = control.findCursor (); 4447 Cursor cursor = control.findCursor ();
4319 if (cursor !is null) { 4448 if (cursor !is null) {
4322 } 4451 }
4323 } 4452 }
4324 return null; 4453 return null;
4325 } 4454 }
4326 4455
4327 LRESULT WM_SETFOCUS (int wParam, int lParam) { 4456 LRESULT WM_SETFOCUS (int /*long*/ wParam, int /*long*/ lParam) {
4328 return wmSetFocus (handle, wParam, lParam); 4457 return wmSetFocus (handle, wParam, lParam);
4329 } 4458 }
4330 4459
4331 LRESULT WM_SETTINGCHANGE (int wParam, int lParam) { 4460 LRESULT WM_SETTINGCHANGE (int /*long*/ wParam, int /*long*/ lParam) {
4332 return null; 4461 return null;
4333 } 4462 }
4334 4463
4335 LRESULT WM_SETFONT (int wParam, int lParam) { 4464 LRESULT WM_SETFONT (int /*long*/ wParam, int /*long*/ lParam) {
4336 return null; 4465 return null;
4337 } 4466 }
4338 4467
4339 LRESULT WM_SETREDRAW (int wParam, int lParam) { 4468 LRESULT WM_SETREDRAW (int /*long*/ wParam, int /*long*/ lParam) {
4340 return null; 4469 return null;
4341 } 4470 }
4342 4471
4343 LRESULT WM_SHOWWINDOW (int wParam, int lParam) { 4472 LRESULT WM_SHOWWINDOW (int /*long*/ wParam, int /*long*/ lParam) {
4344 return null; 4473 return null;
4345 } 4474 }
4346 4475
4347 LRESULT WM_SIZE (int wParam, int lParam) { 4476 LRESULT WM_SIZE (int /*long*/ wParam, int /*long*/ lParam) {
4348 sendEvent (DWT.Resize); 4477 state |= RESIZE_OCCURRED;
4478 if ((state & RESIZE_DEFERRED) is 0) sendEvent (DWT.Resize);
4349 // widget could be disposed at this point 4479 // widget could be disposed at this point
4350 return null; 4480 return null;
4351 } 4481 }
4352 4482
4353 LRESULT WM_SYSCHAR (int wParam, int lParam) { 4483 LRESULT WM_SYSCHAR (int /*long*/ wParam, int /*long*/ lParam) {
4354 return wmSysChar (handle, wParam, lParam); 4484 return wmSysChar (handle, wParam, lParam);
4355 } 4485 }
4356 4486
4357 LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) { 4487 LRESULT WM_SYSCOLORCHANGE (int /*long*/ wParam, int /*long*/ lParam) {
4358 return null; 4488 return null;
4359 } 4489 }
4360 4490
4361 LRESULT WM_SYSCOMMAND (int wParam, int lParam) { 4491 LRESULT WM_SYSCOMMAND (int /*long*/ wParam, int /*long*/ lParam) {
4362 /* 4492 /*
4363 * Check to see if the command is a system command or 4493 * Check to see if the command is a system command or
4364 * a user menu item that was added to the System menu. 4494 * a user menu item that was added to the System menu.
4365 * When a user item is added to the System menu, 4495 * When a user item is added to the System menu,
4366 * WM_SYSCOMMAND must always return zero. 4496 * WM_SYSCOMMAND must always return zero.
4497 *
4498 * NOTE: This is undocumented.
4367 */ 4499 */
4368 if ((wParam & 0xF000) is 0) { 4500 if ((wParam & 0xF000) is 0) {
4369 Decorations shell = menuShell (); 4501 Decorations shell = menuShell ();
4370 if (shell.isEnabled ()) { 4502 if (shell.isEnabled ()) {
4371 MenuItem item = display.getMenuItem (wParam & 0xFFFF); 4503 MenuItem item = display.getMenuItem (OS.LOWORD (wParam));
4372 if (item !is null) item.wmCommandChild (wParam, lParam); 4504 if (item !is null) item.wmCommandChild (wParam, lParam);
4373 } 4505 }
4374 return LRESULT.ZERO; 4506 return LRESULT.ZERO;
4375 } 4507 }
4376 4508
4470 default: 4602 default:
4471 } 4603 }
4472 return null; 4604 return null;
4473 } 4605 }
4474 4606
4475 LRESULT WM_SYSKEYDOWN (int wParam, int lParam) { 4607 LRESULT WM_SYSKEYDOWN (int /*long*/ wParam, int /*long*/ lParam) {
4476 return wmSysKeyDown (handle, wParam, lParam); 4608 return wmSysKeyDown (handle, wParam, lParam);
4477 } 4609 }
4478 4610
4479 LRESULT WM_SYSKEYUP (int wParam, int lParam) { 4611 LRESULT WM_SYSKEYUP (int /*long*/ wParam, int /*long*/ lParam) {
4480 return wmSysKeyUp (handle, wParam, lParam); 4612 return wmSysKeyUp (handle, wParam, lParam);
4481 } 4613 }
4482 4614
4483 LRESULT WM_TIMER (int wParam, int lParam) { 4615 LRESULT WM_TIMER (int /*long*/ wParam, int /*long*/ lParam) {
4484 return null; 4616 return null;
4485 } 4617 }
4486 4618
4487 LRESULT WM_UNDO (int wParam, int lParam) { 4619 LRESULT WM_UNDO (int /*long*/ wParam, int /*long*/ lParam) {
4488 return null; 4620 return null;
4489 } 4621 }
4490 4622
4491 LRESULT WM_UPDATEUISTATE (int wParam, int lParam) { 4623 LRESULT WM_UPDATEUISTATE (int /*long*/ wParam, int /*long*/ lParam) {
4492 return null; 4624 return null;
4493 } 4625 }
4494 4626
4495 LRESULT WM_VSCROLL (int wParam, int lParam) { 4627 LRESULT WM_VSCROLL (int /*long*/ wParam, int /*long*/ lParam) {
4496 Control control = display.getControl (cast(HANDLE)lParam); 4628 Control control = display.getControl (cast(HANDLE)lParam);
4497 if (control is null) return null; 4629 if (control is null) return null;
4498 return control.wmScrollChild (wParam, lParam); 4630 return control.wmScrollChild (wParam, lParam);
4499 } 4631 }
4500 4632
4501 LRESULT WM_WINDOWPOSCHANGED (int wParam, int lParam) { 4633 LRESULT WM_WINDOWPOSCHANGED (int /*long*/ wParam, int /*long*/ lParam) {
4502 return null; 4634 try {
4503 } 4635 display.resizeCount++;
4504 4636 int /*long*/ code = callWindowProc (handle, OS.WM_WINDOWPOSCHANGED, wParam, lParam);
4505 LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) { 4637 return code is 0 ? LRESULT.ZERO : new LRESULT (code);
4638 } finally {
4639 --display.resizeCount;
4640 }
4641 }
4642
4643 LRESULT WM_WINDOWPOSCHANGING (int /*long*/ wParam, int /*long*/ lParam) {
4506 /* 4644 /*
4507 * Bug in Windows. When WM_SETREDRAW is used to turn off drawing 4645 * Bug in Windows. When WM_SETREDRAW is used to turn off drawing
4508 * for a control and the control is moved or resized, Windows does 4646 * for a control and the control is moved or resized, Windows does
4509 * not redraw the area where the control once was in the parent. 4647 * not redraw the area where the control once was in the parent.
4510 * The fix is to detect this case and redraw the area. 4648 * The fix is to detect this case and redraw the area.
4514 if (shell !is this) { 4652 if (shell !is this) {
4515 WINDOWPOS* lpwp = cast(WINDOWPOS*)lParam; 4653 WINDOWPOS* lpwp = cast(WINDOWPOS*)lParam;
4516 if ((lpwp.flags & OS.SWP_NOMOVE) is 0 || (lpwp.flags & OS.SWP_NOSIZE) is 0) { 4654 if ((lpwp.flags & OS.SWP_NOMOVE) is 0 || (lpwp.flags & OS.SWP_NOSIZE) is 0) {
4517 RECT rect; 4655 RECT rect;
4518 OS.GetWindowRect (topHandle (), &rect); 4656 OS.GetWindowRect (topHandle (), &rect);
4519 auto hwndParent = parent is null ? null : parent.handle; 4657 int width = rect.right - rect.left;
4520 OS.MapWindowPoints (null, hwndParent, cast(POINT*)&rect, 2); 4658 int height = rect.bottom - rect.top;
4521 OS.InvalidateRect (hwndParent, &rect, true); 4659 if (width !is 0 && height !is 0) {
4660 auto hwndParent = parent is null ? null : parent.handle;
4661 OS.MapWindowPoints (null, hwndParent, cast(POINT*)&rect, 2);
4662 static if (OS.IsWinCE) {
4663 OS.InvalidateRect (hwndParent, &rect, true);
4664 } else {
4665 auto rgn1 = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom);
4666 auto rgn2 = OS.CreateRectRgn (lpwp.x, lpwp.y, lpwp.x + lpwp.cx, lpwp.y + lpwp.cy);
4667 OS.CombineRgn (rgn1, rgn1, rgn2, OS.RGN_DIFF);
4668 int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN;
4669 OS.RedrawWindow (hwndParent, null, rgn1, flags);
4670 OS.DeleteObject (rgn1);
4671 OS.DeleteObject (rgn2);
4672 }
4673 }
4522 } 4674 }
4523 } 4675 }
4524 } 4676 }
4525 return null; 4677 return null;
4526 } 4678 }
4527 4679
4528 LRESULT WM_XBUTTONDBLCLK (int wParam, int lParam) { 4680 LRESULT WM_XBUTTONDBLCLK (int /*long*/ wParam, int /*long*/ lParam) {
4529 return wmXButtonDblClk (handle, wParam, lParam); 4681 return wmXButtonDblClk (handle, wParam, lParam);
4530 } 4682 }
4531 4683
4532 LRESULT WM_XBUTTONDOWN (int wParam, int lParam) { 4684 LRESULT WM_XBUTTONDOWN (int /*long*/ wParam, int /*long*/ lParam) {
4533 return wmXButtonDown (handle, wParam, lParam); 4685 return wmXButtonDown (handle, wParam, lParam);
4534 } 4686 }
4535 4687
4536 LRESULT WM_XBUTTONUP (int wParam, int lParam) { 4688 LRESULT WM_XBUTTONUP (int /*long*/ wParam, int /*long*/ lParam) {
4537 return wmXButtonUp (handle, wParam, lParam); 4689 return wmXButtonUp (handle, wParam, lParam);
4538 } 4690 }
4539 4691
4540 LRESULT wmColorChild (int wParam, int lParam) { 4692 LRESULT wmColorChild (int /*long*/ wParam, int /*long*/ lParam) {
4541 Control control = findBackgroundControl (); 4693 Control control = findBackgroundControl ();
4542 if (control is null) { 4694 if (control is null) {
4543 if ((state & THEME_BACKGROUND) !is 0) { 4695 if ((state & THEME_BACKGROUND) !is 0) {
4544 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) { 4696 if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
4545 control = findThemeControl (); 4697 control = findThemeControl ();
4589 OS.SelectObject (cast(HANDLE)wParam, hOldBrush); 4741 OS.SelectObject (cast(HANDLE)wParam, hOldBrush);
4590 } 4742 }
4591 return new LRESULT ( cast(int) hBrush); 4743 return new LRESULT ( cast(int) hBrush);
4592 } 4744 }
4593 4745
4594 LRESULT wmCommandChild (int wParam, int lParam) { 4746 LRESULT wmCommandChild (int /*long*/ wParam, int /*long*/ lParam) {
4595 return null; 4747 return null;
4596 } 4748 }
4597 4749
4598 LRESULT wmDrawChild (int wParam, int lParam) { 4750 LRESULT wmDrawChild (int /*long*/ wParam, int /*long*/ lParam) {
4599 return null; 4751 return null;
4600 } 4752 }
4601 4753
4602 LRESULT wmMeasureChild (int wParam, int lParam) { 4754 LRESULT wmMeasureChild (int /*long*/ wParam, int /*long*/ lParam) {
4603 return null; 4755 return null;
4604 } 4756 }
4605 4757
4606 LRESULT wmNotify (NMHDR* hdr, int wParam, int lParam) { 4758 LRESULT wmNotify (NMHDR* hdr, int wParam, int lParam) {
4607 Control control = display.getControl (hdr.hwndFrom); 4759 Control control = display.getControl (hdr.hwndFrom);
4611 4763
4612 LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) { 4764 LRESULT wmNotifyChild (NMHDR* hdr, int wParam, int lParam) {
4613 return null; 4765 return null;
4614 } 4766 }
4615 4767
4616 LRESULT wmScrollChild (int wParam, int lParam) { 4768 LRESULT wmScrollChild (int /*long*/ wParam, int /*long*/ lParam) {
4617 return null; 4769 return null;
4618 } 4770 }
4619 4771
4620 } 4772 }