Signed-off-by: Sergio Gómez Del Real sdelreal@codeweavers.com --- dlls/comctl32/edit.c | 64 ++++++++++++++++++++++++++++++++++++++ dlls/comctl32/tests/edit.c | 62 ++++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+)
diff --git a/dlls/comctl32/edit.c b/dlls/comctl32/edit.c index f0180adfbe..9800b84749 100644 --- a/dlls/comctl32/edit.c +++ b/dlls/comctl32/edit.c @@ -131,6 +131,7 @@ typedef struct should be sent to the first parent. */ HWND hwndListBox; /* handle of ComboBox's listbox or NULL */ INT wheelDeltaRemainder; /* scroll wheel delta left over after scrolling whole lines */ + LPWSTR cue_banner_text; /* cue banner string */ /* * only for multi line controls */ @@ -2181,6 +2182,12 @@ static void EDIT_PaintLine(EDITSTATE *es, HDC dc, INT line, BOOL rev) x += EDIT_PaintText(es, dc, x, y, line, e - li, li + ll - e, FALSE); } else x += EDIT_PaintText(es, dc, x, y, line, 0, ll, FALSE); + + if (!(es->flags & EF_FOCUSED) && es->cue_banner_text && es->text_length == 0) + { + SetTextColor(dc, GetSysColor(COLOR_GRAYTEXT)); + TextOutW(dc, x, y, es->cue_banner_text, strlenW(es->cue_banner_text)); + } }
@@ -4152,6 +4159,54 @@ static LRESULT EDIT_EM_GetThumb(EDITSTATE *es) EDIT_WM_HScroll(es, EM_GETTHUMB, 0)); }
+/********************************************************************* + * + * EM_SETCUEBANNER + * + */ +static BOOL EDIT_EM_SetCueBanner(EDITSTATE *es, BOOL focus, const WCHAR *cue_text) +{ + SIZE_T str_size; + + if (es->style & ES_MULTILINE || !cue_text) + return FALSE; + + str_size = strlenW(cue_text); + + if (es->cue_banner_text) + heap_free(es->cue_banner_text); + + es->cue_banner_text = heap_alloc_zero(ROUND_TO_GROW((str_size + 1) * sizeof(WCHAR))); + if (!es->cue_banner_text) + return FALSE; + + memcpy(es->cue_banner_text, cue_text, str_size * sizeof(WCHAR)); + + return TRUE; +} + +/********************************************************************* + * + * EM_GETCUEBANNER + * + */ +static BOOL EDIT_EM_GetCueBanner(EDITSTATE *es, WCHAR *buf, DWORD size) +{ + if (!es->cue_banner_text) + return FALSE; + else + { + if (size > strlenW(es->cue_banner_text)) + lstrcpynW(buf, es->cue_banner_text, strlenW(es->cue_banner_text)+1); + else if (size > 0) + { + memcpy(buf, es->cue_banner_text, (size - 1) * sizeof(WCHAR)); + buf[size-1] = 0; + } + return TRUE; + } +} +
/******************************************************************** * @@ -4490,6 +4545,7 @@ static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es) SetWindowLongPtrW( es->hwndSelf, 0, 0 ); heap_free(es->undo_text); heap_free(es); + heap_free(es->cue_banner_text);
return 0; } @@ -4703,6 +4759,14 @@ static LRESULT CALLBACK EDIT_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPAR result = EDIT_EM_CharFromPos(es, (short)LOWORD(lParam), (short)HIWORD(lParam)); break;
+ case EM_SETCUEBANNER: + result = EDIT_EM_SetCueBanner(es, (BOOL)wParam, (const WCHAR *)lParam); + break; + + case EM_GETCUEBANNER: + result = EDIT_EM_GetCueBanner(es, (WCHAR *)wParam, (DWORD)lParam); + break; + /* End of the EM_ messages which were in numerical order; what order * are these in? vaguely alphabetical? */ diff --git a/dlls/comctl32/tests/edit.c b/dlls/comctl32/tests/edit.c index a5097d1cbb..030c614344 100644 --- a/dlls/comctl32/tests/edit.c +++ b/dlls/comctl32/tests/edit.c @@ -3061,6 +3061,67 @@ static const struct message killfocus_combined_seq[] = { 0 } };
+static void test_cue_banner(void) +{ + HWND hwnd_edit; + BOOL ret; + static WCHAR testW[80] = {'T','e','s','t',0}; + static WCHAR testcmp1W[] = {'T','e','s','t',0}; + static WCHAR testcmp2W[] = {'T','e','s',0}; + static WCHAR getcuetestW[5]; + static WCHAR emptyW[] = {0}; + + hwnd_edit = create_editcontrolW(ES_AUTOHSCROLL | ES_AUTOVSCROLL, 0); + + ret = (BOOL)SendMessageW(hwnd_edit, EM_GETCUEBANNER, 0, 0); + ok(ret == FALSE, "EM_GETCUEBANNER should have returned FALSE.\n"); + + ret = (BOOL)SendMessageW(hwnd_edit, EM_SETCUEBANNER, 0, 0); + ok(ret == FALSE, "EM_SETCUEBANNER should have returned FALSE.\n"); + + ret = (BOOL)SendMessageW(hwnd_edit, EM_GETCUEBANNER, 0, 0); + ok(ret == FALSE, "EM_GETCUEBANNER should have returned FALSE.\n"); + + ret = (BOOL)SendMessageW(hwnd_edit, EM_SETCUEBANNER, 0, (LPARAM)testW); + ok(ret == TRUE, "EM_SETCUEBANNER should have returned TRUE.\n"); + + ret = (BOOL)SendMessageW(hwnd_edit, EM_GETCUEBANNER, (WPARAM)getcuetestW, 5); + ok(ret == TRUE, "EM_GETCUEBANNER should have returned TRUE.\n"); + ok(lstrcmpW(getcuetestW, testW) == 0, "EM_GETCUEBANNER returned string %s.\n", wine_dbgstr_w(getcuetestW)); + + ret = (BOOL)SendMessageW(hwnd_edit, EM_SETCUEBANNER, 0, (LPARAM)emptyW); + ok(ret == TRUE, "EM_SETCUEBANNER should have returned TRUE.\n"); + + ret = (BOOL)SendMessageW(hwnd_edit, EM_GETCUEBANNER, (WPARAM)getcuetestW, 5); + ok(ret == TRUE, "EM_GETCUEBANNER should have returned TRUE.\n"); + ok(lstrcmpW(getcuetestW, emptyW) == 0, "EM_GETCUEBANNER returned string %s.\n", wine_dbgstr_w(getcuetestW)); + + /* EM_GETCUEBANNER's buffer size includes null char */ + ret = (BOOL)SendMessageW(hwnd_edit, EM_SETCUEBANNER, 0, (LPARAM)testW); + ok(ret == TRUE, "EM_SETCUEBANNER should have returned TRUE.\n"); + memset(testW, 0, lstrlenW(testcmp1W)*sizeof(WCHAR)); + ret = (BOOL)SendMessageW(hwnd_edit, EM_GETCUEBANNER, (WPARAM)testW, (LPARAM)lstrlenW(testcmp1W)+1); + ok(ret == TRUE || + broken(ret == FALSE), /* Win XP */ + "EM_GETCUEBANNER should have returned TRUE.\n"); + ok(lstrcmpW(testW, testcmp1W) == 0 || + broken(lstrcmpW(testW, testcmp1W) == -1), /* Win XP, Server 2003 */ + "EM_GETCUEBANNER returned string %s.\n", wine_dbgstr_w(testW)); + memset(testW, 0, lstrlenW(testcmp1W)*sizeof(WCHAR)); + ret = (BOOL)SendMessageW(hwnd_edit, EM_GETCUEBANNER, (WPARAM)testW, (LPARAM)lstrlenW(testcmp1W)); + ok(lstrcmpW(testW, testcmp2W) == 0 || + broken(lstrcmpW(testW, testcmp1W) == -1), /* Win XP, Server 2003 */ + "EM_GETCUEBANNER returned string %s.\n", wine_dbgstr_w(testW)); + DestroyWindow(hwnd_edit); + + /* setting cue banner fails for multi-line edit controls */ + hwnd_edit = create_editcontrolW(ES_AUTOHSCROLL | ES_AUTOVSCROLL | ES_MULTILINE, 0); + ret = (BOOL)SendMessageW(hwnd_edit, EM_SETCUEBANNER, 0, (LPARAM)testW); + ok(ret == FALSE, "EM_SETCUEBANNER.\n"); + + DestroyWindow(hwnd_edit); +} + static void test_change_focus(void) { HWND hwnd, parent_wnd; @@ -3138,6 +3199,7 @@ START_TEST(edit) test_EM_GETLINE(); test_wordbreak_proc(); test_change_focus(); + test_cue_banner();
UnregisterWindowClasses();
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=43364
Your paranoid android.
=== wxppro (32 bit Windows report) ===
comctl32: edit.c:3089: Test failed: EM_GETCUEBANNER should have returned TRUE. edit.c:3090: Test failed: EM_GETCUEBANNER returned string L"". edit.c:3096: Test failed: EM_GETCUEBANNER should have returned TRUE.
=== w2003std (32 bit Windows report) ===
comctl32: edit.c:3089: Test failed: EM_GETCUEBANNER should have returned TRUE. edit.c:3090: Test failed: EM_GETCUEBANNER returned string L"". edit.c:3096: Test failed: EM_GETCUEBANNER should have returned TRUE.
On 10/22/2018 06:46 PM, Sergio Gómez Del Real wrote:
LPWSTR cue_banner_text; /* cue banner string */
Please use WCHAR * for this, I know comctl32 is not very consistent about this. You can remove comment too, field name is self explanatory.
+static BOOL EDIT_EM_SetCueBanner(EDITSTATE *es, BOOL focus, const WCHAR *cue_text)
Is wParam doing anything?
- es->cue_banner_text = heap_alloc_zero(ROUND_TO_GROW((str_size + 1) * sizeof(WCHAR)));
- if (!es->cue_banner_text)
return FALSE;
Why size alignment and zero-ing?
if (size > strlenW(es->cue_banner_text))
lstrcpynW(buf, es->cue_banner_text, strlenW(es->cue_banner_text)+1);
else if (size > 0)
{
memcpy(buf, es->cue_banner_text, (size - 1) * sizeof(WCHAR));
buf[size-1] = 0;
}
ret
It doesn't look like such separation is necessary.
@@ -4490,6 +4545,7 @@ static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es) SetWindowLongPtrW( es->hwndSelf, 0, 0 ); heap_free(es->undo_text); heap_free(es);
- heap_free(es->cue_banner_text);
This is wrong.
- ret = (BOOL)SendMessageW(hwnd_edit, EM_GETCUEBANNER, 0, 0);
- ok(ret == FALSE, "EM_GETCUEBANNER should have returned FALSE.\n");
I don't think you need a cast.
- ret = (BOOL)SendMessageW(hwnd_edit, EM_GETCUEBANNER, (WPARAM)testW, (LPARAM)lstrlenW(testcmp1W)+1);
- ok(ret == TRUE ||
broken(ret == FALSE), /* Win XP */
"EM_GETCUEBANNER should have returned TRUE.\n");
This should be a first thing to try, followed by win_skip().