Resend 2: Make controls redraw themselves immediately in certain
situations
Michael Kaufmann
hallo at michael-kaufmann.ch
Sun Oct 31 16:12:35 CST 2004
I've updated this patch; it's against the current CVS version.
Look here for explanations and a demo program:
http://www.winehq.org/hypermail/wine-devel/2004/09/0535.html
Changelog:
- Redraw these controls immediately if an important property gets
changed: ComboBox, Static control, Progress control, Statusbar, Tab control
- Edit control: Redraw immediately if the user types something and upon
EM_REPLACESEL, EM_SETSEL, WM_CLEAR, WM_PASTE, WM_CUT
- Listbox: Redraw immediately if the current selection gets changed and
upon LB_SETCURSEL, LB_SETTOPINDEX
-------------- next part --------------
Index: dlls/comctl32/progress.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/progress.c,v
retrieving revision 1.39
diff -u -r1.39 progress.c
--- dlls/comctl32/progress.c 27 Oct 2004 21:16:03 -0000 1.39
+++ dlls/comctl32/progress.c 31 Oct 2004 16:12:02 -0000
@@ -485,7 +485,7 @@
infoPtr->MinVal = low;
infoPtr->MaxVal = high;
PROGRESS_CoercePos(infoPtr);
- InvalidateRect(infoPtr->Self, NULL, TRUE);
+ RedrawWindow(infoPtr->Self, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
return res;
}
@@ -562,6 +562,7 @@
PROGRESS_CoercePos (infoPtr);
TRACE("PBM_DELTAPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
+ UpdateWindow(infoPtr->Self);
}
return oldVal;
}
@@ -575,6 +576,7 @@
PROGRESS_CoercePos(infoPtr);
TRACE("PBM_SETPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
+ UpdateWindow(infoPtr->Self);
}
return oldVal;
}
@@ -601,6 +603,7 @@
{
TRACE("PBM_STEPIT: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal);
PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal );
+ UpdateWindow(infoPtr->Self);
}
return oldVal;
}
Index: dlls/comctl32/status.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/status.c,v
retrieving revision 1.67
diff -u -r1.67 status.c
--- dlls/comctl32/status.c 27 Oct 2004 21:16:17 -0000 1.67
+++ dlls/comctl32/status.c 31 Oct 2004 16:12:02 -0000
@@ -537,14 +537,14 @@
return TRUE;
infoPtr->part0.hIcon = hIcon;
if (infoPtr->simple)
- InvalidateRect(infoPtr->Self, &infoPtr->part0.bound, FALSE);
+ RedrawWindow(infoPtr->Self, &infoPtr->part0.bound, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
} else {
if (infoPtr->parts[nPart].hIcon == hIcon) /* same as - no redraw */
return TRUE;
infoPtr->parts[nPart].hIcon = hIcon;
if (!(infoPtr->simple))
- InvalidateRect(infoPtr->Self, &infoPtr->parts[nPart].bound, FALSE);
+ RedrawWindow(infoPtr->Self, &infoPtr->parts[nPart].bound, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
return TRUE;
}
@@ -639,7 +639,7 @@
}
}
STATUSBAR_SetPartBounds (infoPtr);
- InvalidateRect(infoPtr->Self, NULL, FALSE);
+ RedrawWindow(infoPtr->Self, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return TRUE;
}
@@ -706,7 +706,7 @@
Free (part->text);
part->text = ntext;
}
- InvalidateRect(infoPtr->Self, &part->bound, FALSE);
+ RedrawWindow(infoPtr->Self, &part->bound, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return TRUE;
}
@@ -778,7 +778,8 @@
nmhdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID);
nmhdr.code = SBN_SIMPLEMODECHANGE;
SendMessageW (infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nmhdr);
- InvalidateRect(infoPtr->Self, NULL, FALSE);
+ RedrawWindow(infoPtr->Self, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
+
return TRUE;
}
@@ -837,9 +838,7 @@
i = SendMessageW(infoPtr->Notify, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY);
infoPtr->NtfUnicode = (i == NFR_UNICODE);
- GetClientRect (hwnd, &rect);
- InvalidateRect (hwnd, &rect, 0);
- UpdateWindow(hwnd);
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
ZeroMemory (&nclm, sizeof(nclm));
nclm.cbSize = sizeof(nclm);
@@ -1049,7 +1048,7 @@
}
}
- InvalidateRect(infoPtr->Self, &part->bound, FALSE);
+ RedrawWindow(infoPtr->Self, &part->bound, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return TRUE;
}
Index: dlls/comctl32/tab.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/tab.c,v
retrieving revision 1.101
diff -u -r1.101 tab.c
--- dlls/comctl32/tab.c 26 Oct 2004 00:22:31 -0000 1.101
+++ dlls/comctl32/tab.c 31 Oct 2004 16:12:05 -0000
@@ -239,6 +239,7 @@
infoPtr->iSelected=iItem;
TAB_EnsureSelectionVisible(hwnd, infoPtr);
TAB_InvalidateTabArea(hwnd, infoPtr);
+ UpdateWindow(hwnd);
}
return prevItem;
}
Index: dlls/comctl32/trackbar.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/trackbar.c,v
retrieving revision 1.62
diff -u -r1.62 trackbar.c
--- dlls/comctl32/trackbar.c 14 Sep 2004 00:45:26 -0000 1.62
+++ dlls/comctl32/trackbar.c 31 Oct 2004 16:12:06 -0000
@@ -375,12 +375,6 @@
TRACKBAR_CalcThumb(infoPtr, infoPtr->lPos, &infoPtr->rcThumb);
}
-static inline void
-TRACKBAR_InvalidateAll(TRACKBAR_INFO * infoPtr)
-{
- InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
-}
-
static void
TRACKBAR_InvalidateThumb (TRACKBAR_INFO *infoPtr, LONG thumbPos)
{
@@ -951,7 +945,8 @@
infoPtr->lSelMax = 0;
infoPtr->flags |= TB_SELECTIONCHANGED;
- if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
+ if (fRedraw)
+ RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
@@ -966,7 +961,8 @@
infoPtr->uNumTics = 0;
}
- if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
+ if (fRedraw)
+ RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
@@ -1096,7 +1092,11 @@
infoPtr->lPos = infoPtr->lRangeMax;
infoPtr->flags |= TB_THUMBPOSCHANGED;
- if (fPosition) TRACKBAR_InvalidateThumbMove(infoPtr, oldPos, lPosition);
+ if (fPosition)
+ {
+ TRACKBAR_InvalidateThumbMove(infoPtr, oldPos, lPosition);
+ UpdateWindow(infoPtr->hwndSelf);
+ }
return 0;
}
@@ -1121,7 +1121,8 @@
infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5;
if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1;
- if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
+ if (fRedraw)
+ RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
@@ -1139,7 +1140,8 @@
infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5;
if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1;
- if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
+ if (fRedraw)
+ RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
@@ -1157,7 +1159,8 @@
infoPtr->lPageSize = (infoPtr->lRangeMax - infoPtr->lRangeMin) / 5;
if (infoPtr->lPageSize == 0) infoPtr->lPageSize = 1;
- if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
+ if (fRedraw)
+ RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
@@ -1178,7 +1181,8 @@
if (infoPtr->lSelMax > infoPtr->lRangeMax)
infoPtr->lSelMax = infoPtr->lRangeMax;
- if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
+ if (fRedraw)
+ RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
@@ -1196,7 +1200,8 @@
if (infoPtr->lSelMax > infoPtr->lRangeMax)
infoPtr->lSelMax = infoPtr->lRangeMax;
- if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
+ if (fRedraw)
+ RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
@@ -1214,7 +1219,8 @@
if (infoPtr->lSelMin < infoPtr->lRangeMin)
infoPtr->lSelMin = infoPtr->lRangeMin;
- if (fRedraw) TRACKBAR_InvalidateAll(infoPtr);
+ if (fRedraw)
+ RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
return 0;
}
@@ -1226,7 +1232,7 @@
if (GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE) & TBS_FIXEDLENGTH) {
infoPtr->uThumbLen = iLength;
infoPtr->flags |= TB_THUMBSIZECHANGED;
- InvalidateRect (infoPtr->hwndSelf, &infoPtr->rcThumb, FALSE);
+ RedrawWindow(infoPtr->hwndSelf, &infoPtr->rcThumb, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
return 0;
@@ -1254,8 +1260,8 @@
}
infoPtr->tics[infoPtr->uNumTics-1] = lPos;
- TRACKBAR_InvalidateAll(infoPtr);
-
+ RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
+
return TRUE;
}
@@ -1266,7 +1272,7 @@
if (GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE) & TBS_AUTOTICKS) {
infoPtr->uTicFreq = wFreq;
TRACKBAR_RecalculateTics (infoPtr);
- TRACKBAR_InvalidateAll(infoPtr);
+ RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
}
return 0;
@@ -1412,7 +1418,7 @@
{
TRACE("\n");
infoPtr->bFocussed = FALSE;
- TRACKBAR_InvalidateAll(infoPtr);
+ InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
return 0;
}
@@ -1496,7 +1502,7 @@
{
TRACE("\n");
infoPtr->bFocussed = TRUE;
- TRACKBAR_InvalidateAll(infoPtr);
+ InvalidateRect(infoPtr->hwndSelf, NULL, FALSE);
return 0;
}
Index: dlls/comctl32/treeview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/treeview.c,v
retrieving revision 1.156
diff -u -r1.156 treeview.c
--- dlls/comctl32/treeview.c 7 Oct 2004 17:34:31 -0000 1.156
+++ dlls/comctl32/treeview.c 31 Oct 2004 16:12:09 -0000
@@ -4162,7 +4162,9 @@
TREEVIEW_Invalidate(infoPtr, NULL);
break;
}
-
+
+ UpdateWindow(infoPtr->hwnd);
+
TRACE("Leaving state %d\n", newSelect ? newSelect->state : 0);
return TRUE;
}
Index: dlls/user/combo.c
===================================================================
RCS file: /home/wine/wine/dlls/user/combo.c,v
retrieving revision 1.4
diff -u -r1.4 combo.c
--- dlls/user/combo.c 18 Oct 2004 21:22:44 -0000 1.4
+++ dlls/user/combo.c 31 Oct 2004 16:12:24 -0000
@@ -1157,9 +1157,9 @@
SWP_NOACTIVATE | SWP_SHOWWINDOW);
- if( !(lphc->wState & CBF_NOREDRAW) )
- RedrawWindow( lphc->self, NULL, 0, RDW_INVALIDATE |
- RDW_ERASE | RDW_UPDATENOW | RDW_NOCHILDREN );
+ if( !(lphc->wState & CBF_NOREDRAW) && !IsRectEmpty(&lphc->buttonRect) )
+ RedrawWindow ( lphc->self, &lphc->buttonRect, 0, RDW_INVALIDATE |
+ RDW_ERASE | RDW_UPDATENOW);
EnableWindow( lphc->hWndLBox, TRUE );
if (GetCapture() != lphc->self)
@@ -1398,6 +1398,10 @@
CB_NOTIFY( lphc, CBN_SELCHANGE );
+ /* FIXME: Calling this before CB_NOTIFY looks much nicer,
+ but Windows does it this way */
+ UpdateWindow(lphc->self);
+
/* fall through */
case LBN_SETFOCUS:
Index: dlls/user/edit.c
===================================================================
RCS file: /home/wine/wine/dlls/user/edit.c,v
retrieving revision 1.6
diff -u -r1.6 edit.c
--- dlls/user/edit.c 25 Oct 2004 21:49:30 -0000 1.6
+++ dlls/user/edit.c 31 Oct 2004 16:12:27 -0000
@@ -247,7 +247,7 @@
static BOOL EDIT_EM_LineScroll(EDITSTATE *es, INT dx, INT dy);
static BOOL EDIT_EM_LineScroll_internal(EDITSTATE *es, INT dx, INT dy);
static LRESULT EDIT_EM_PosFromChar(EDITSTATE *es, INT index, BOOL after_wrap);
-static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit);
+static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit, BOOL drawImmediately);
static LRESULT EDIT_EM_Scroll(EDITSTATE *es, INT action);
static void EDIT_EM_ScrollCaret(EDITSTATE *es);
static void EDIT_EM_SetHandle(EDITSTATE *es, HLOCAL hloc);
@@ -255,7 +255,7 @@
static void EDIT_EM_SetLimitText(EDITSTATE *es, INT limit);
static void EDIT_EM_SetMargins(EDITSTATE *es, INT action, INT left, INT right);
static void EDIT_EM_SetPasswordChar(EDITSTATE *es, WCHAR c);
-static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap);
+static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap, BOOL drawImmediately);
static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, LPINT tabs);
static BOOL EDIT_EM_SetTabStops16(EDITSTATE *es, INT count, LPINT16 tabs);
static void EDIT_EM_SetWordBreakProc(EDITSTATE *es, void *wbp);
@@ -348,7 +348,7 @@
if(es->style & ES_READONLY)
return;
- EDIT_EM_ReplaceSel(es, TRUE, empty_stringW, TRUE, TRUE);
+ EDIT_EM_ReplaceSel(es, TRUE, empty_stringW, TRUE, TRUE, TRUE);
}
@@ -463,15 +463,15 @@
case EM_SETSEL16:
if ((short)LOWORD(lParam) == -1)
- EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
+ EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE, TRUE);
else
- EDIT_EM_SetSel(es, LOWORD(lParam), HIWORD(lParam), FALSE);
+ EDIT_EM_SetSel(es, LOWORD(lParam), HIWORD(lParam), FALSE, TRUE);
if (!wParam)
EDIT_EM_ScrollCaret(es);
result = 1;
break;
case EM_SETSEL:
- EDIT_EM_SetSel(es, wParam, lParam, FALSE);
+ EDIT_EM_SetSel(es, wParam, lParam, FALSE, TRUE);
EDIT_EM_ScrollCaret(es);
result = 1;
break;
@@ -626,7 +626,7 @@
MultiByteToWideChar(CP_ACP, 0, textA, -1, textW, countW);
}
- EDIT_EM_ReplaceSel(es, (BOOL)wParam, textW, TRUE, TRUE);
+ EDIT_EM_ReplaceSel(es, (BOOL)wParam, textW, TRUE, TRUE, TRUE);
result = 1;
if(!unicode)
@@ -1831,7 +1831,7 @@
e--;
}
}
- EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
+ EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE, TRUE);
EDIT_EM_ScrollCaret(es);
}
@@ -1857,7 +1857,7 @@
e = EDIT_CharFromPos(es, x, y + es->line_height, &after_wrap);
if (!extend)
s = e;
- EDIT_EM_SetSel(es, s, e, after_wrap);
+ EDIT_EM_SetSel(es, s, e, after_wrap, TRUE);
EDIT_EM_ScrollCaret(es);
}
@@ -1878,7 +1878,7 @@
HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), &after_wrap);
else
e = strlenW(es->text);
- EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, after_wrap);
+ EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, after_wrap, TRUE);
EDIT_EM_ScrollCaret(es);
}
@@ -1901,7 +1901,7 @@
e += 2;
}
}
- EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
+ EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE, TRUE);
EDIT_EM_ScrollCaret(es);
}
@@ -1923,7 +1923,7 @@
HIWORD(EDIT_EM_PosFromChar(es, es->selection_end, es->flags & EF_AFTER_WRAP)), NULL);
else
e = 0;
- EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE);
+ EDIT_EM_SetSel(es, extend ? es->selection_start : e, e, FALSE, TRUE);
EDIT_EM_ScrollCaret(es);
}
@@ -1951,7 +1951,7 @@
&after_wrap);
if (!extend)
s = e;
- EDIT_EM_SetSel(es, s, e, after_wrap);
+ EDIT_EM_SetSel(es, s, e, after_wrap, TRUE);
EDIT_EM_ScrollCaret(es);
}
@@ -1979,7 +1979,7 @@
&after_wrap);
if (!extend)
s = e;
- EDIT_EM_SetSel(es, s, e, after_wrap);
+ EDIT_EM_SetSel(es, s, e, after_wrap, TRUE);
EDIT_EM_ScrollCaret(es);
}
@@ -2005,7 +2005,7 @@
e = EDIT_CharFromPos(es, x, y - es->line_height, &after_wrap);
if (!extend)
s = e;
- EDIT_EM_SetSel(es, s, e, after_wrap);
+ EDIT_EM_SetSel(es, s, e, after_wrap, TRUE);
EDIT_EM_ScrollCaret(es);
}
@@ -2037,7 +2037,7 @@
}
if (!extend)
s = e;
- EDIT_EM_SetSel(es, s, e, FALSE);
+ EDIT_EM_SetSel(es, s, e, FALSE, TRUE);
EDIT_EM_ScrollCaret(es);
}
@@ -2067,7 +2067,7 @@
}
if (!extend)
s = e;
- EDIT_EM_SetSel(es, s, e, FALSE);
+ EDIT_EM_SetSel(es, s, e, FALSE, TRUE);
EDIT_EM_ScrollCaret(es);
}
@@ -2914,7 +2914,7 @@
* FIXME: handle ES_NUMBER and ES_OEMCONVERT here
*
*/
-static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit)
+static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, LPCWSTR lpsz_replace, BOOL send_update, BOOL honor_limit, BOOL drawImmediately)
{
UINT strl = strlenW(lpsz_replace);
UINT tl = strlenW(es->text);
@@ -3026,7 +3026,7 @@
else
EDIT_CalcLineWidth_SL(es);
- EDIT_EM_SetSel(es, s, s, FALSE);
+ EDIT_EM_SetSel(es, s, s, FALSE, FALSE);
es->flags |= EF_MODIFIED;
if (send_update) es->flags |= EF_UPDATE;
if (hrgn)
@@ -3042,6 +3042,7 @@
/* force scroll info update */
EDIT_UpdateScrollInfo(es);
+ if (drawImmediately) UpdateWindow(es->hwndSelf);
if(es->flags & EF_UPDATE)
{
@@ -3438,7 +3439,7 @@
* In other words: this handler is OK
*
*/
-static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap)
+static void EDIT_EM_SetSel(EDITSTATE *es, UINT start, UINT end, BOOL after_wrap, BOOL drawImmediately)
{
UINT old_start = es->selection_start;
UINT old_end = es->selection_end;
@@ -3483,6 +3484,8 @@
}
}
else EDIT_InvalidateText(es, start, old_end);
+
+ if (drawImmediately) UpdateWindow(es->hwndSelf);
}
@@ -3595,10 +3598,10 @@
TRACE("before UNDO:insertion length = %d, deletion buffer = %s\n",
es->undo_insert_count, debugstr_w(utext));
- EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
+ EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE, FALSE);
EDIT_EM_EmptyUndoBuffer(es);
- EDIT_EM_ReplaceSel(es, TRUE, utext, TRUE, TRUE);
- EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE);
+ EDIT_EM_ReplaceSel(es, TRUE, utext, TRUE, TRUE, FALSE);
+ EDIT_EM_SetSel(es, es->undo_position, es->undo_position + es->undo_insert_count, FALSE, FALSE);
/* send the notification after the selection start and end are set */
EDIT_NOTIFY_PARENT(es, EN_CHANGE, "EN_CHANGE");
EDIT_EM_ScrollCaret(es);
@@ -3633,7 +3636,7 @@
EDIT_MoveDown_ML(es, FALSE);
} else {
static const WCHAR cr_lfW[] = {'\r','\n',0};
- EDIT_EM_ReplaceSel(es, TRUE, cr_lfW, TRUE, TRUE);
+ EDIT_EM_ReplaceSel(es, TRUE, cr_lfW, TRUE, TRUE, TRUE);
}
}
break;
@@ -3641,7 +3644,7 @@
if ((es->style & ES_MULTILINE) && !(es->style & ES_READONLY))
{
static const WCHAR tabW[] = {'\t',0};
- EDIT_EM_ReplaceSel(es, TRUE, tabW, TRUE, TRUE);
+ EDIT_EM_ReplaceSel(es, TRUE, tabW, TRUE, TRUE, TRUE);
}
break;
case VK_BACK:
@@ -3650,7 +3653,7 @@
EDIT_WM_Clear(es);
else {
/* delete character left of caret */
- EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
+ EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE, TRUE);
EDIT_MoveBackward(es, TRUE);
EDIT_WM_Clear(es);
}
@@ -3677,7 +3680,7 @@
WCHAR str[2];
str[0] = c;
str[1] = '\0';
- EDIT_EM_ReplaceSel(es, TRUE, str, TRUE, TRUE);
+ EDIT_EM_ReplaceSel(es, TRUE, str, TRUE, TRUE, TRUE);
}
break;
}
@@ -3711,7 +3714,7 @@
EDIT_WM_Clear(es);
break;
case EM_SETSEL:
- EDIT_EM_SetSel(es, 0, (UINT)-1, FALSE);
+ EDIT_EM_SetSel(es, 0, (UINT)-1, FALSE, TRUE);
EDIT_EM_ScrollCaret(es);
break;
default:
@@ -3809,7 +3812,7 @@
EDIT_EM_EmptyUndoBuffer(es);
if (name && *name) {
- EDIT_EM_ReplaceSel(es, FALSE, name, FALSE, TRUE);
+ EDIT_EM_ReplaceSel(es, FALSE, name, FALSE, TRUE, FALSE);
/* if we insert text to the editline, the text scrolls out
* of the window, as the caret is placed after the insert
* pos normally; thus we reset es->selection... to 0 and
@@ -4174,17 +4177,17 @@
} else {
if (shift) {
/* delete character left of caret */
- EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
+ EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE, TRUE);
EDIT_MoveBackward(es, TRUE);
EDIT_WM_Clear(es);
} else if (control) {
/* delete to end of line */
- EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
+ EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE, TRUE);
EDIT_MoveEnd(es, TRUE);
EDIT_WM_Clear(es);
} else {
/* delete character right of caret */
- EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE);
+ EDIT_EM_SetSel(es, (UINT)-1, 0, FALSE, TRUE);
EDIT_MoveForward(es, TRUE);
EDIT_WM_Clear(es);
}
@@ -4256,7 +4259,7 @@
ll = EDIT_EM_LineLength(es, e);
s = li + EDIT_CallWordBreakProc(es, li, e - li, ll, WB_LEFT);
e = li + EDIT_CallWordBreakProc(es, li, e - li, ll, WB_RIGHT);
- EDIT_EM_SetSel(es, s, e, FALSE);
+ EDIT_EM_SetSel(es, s, e, FALSE, TRUE);
EDIT_EM_ScrollCaret(es);
return 0;
}
@@ -4280,7 +4283,7 @@
SetCapture(es->hwndSelf);
EDIT_ConfinePoint(es, &x, &y);
e = EDIT_CharFromPos(es, x, y, &after_wrap);
- EDIT_EM_SetSel(es, (keys & MK_SHIFT) ? es->selection_start : e, e, after_wrap);
+ EDIT_EM_SetSel(es, (keys & MK_SHIFT) ? es->selection_start : e, e, after_wrap, TRUE);
EDIT_EM_ScrollCaret(es);
es->region_posx = es->region_posy = 0;
SetTimer(es->hwndSelf, 0, 100, NULL);
@@ -4339,7 +4342,7 @@
es->region_posx = (prex < x) ? -1 : ((prex > x) ? 1 : 0);
es->region_posy = (prey < y) ? -1 : ((prey > y) ? 1 : 0);
e = EDIT_CharFromPos(es, x, y, &after_wrap);
- EDIT_EM_SetSel(es, es->selection_start, e, after_wrap);
+ EDIT_EM_SetSel(es, es->selection_start, e, after_wrap, TRUE);
EDIT_SetCaretPos(es,es->selection_end,es->flags & EF_AFTER_WRAP);
return 0;
}
@@ -4546,7 +4549,7 @@
OpenClipboard(es->hwndSelf);
if ((hsrc = GetClipboardData(CF_UNICODETEXT))) {
src = (LPWSTR)GlobalLock(hsrc);
- EDIT_EM_ReplaceSel(es, TRUE, src, TRUE, TRUE);
+ EDIT_EM_ReplaceSel(es, TRUE, src, TRUE, TRUE, TRUE);
GlobalUnlock(hsrc);
}
CloseClipboard();
@@ -4645,11 +4648,11 @@
text = textW;
}
- EDIT_EM_SetSel(es, 0, (UINT)-1, FALSE);
+ EDIT_EM_SetSel(es, 0, (UINT)-1, FALSE, FALSE);
if (text)
{
TRACE("%s\n", debugstr_w(text));
- EDIT_EM_ReplaceSel(es, FALSE, text, FALSE, FALSE);
+ EDIT_EM_ReplaceSel(es, FALSE, text, FALSE, FALSE, FALSE);
if(!unicode)
HeapFree(GetProcessHeap(), 0, (LPWSTR)text);
}
@@ -4657,11 +4660,11 @@
{
static const WCHAR empty_stringW[] = {0};
TRACE("<NULL>\n");
- EDIT_EM_ReplaceSel(es, FALSE, empty_stringW, FALSE, FALSE);
+ EDIT_EM_ReplaceSel(es, FALSE, empty_stringW, FALSE, FALSE, FALSE);
}
es->x_offset = 0;
es->flags &= ~EF_MODIFIED;
- EDIT_EM_SetSel(es, 0, 0, FALSE);
+ EDIT_EM_SetSel(es, 0, 0, FALSE, FALSE);
/* Send the notification after the selection start and end have been set
* edit control doesn't send notification on WM_SETTEXT
@@ -4905,7 +4908,7 @@
/*********************************************************************
*
- * EDIT_UpdateText
+ * EDIT_UpdateTextRegion
*
*/
static void EDIT_UpdateTextRegion(EDITSTATE *es, HRGN hrgn, BOOL bErase)
Index: dlls/user/listbox.c
===================================================================
RCS file: /home/wine/wine/dlls/user/listbox.c,v
retrieving revision 1.5
diff -u -r1.5 listbox.c
--- dlls/user/listbox.c 26 Oct 2004 22:03:00 -0000 1.5
+++ dlls/user/listbox.c 31 Oct 2004 16:12:30 -0000
@@ -2367,6 +2367,12 @@
descr->selected_item = caret;
else
LISTBOX_SetSelection( descr, caret, TRUE, FALSE);
+
+ /* If the content has been scrolled, the new items
+ * need to be drawn immediately (Windows does it this way)
+ */
+ UpdateWindow(descr->self);
+
if (descr->style & LBS_NOTIFY)
{
if( descr->lphc )
@@ -2721,7 +2727,9 @@
case LB_SETTOPINDEX16:
case LB_SETTOPINDEX:
- return LISTBOX_SetTopItem( descr, wParam, TRUE );
+ ret = LISTBOX_SetTopItem( descr, wParam, TRUE );
+ UpdateWindow(hwnd); /* Windows does this too */
+ return ret;
case LB_SETCOLUMNWIDTH16:
case LB_SETCOLUMNWIDTH:
@@ -2842,7 +2850,8 @@
LISTBOX_SetCaretIndex( descr, wParam, TRUE );
ret = LISTBOX_SetSelection( descr, wParam, TRUE, FALSE );
if (lphc && ret != LB_ERR) ret = descr->selected_item;
- return ret;
+ UpdateWindow(hwnd); /* Windows does this too */
+ return ret;
case LB_GETSELCOUNT16:
case LB_GETSELCOUNT:
Index: dlls/user/static.c
===================================================================
RCS file: /home/wine/wine/dlls/user/static.c,v
retrieving revision 1.2
diff -u -r1.2 static.c
--- dlls/user/static.c 5 Oct 2004 04:11:29 -0000 1.2
+++ dlls/user/static.c 31 Oct 2004 16:12:31 -0000
@@ -348,8 +348,6 @@
else
lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam );
}
- if (uMsg == WM_SETTEXT)
- STATIC_TryPaintFcn( hwnd, full_style );
break;
}
default:
@@ -360,9 +358,10 @@
else
lResult = DefWindowProcA( hwnd, WM_SETTEXT, wParam, lParam );
}
- if(uMsg == WM_SETTEXT)
- InvalidateRect(hwnd, NULL, TRUE);
}
+
+ STATIC_TryPaintFcn( hwnd, full_style );
+
return 1; /* success. FIXME: check text length */
case WM_SETFONT:
Index: dlls/user/tests/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/Makefile.in,v
retrieving revision 1.11
diff -u -r1.11 Makefile.in
--- dlls/user/tests/Makefile.in 20 Jul 2004 22:09:14 -0000 1.11
+++ dlls/user/tests/Makefile.in 31 Oct 2004 16:12:31 -0000
@@ -14,6 +14,7 @@
input.c \
listbox.c \
msg.c \
+ redraw.c \
resource.c \
sysparams.c \
text.c \
--- /dev/null 2004-08-22 23:26:44.000000000 +0200
+++ dlls/user/tests/redraw.c 2004-10-31 15:07:42.000000000 +0100
@@ -0,0 +1,183 @@
+/* Unit test suite for redraw behaviour (standard controls)
+ *
+ * Copyright 2004 Michael Kaufmann
+ *
+ * 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 <windows.h>
+
+#include "wine/test.h"
+
+static const CHAR parent_class[] = "RedrawWindowClass";
+
+static LRESULT WINAPI redraw_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+ return DefWindowProcA(hwnd, msg, wparam, lparam);
+}
+
+void do_redraw_test ()
+{
+ int i;
+ HWND parent;
+ HWND handle;
+
+
+ /* Register a class for the parent window */
+
+ WNDCLASSA cls;
+
+ cls.style = CS_HREDRAW | CS_VREDRAW;
+ cls.lpfnWndProc = redraw_window_procA;
+ cls.cbClsExtra = 0;
+ cls.cbWndExtra = 0;
+ cls.hInstance = GetModuleHandleA(0);
+ cls.hIcon = LoadIconA(NULL, IDI_APPLICATION);
+ cls.hCursor = LoadCursorA(NULL, (LPSTR)IDC_ARROW);
+ cls.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
+ cls.lpszMenuName = NULL;
+ cls.lpszClassName = parent_class;
+
+ assert(RegisterClassA(&cls));
+
+
+ /* Create the parent window */
+
+ parent = CreateWindowA (parent_class, "Redraw Test",
+ WS_OVERLAPPEDWINDOW,
+ 0, 0, 200, 200,
+ NULL, NULL, NULL, 0);
+
+
+ /* Static control */
+
+ handle = CreateWindow ("STATIC", "Static Test",
+ (WS_CHILD | WS_VISIBLE | SS_SIMPLE),
+ 0, 0, 200, 200,
+ parent, NULL, NULL, 0);
+
+ assert (handle);
+
+ ShowWindow(parent, SW_SHOW);
+ UpdateWindow(parent);
+
+ ok(!GetUpdateRect(handle, NULL, FALSE), "GetUpdateRect should return FALSE after UpdateWindow\n");
+
+ SendMessage(handle, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) "New Text");
+ ok(!GetUpdateRect(handle, NULL, FALSE), "WM_SETTEXT: Static control should redraw itself\n");
+
+ assert(DestroyWindow(handle));
+
+
+
+ /* Listbox */
+
+ handle = CreateWindow ("LISTBOX", "ListboxTest",
+ (WS_CHILD | WS_VISIBLE | (LBS_STANDARD & ~LBS_SORT) | LBS_MULTIPLESEL),
+ 0, 0, 200, 200,
+ parent, NULL, NULL, 0);
+
+ assert (handle);
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage (handle, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) "First added");
+ ok(GetUpdateRect(handle, NULL, FALSE), "LB_ADDSTRING: Listbox should not redraw itself\n");
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage (handle, LB_SETSEL, TRUE, 0);
+ SendMessage (handle, LB_SETSEL, TRUE, 1);
+ ok(GetUpdateRect(handle, NULL, FALSE), "LB_SETSEL: Listbox should not redraw itself\n");
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage (handle, LB_RESETCONTENT, 0, 0);
+ ok(GetUpdateRect(handle, NULL, FALSE), "LB_RESETCONTENT: Listbox should not redraw itself\n");
+
+ /* Add enough items to make scrolling necessary */
+ for (i=0; i < 100; i++) SendMessage(handle, LB_ADDSTRING, 0, (LPARAM) (LPCTSTR) "Listbox Item");
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage(handle, LB_SETTOPINDEX, 90, 0);
+ ok(!GetUpdateRect(handle, NULL, FALSE), "LB_SETTOPINDEX: Listbox should redraw itself\n");
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage(handle, LB_SETCURSEL, 5, 0);
+ ok(!GetUpdateRect(handle, NULL, FALSE), "LB_SETCURSEL: Listbox should redraw itself\n");
+
+ assert(DestroyWindow(handle));
+
+
+ /* Edit control */
+
+ handle = CreateWindow ("EDIT", "Edit Test",
+ (WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_AUTOVSCROLL),
+ 0, 0, 200, 200,
+ parent, NULL, NULL, 0);
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage(handle, WM_SETTEXT, 0, (LPARAM) (LPCTSTR) "New Edit Text");
+ ok(GetUpdateRect(handle, NULL, FALSE), "WM_SETTEXT: Single-line edit control should not redraw itself\n");
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage(handle, EM_REPLACESEL, TRUE, (LPARAM) (LPCTSTR) "Replacement Text");
+ ok(!GetUpdateRect(handle, NULL, FALSE), "EM_REPLACESEL: Single-line edit control should redraw itself\n");
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage(handle, EM_SETSEL, 0, 10);
+ ok(!GetUpdateRect(handle, NULL, FALSE), "EM_SETSEL: Single-line edit control should redraw itself\n");
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage(handle, WM_CUT, 0, 0);
+ ok(!GetUpdateRect(handle, NULL, FALSE), "WM_CUT: Single-line edit control should redraw itself\n");
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage(handle, WM_PASTE, 0, 0);
+ ok(!GetUpdateRect(handle, NULL, FALSE), "WM_PASTE: Single-line edit control should redraw itself\n");
+
+ UpdateWindow(handle);
+ assert(!GetUpdateRect(handle, NULL, FALSE));
+
+ SendMessage(handle, WM_CLEAR, 0, 0);
+ ok(!GetUpdateRect(handle, NULL, FALSE), "WM_CLEAR: Single-line edit control should redraw itself\n");
+
+ assert(DestroyWindow(handle));
+ assert(DestroyWindow(parent));
+ assert(UnregisterClassA("RedrawWindowClass", GetModuleHandleA(0)));
+}
+
+START_TEST(redraw)
+{
+ do_redraw_test();
+}
More information about the wine-patches
mailing list