EnableWindow
Ulrich Czekalla
ulrich.czekalla at utoronto.ca
Fri May 28 16:33:26 CDT 2004
ChangeLog:
Ulrich Czekalla <ulrich at codeweavers.com>
EnableWindow should not remove the focus of child windows
-------------- next part --------------
Index: dlls/user/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/Makefile.in,v
retrieving revision 1.9
diff -u -r1.9 Makefile.in
--- dlls/user/tests/Makefile.in 23 Apr 2004 21:32:17 -0000 1.9
+++ dlls/user/tests/Makefile.in 28 May 2004 21:25:27 -0000
@@ -9,6 +9,7 @@
class.c \
dde.c \
dialog.c \
+ enable.c \
generated.c \
input.c \
listbox.c \
Index: windows/win.c
===================================================================
RCS file: /home/wine/wine/windows/win.c,v
retrieving revision 1.242
diff -u -r1.242 win.c
--- windows/win.c 28 May 2004 19:35:37 -0000 1.242
+++ windows/win.c 28 May 2004 21:25:28 -0000
@@ -1759,7 +1759,7 @@
WIN_SetStyle( hwnd, style | WS_DISABLED );
focus_wnd = GetFocus();
- if (hwnd == focus_wnd || IsChild(hwnd, focus_wnd))
+ if (hwnd == focus_wnd)
SetFocus( 0 ); /* A disabled window can't have the focus */
capture_wnd = GetCapture();
--- /dev/null 2004-02-23 16:02:56.000000000 -0500
+++ dlls/user/tests/enable.c 2004-05-28 17:23:42.421071880 -0400
@@ -0,0 +1,125 @@
+/*
+ * Unit tests for EnableWindow
+ *
+ * Copyright 2004 Ulrich Czekalla
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <assert.h>
+#include <stdarg.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+
+#include "wine/test.h"
+
+#define TESTCLASS "TestClass"
+#define TESTCHILDCLASS "TestChildClass"
+
+UINT msgindex = 0;
+
+static LRESULT WINAPI WndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT ret = FALSE;
+
+ switch (msg)
+ {
+ case WM_CANCELMODE:
+ ok (msgindex++ == 1, "WM_CANCELMODE received out of sequence\n");
+ break;
+
+ case WM_ENABLE:
+ ok (msgindex++ == 2, "WM_ENABLE received out of sequence\n");
+ break;
+
+ default:
+ ret = DefWindowProcA(hwnd, msg, wParam, lParam);
+ break;
+ }
+
+ return ret;
+}
+
+
+static LRESULT WINAPI ChildWndProcA(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT ret = FALSE;
+
+ switch (msg)
+ {
+ case WM_SETFOCUS:
+ ok (msgindex++ == 0, "WM_SETFOCUS received out of sequence\n");
+ break;
+
+ case WM_KILLFOCUS:
+ ok (FALSE, "WM_KILLFOCUS received out of sequence\n");
+ break;
+
+ default:
+ ret = DefWindowProcA(hwnd, msg, wParam, lParam);
+ break;
+ }
+
+ return ret;
+}
+
+
+static BOOL RegisterWindowClass(void)
+{
+ WNDCLASSA cls;
+
+ cls.style = 0;
+ cls.lpfnWndProc = WndProcA;
+ cls.cbClsExtra = 0;
+ cls.cbWndExtra = 0;
+ cls.hInstance = GetModuleHandleA(0);
+ cls.hIcon = 0;
+ cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
+ cls.hbrBackground = GetStockObject(WHITE_BRUSH);
+ cls.lpszMenuName = NULL;
+ cls.lpszClassName = TESTCLASS;
+ RegisterClassA(&cls);
+
+ cls.lpfnWndProc = ChildWndProcA;
+ cls.hbrBackground = GetStockObject(GRAY_BRUSH);
+ cls.lpszClassName = TESTCHILDCLASS;
+ RegisterClassA(&cls);
+
+ return TRUE;
+}
+
+START_TEST(enable)
+{
+ HWND hWndMain;
+ HWND hWndChild;
+
+ RegisterWindowClass();
+
+ hWndMain = CreateWindowExA(0, TESTCLASS, "", WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU,
+ 0, 0, 100, 100, NULL, NULL, NULL, NULL);
+ ok (hWndMain != 0, "Failed to create main test window\n");
+
+ hWndChild = CreateWindowExA(0, TESTCHILDCLASS, "", WS_VISIBLE | WS_CHILD,
+ 20, 20, 60, 60, hWndMain, NULL, NULL, NULL);
+ ok (hWndChild != 0, "Failed to create child test window\n");
+
+ SetFocus(hWndChild);
+ EnableWindow(hWndMain, FALSE);
+
+ ok (GetFocus() == hWndChild, "Child test window should have focus\n");
+}
More information about the wine-patches
mailing list