[PATCH] user32: edit control should respond to ctrl + z

Lei Zhang thestig at google.com
Thu Aug 30 16:34:21 CDT 2007


Hi,

This lets users hit ctrl + z in edit dialogs. A test case is included.
This should fixed bug 9525.
-------------- next part --------------
From 40b25e1a49dc9c9ac8b7f0cb0aa8353658fdb412 Mon Sep 17 00:00:00 2001
From: Lei Zhang <thestig at google.com>
Date: Thu, 30 Aug 2007 14:29:30 -0700
Subject: [PATCH] user32: edit control should respond to ctrl + z
---
 dlls/user32/edit.c       |    4 ++++
 dlls/user32/tests/edit.c |   38 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c
index 77ecf32..b11bf10 100644
--- a/dlls/user32/edit.c
+++ b/dlls/user32/edit.c
@@ -4036,6 +4036,10 @@ static void EDIT_WM_Char(EDITSTATE *es, 
 	        if (!((es->style & ES_READONLY) || (es->style & ES_PASSWORD)))
 		    SendMessageW(es->hwndSelf, WM_CUT, 0, 0);
 		break;
+	case 0x1A: /* ^Z */
+	        if (!(es->style & ES_READONLY))
+		    SendMessageW(es->hwndSelf, WM_UNDO, 0, 0);
+		break;
 
 	default:
 		/*If Edit control style is ES_NUMBER allow users to key in only numeric values*/
diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index 534bd9b..4deac99 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -1023,7 +1023,7 @@ static void test_espassword(void)
 
     /* get text */
     r = SendMessage(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
-    ok(r == strlen(password), "Expected: %s, got len %d\n", password, r);
+    ok(r == strlen(password), "Expected: %d, got len %d\n", strlen(password), r);
     ok(strcmp(buffer, password) == 0, "expected %s, got %s\n", password, buffer);
 
     r = OpenClipboard(hwEdit);
@@ -1047,6 +1047,41 @@ static void test_espassword(void)
     DestroyWindow (hwEdit);
 }
 
+static void test_undo(void)
+{
+    HWND hwEdit;
+    LONG r;
+    char buffer[1024];
+    const char* text = "undo this";
+
+    hwEdit = create_editcontrol(0, 0);
+    r = get_edit_style(hwEdit);
+    ok(r == 0, "Wrong style expected 0x%x got: 0x%x\n", 0, r);
+    /* set text */
+    r = SendMessage(hwEdit , WM_SETTEXT, 0, (LPARAM) text);
+    ok(r == TRUE, "Expected: %d, got: %d\n", TRUE, r);
+
+    /* select all, cut (ctrl-x), undo (ctrl-z) */
+    SendMessage(hwEdit, EM_SETSEL, 0, -1);
+    SendMessage(hwEdit, WM_CHAR, 24, 0);
+    SendMessage(hwEdit, WM_CHAR, 26, 0);
+
+    /* get text */
+    r = SendMessage(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
+    ok(r == strlen(text), "Expected: %d, got len %d\n", strlen(text), r);
+    ok(strcmp(buffer, text) == 0, "expected %s, got %s\n", text, buffer);
+
+    /* undo again (ctrl-z) */
+    SendMessage(hwEdit, WM_CHAR, 26, 0);
+
+    /* get text */
+    r = SendMessage(hwEdit, WM_GETTEXT, 1024, (LPARAM) buffer);
+    ok(r == 0, "Expected: %d, got len %d\n", 0, r);
+    ok(strcmp(buffer, "") == 0, "expected %s, got %s\n", "", buffer);
+
+    DestroyWindow (hwEdit);
+}
+
 static BOOL RegisterWindowClasses (void)
 {
     WNDCLASSA test2;
@@ -1113,6 +1148,7 @@ START_TEST(edit)
     test_margins_font_change();
     test_text_position();
     test_espassword();
+    test_undo();
 
     UnregisterWindowClasses();
 }
-- 
1.4.1


More information about the wine-patches mailing list