sync edit to wine 1.1.31
authorChristoph von Wittich <christoph_vw@reactos.org>
Sat, 17 Oct 2009 19:35:42 +0000 (19:35 +0000)
committerChristoph von Wittich <christoph_vw@reactos.org>
Sat, 17 Oct 2009 19:35:42 +0000 (19:35 +0000)
svn path=/trunk/; revision=43539

reactos/dll/win32/user32/controls/edit.c

index 92d4c59..901b0ad 100644 (file)
@@ -164,6 +164,7 @@ typedef struct
                     (LPARAM)(es->hwndSelf)); \
        } while(0)
 
+
 /*********************************************************************
  *
  *     EM_CANUNDO
@@ -1225,7 +1226,7 @@ static void EDIT_UnlockBuffer(EDITSTATE *es, BOOL force)
        {
            WARN("edit hwnd %p already destroyed\n", es->hwndSelf);
            return;
-       }
+       }
 
        if (!es->lock_count) {
                ERR("lock_count == 0 ... please report\n");
@@ -3676,8 +3677,8 @@ static LRESULT EDIT_WM_KeyDown(EDITSTATE *es, INT key)
            }
            break;
         case VK_ESCAPE:
-           if (!(es->style & ES_MULTILINE) && EDIT_IsInsideDialog(es))
-               PostMessageW(es->hwndParent, WM_CLOSE, 0, 0);
+            if ((es->style & ES_MULTILINE) && EDIT_IsInsideDialog(es))
+                PostMessageW(es->hwndParent, WM_CLOSE, 0, 0);
             break;
         case VK_TAB:
             if ((es->style & ES_MULTILINE) && EDIT_IsInsideDialog(es))
@@ -4601,8 +4602,8 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs, BOOL unicode)
         *            WM_XXX messages before WM_NCCREATE is completed.
         */
 
-       es->is_unicode = unicode;
-       es->style = lpcs->style;
+       es->is_unicode = unicode;
+       es->style = lpcs->style;
 
         es->bEnableState = !(es->style & WS_DISABLED);
 
@@ -4670,7 +4671,7 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs, BOOL unicode)
          * If WS_BORDER without WS_EX_CLIENTEDGE is specified we shouldn't have
          * a nonclient area and we should handle painting the border ourselves.
          *
-         * When making modifications please ensure that the code still works 
+         * When making modifications please ensure that the code still works
          * for edit controls created directly with style 0x50800000, exStyle 0
          * (which should have a single pixel border)
         */
@@ -4691,7 +4692,7 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs, BOOL unicode)
 static LRESULT EDIT_WM_Create(EDITSTATE *es, LPCWSTR name)
 {
         RECT clientRect;
-        
+
        TRACE("%s\n", debugstr_w(name));
        /*
         *      To initialize some final structure members, we call some helper
@@ -4701,7 +4702,7 @@ static LRESULT EDIT_WM_Create(EDITSTATE *es, LPCWSTR name)
         */
         EDIT_WM_SetFont(es, 0, FALSE);
         EDIT_EM_EmptyUndoBuffer(es);
-        
+
         /* We need to calculate the format rect
            (applications may send EM_SETMARGINS before the control gets visible) */
         GetClientRect(es->hwndSelf, &clientRect);
@@ -4803,7 +4804,7 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
        LRESULT result = 0;
 
         TRACE("hwnd=%p msg=%x (%s) wparam=%lx lparam=%lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), wParam, lParam);
-       
+
        if (!es && msg != WM_NCCREATE)
                return DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
 
@@ -5121,6 +5122,9 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
        case EM_SETREADONLY16:
 #endif
        case EM_SETREADONLY:
+       {
+               DWORD old_style = es->style;
+
                if (wParam) {
                     SetWindowLongPtrW( hwnd, GWL_STYLE,
                                        GetWindowLongPtrW( hwnd, GWL_STYLE ) | ES_READONLY );
@@ -5130,8 +5134,13 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
                                        GetWindowLongPtrW( hwnd, GWL_STYLE ) & ~ES_READONLY );
                     es->style &= ~ES_READONLY;
                }
-                result = 1;
-               break;
+
+               if (old_style ^ es->style)
+                   InvalidateRect(es->hwndSelf, NULL, TRUE);
+
+               result = 1;
+               break;
+       }
 
 #ifndef __REACTOS__
        case EM_SETWORDBREAKPROC16:
@@ -5208,7 +5217,7 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
 
        case WM_GETDLGCODE:
                result = DLGC_HASSETSEL | DLGC_WANTCHARS | DLGC_WANTARROWS;
-               
+
                if (es->style & ES_MULTILINE)
                   result |= DLGC_WANTALLKEYS;
 
@@ -5483,12 +5492,12 @@ LRESULT WINAPI EditWndProc_common( HWND hwnd, UINT msg,
 
        case WM_IME_CONTROL:
                break;
-                
+
        default:
                result = DefWindowProcT(hwnd, msg, wParam, lParam, unicode);
                break;
        }
-       
+
        if (es) EDIT_UnlockBuffer(es, FALSE);
 
         TRACE("hwnd=%p msg=%x (%s) -- 0x%08lx\n", hwnd, msg, SPY_GetMsgName(msg, hwnd), result);