Nikolay Sivov : comctl32: Replace nonprintable characters with spaces on SB_SETTEXT.
Alexandre Julliard
julliard at winehq.org
Fri Mar 6 09:49:51 CST 2009
Module: wine
Branch: master
Commit: 74e9b904b9d3cbd892d7c26fd7ac8f6a7f7be154
URL: http://source.winehq.org/git/wine.git/?a=commit;h=74e9b904b9d3cbd892d7c26fd7ac8f6a7f7be154
Author: Nikolay Sivov <bunglehead at gmail.com>
Date: Tue Mar 3 16:50:55 2009 -0500
comctl32: Replace nonprintable characters with spaces on SB_SETTEXT.
---
dlls/comctl32/status.c | 11 +++++++++++
dlls/comctl32/tests/status.c | 30 ++++++++++++++++++++----------
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c
index a56c2a0..17ba1e9 100644
--- a/dlls/comctl32/status.c
+++ b/dlls/comctl32/status.c
@@ -762,6 +762,7 @@ STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style,
part->text = (LPWSTR)text;
} else {
LPWSTR ntext;
+ WCHAR *idx;
if (text && !isW) {
LPCSTR atxt = (LPCSTR)text;
@@ -775,6 +776,16 @@ STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style,
strcpyW (ntext, text);
} else ntext = 0;
+ /* replace nonprintable characters with spaces */
+ if (ntext) {
+ idx = ntext;
+ while (*idx) {
+ if(!isprintW(*idx))
+ *idx = ' ';
+ idx++;
+ }
+ }
+
/* check if text is unchanged -> no need to redraw */
if (text) {
if (!changed && part->text && !lstrcmpW(ntext, part->text)) {
diff --git a/dlls/comctl32/tests/status.c b/dlls/comctl32/tests/status.c
index 4ae663f..f1cbda4 100644
--- a/dlls/comctl32/tests/status.c
+++ b/dlls/comctl32/tests/status.c
@@ -258,6 +258,8 @@ static void test_status_control(void)
RECT rc;
CHAR charArray[20];
HICON hIcon;
+ char ch;
+ char chstr[10] = "Inval id";
hWndStatus = create_status_control(WS_VISIBLE, 0);
@@ -307,7 +309,7 @@ static void test_status_control(void)
/* Test resetting text with different characters */
r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)"First at Again");
expect(TRUE,r);
- r = SendMessage(hWndStatus, SB_SETTEXT, 1, (LPARAM)"InvalidChars\\7\7");
+ r = SendMessage(hWndStatus, SB_SETTEXT, 1, (LPARAM)"Invalid\tChars\\7\7");
expect(TRUE,r);
r = SendMessage(hWndStatus, SB_SETTEXT, 2, (LPARAM)"InvalidChars\\n\n");
expect(TRUE,r);
@@ -318,20 +320,28 @@ static void test_status_control(void)
expect(11,LOWORD(r));
expect(0,HIWORD(r));
r = SendMessage(hWndStatus, SB_GETTEXT, 1, (LPARAM) charArray);
- todo_wine
- {
- ok(strcmp(charArray,"InvalidChars\\7 ") == 0, "Expected InvalidChars\\7 , got %s\n", charArray);
- }
- expect(15,LOWORD(r));
+ ok(strcmp(charArray,"Invalid\tChars\\7 ") == 0, "Expected Invalid\tChars\\7 , got %s\n", charArray);
+
+ expect(16,LOWORD(r));
expect(0,HIWORD(r));
r = SendMessage(hWndStatus, SB_GETTEXT, 2, (LPARAM) charArray);
- todo_wine
- {
- ok(strcmp(charArray,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray);
- }
+ ok(strcmp(charArray,"InvalidChars\\n ") == 0, "Expected InvalidChars\\n , got %s\n", charArray);
+
expect(15,LOWORD(r));
expect(0,HIWORD(r));
+ /* test more nonprintable chars */
+ for(ch = 0x00; ch < 0x7F; ch++) {
+ chstr[5] = ch;
+ r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)chstr);
+ expect(TRUE,r);
+ r = SendMessage(hWndStatus, SB_GETTEXT, 0, (LPARAM)charArray);
+ /* substitution with single space */
+ if (ch > 0x00 && ch < 0x20 && ch != '\t')
+ chstr[5] = ' ';
+ ok(strcmp(charArray, chstr) == 0, "Expected %s, got %s\n", chstr, charArray);
+ }
+
/* Set background color */
r = SendMessage(hWndStatus, SB_SETBKCOLOR , 0, RGB(255,0,0));
ok(r == CLR_DEFAULT ||
More information about the wine-cvs
mailing list