From: Paul Gofman pgofman@codeweavers.com
--- dlls/user32/tests/combo.c | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
diff --git a/dlls/user32/tests/combo.c b/dlls/user32/tests/combo.c index 2fc0d1ad9c0..59c810a0203 100644 --- a/dlls/user32/tests/combo.c +++ b/dlls/user32/tests/combo.c @@ -915,6 +915,53 @@ static void test_combo_ctlcolor(void) DestroyWindow(combo); }
+static void test_combo_setfont(void) +{ + COMBOBOXINFO info; + RECT r1, r2; + HWND combo; + BOOL ret; + HFONT hf; + + hf = CreateFontA( 24, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, + CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Arial" ); + ok( !!hf, "got NULL.\n" ); + + combo = CreateWindowA( "ComboBox", "Combo", WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST, + 5, 5, 200, 200, hMainWnd, (HMENU)COMBO_ID, NULL, 0 ); + info.cbSize = sizeof(COMBOBOXINFO); + ret = GetComboBoxInfo( combo, &info ); + ok( ret, "got error %lu.\n", GetLastError() ); + r1 = info.rcItem; + + SendMessageA( combo, WM_SETFONT, (WPARAM)hf, TRUE ); + + ret = GetComboBoxInfo( combo, &info ); + ok( ret, "got error %lu.\n", GetLastError() ); + r2 = info.rcItem; + ok( memcmp( &r1, &r2, sizeof(r1) ), "got equal rects %s.\n", wine_dbgstr_rect(&r2) ); + + DestroyWindow(combo); + + + combo = CreateWindowA( "ComboBox", "Combo", WS_VISIBLE | WS_CHILD | CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED, + 5, 5, 200, 200, hMainWnd, (HMENU)COMBO_ID, NULL, 0 ); + info.cbSize = sizeof(COMBOBOXINFO); + ret = GetComboBoxInfo( combo, &info ); + ok( ret, "got error %lu.\n", GetLastError() ); + r1 = info.rcItem; + + SendMessageA( combo, WM_SETFONT, (WPARAM)hf, TRUE ); + + ret = GetComboBoxInfo( combo, &info ); + ok( ret, "got error %lu.\n", GetLastError() ); + r2 = info.rcItem; + todo_wine ok( !memcmp( &r1, &r2, sizeof(r1) ), "got %s, expected %s.\n", wine_dbgstr_rect(&r2), wine_dbgstr_rect(&r1) ); + DestroyWindow(combo); + + DeleteObject(hf); +} + START_TEST(combo) { brush_red = CreateSolidBrush(RGB(255, 0, 0)); @@ -938,6 +985,7 @@ START_TEST(combo) test_listbox_styles(CBS_DROPDOWNLIST); test_listbox_size(CBS_DROPDOWN); test_combo_ctlcolor(); + test_combo_setfont();
DestroyWindow(hMainWnd); DeleteObject(brush_red);
From: Paul Gofman pgofman@codeweavers.com
--- dlls/user32/combo.c | 3 ++- dlls/user32/tests/combo.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index 7486385ac37..5f2ddb3dcdf 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -1467,7 +1467,8 @@ static void COMBO_Size( HEADCOMBO *lphc ) static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw ) { lphc->hFont = hFont; - lphc->item_height = combo_get_text_height(lphc); + if (!CB_OWNERDRAWN(lphc)) + lphc->item_height = combo_get_text_height(lphc);
/* * Propagate to owned windows. diff --git a/dlls/user32/tests/combo.c b/dlls/user32/tests/combo.c index 59c810a0203..77dec2382bd 100644 --- a/dlls/user32/tests/combo.c +++ b/dlls/user32/tests/combo.c @@ -956,7 +956,7 @@ static void test_combo_setfont(void) ret = GetComboBoxInfo( combo, &info ); ok( ret, "got error %lu.\n", GetLastError() ); r2 = info.rcItem; - todo_wine ok( !memcmp( &r1, &r2, sizeof(r1) ), "got %s, expected %s.\n", wine_dbgstr_rect(&r2), wine_dbgstr_rect(&r1) ); + ok( !memcmp( &r1, &r2, sizeof(r1) ), "got %s, expected %s.\n", wine_dbgstr_rect(&r2), wine_dbgstr_rect(&r1) ); DestroyWindow(combo);
DeleteObject(hf);
From: Paul Gofman pgofman@codeweavers.com
--- dlls/comctl32/tests/combo.c | 53 +++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 8 deletions(-)
diff --git a/dlls/comctl32/tests/combo.c b/dlls/comctl32/tests/combo.c index 0ba720a03ce..61516fd4aa9 100644 --- a/dlls/comctl32/tests/combo.c +++ b/dlls/comctl32/tests/combo.c @@ -743,17 +743,20 @@ static void test_combo_setitemheight(DWORD style)
static void test_combo_setfont(DWORD style) { + unsigned int expected_height, initial_height; HFONT hFont1, hFont2; HWND hCombo; RECT r; int i;
+ winetest_push_context("style %#lx", style); hCombo = create_combobox(style); hFont1 = CreateFontA(10, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett"); hFont2 = CreateFontA(8, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, SYMBOL_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Marlett");
GetClientRect(hCombo, &r); - expect_rect(r, 0, 0, 100, get_font_height(GetStockObject(SYSTEM_FONT)) + 8); + initial_height = get_font_height(GetStockObject(SYSTEM_FONT)) + 8; + expect_rect(r, 0, 0, 100, initial_height); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); todo_wine expect_rect(r, 5, 5, 105, 105); @@ -766,24 +769,50 @@ static void test_combo_setfont(DWORD style) { SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE); GetClientRect(hCombo, &r); - expect_rect(r, 0, 0, 100, 18); + expected_height = style & CBS_OWNERDRAWFIXED ? initial_height : 18; + todo_wine_if(style & CBS_OWNERDRAWFIXED) expect_rect(r, 0, 0, 100, expected_height); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); - todo_wine expect_rect(r, 5, 5, 105, 105 - (get_font_height(GetStockObject(SYSTEM_FONT)) - get_font_height(hFont1))); + + if (style & CBS_OWNERDRAWFIXED) + { + todo_wine expect_rect(r, 5, 5, 105, 105); + } + else + { + todo_wine expect_rect(r, 5, 5, 105, 105 - (get_font_height(GetStockObject(SYSTEM_FONT)) - get_font_height(hFont1))); + }
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont2, FALSE); GetClientRect(hCombo, &r); - expect_rect(r, 0, 0, 100, 16); + expected_height = style & CBS_OWNERDRAWFIXED ? initial_height : 16; + todo_wine_if(style & CBS_OWNERDRAWFIXED) expect_rect(r, 0, 0, 100, expected_height); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); - todo_wine expect_rect(r, 5, 5, 105, 105 - (get_font_height(GetStockObject(SYSTEM_FONT)) - get_font_height(hFont2))); + + if (style & CBS_OWNERDRAWFIXED) + { + todo_wine expect_rect(r, 5, 5, 105, 105); + } + else + { + todo_wine expect_rect(r, 5, 5, 105, 105 - (get_font_height(GetStockObject(SYSTEM_FONT)) - get_font_height(hFont2))); + }
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE); GetClientRect(hCombo, &r); - expect_rect(r, 0, 0, 100, 18); + expected_height = style & CBS_OWNERDRAWFIXED ? initial_height : 18; + todo_wine_if(style & CBS_OWNERDRAWFIXED) expect_rect(r, 0, 0, 100, expected_height); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); - todo_wine expect_rect(r, 5, 5, 105, 105 - (get_font_height(GetStockObject(SYSTEM_FONT)) - get_font_height(hFont1))); + if (style & CBS_OWNERDRAWFIXED) + { + todo_wine expect_rect(r, 5, 5, 105, 105); + } + else + { + todo_wine expect_rect(r, 5, 5, 105, 105 - (get_font_height(GetStockObject(SYSTEM_FONT)) - get_font_height(hFont1))); + } } else { @@ -798,7 +827,13 @@ static void test_combo_setfont(DWORD style)
SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont, FALSE); GetClientRect(hCombo, &r); - ok((r.bottom - r.top) == (height + 8), "Unexpected client rect height.\n"); + if (style & CBS_OWNERDRAWFIXED) + expected_height = initial_height; + else + expected_height = (height + 8); + todo_wine_if(style & CBS_OWNERDRAWFIXED && initial_height != height + 8) + ok((r.bottom - r.top) == expected_height, "Unexpected client rect height %ld, expected %d.\n", r.bottom - r.top, + expected_height); SendMessageA(hCombo, WM_SETFONT, 0, FALSE); DeleteObject(hFont); } @@ -806,6 +841,7 @@ static void test_combo_setfont(DWORD style) DestroyWindow(hCombo); DeleteObject(hFont1); DeleteObject(hFont2); + winetest_pop_context(); }
static LRESULT (CALLBACK *old_parent_proc)(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); @@ -1691,6 +1727,7 @@ START_TEST(combo) test_combo_WS_VSCROLL(); test_combo_setfont(CBS_DROPDOWN); test_combo_setfont(CBS_DROPDOWNLIST); + test_combo_setfont(CBS_DROPDOWNLIST | CBS_OWNERDRAWFIXED); test_combo_setitemheight(CBS_DROPDOWN); test_combo_setitemheight(CBS_DROPDOWNLIST); test_combo_CBN_SELCHANGE();
From: Paul Gofman pgofman@codeweavers.com
--- dlls/comctl32/combo.c | 3 ++- dlls/comctl32/tests/combo.c | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/comctl32/combo.c b/dlls/comctl32/combo.c index 1094132826b..b85066b6f6d 100644 --- a/dlls/comctl32/combo.c +++ b/dlls/comctl32/combo.c @@ -1439,7 +1439,8 @@ static void COMBO_Size( HEADCOMBO *lphc ) static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw ) { lphc->hFont = hFont; - lphc->item_height = combo_get_text_height(lphc); + if (!CB_OWNERDRAWN(lphc)) + lphc->item_height = combo_get_text_height(lphc);
/* * Propagate to owned windows. diff --git a/dlls/comctl32/tests/combo.c b/dlls/comctl32/tests/combo.c index 61516fd4aa9..5af530ad5be 100644 --- a/dlls/comctl32/tests/combo.c +++ b/dlls/comctl32/tests/combo.c @@ -770,7 +770,7 @@ static void test_combo_setfont(DWORD style) SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE); GetClientRect(hCombo, &r); expected_height = style & CBS_OWNERDRAWFIXED ? initial_height : 18; - todo_wine_if(style & CBS_OWNERDRAWFIXED) expect_rect(r, 0, 0, 100, expected_height); + expect_rect(r, 0, 0, 100, expected_height); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
@@ -786,7 +786,7 @@ static void test_combo_setfont(DWORD style) SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont2, FALSE); GetClientRect(hCombo, &r); expected_height = style & CBS_OWNERDRAWFIXED ? initial_height : 16; - todo_wine_if(style & CBS_OWNERDRAWFIXED) expect_rect(r, 0, 0, 100, expected_height); + expect_rect(r, 0, 0, 100, expected_height); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2);
@@ -802,7 +802,7 @@ static void test_combo_setfont(DWORD style) SendMessageA(hCombo, WM_SETFONT, (WPARAM)hFont1, FALSE); GetClientRect(hCombo, &r); expected_height = style & CBS_OWNERDRAWFIXED ? initial_height : 18; - todo_wine_if(style & CBS_OWNERDRAWFIXED) expect_rect(r, 0, 0, 100, expected_height); + expect_rect(r, 0, 0, 100, expected_height); SendMessageA(hCombo, CB_GETDROPPEDCONTROLRECT, 0, (LPARAM)&r); MapWindowPoints(HWND_DESKTOP, hMainWnd, (LPPOINT)&r, 2); if (style & CBS_OWNERDRAWFIXED) @@ -831,7 +831,6 @@ static void test_combo_setfont(DWORD style) expected_height = initial_height; else expected_height = (height + 8); - todo_wine_if(style & CBS_OWNERDRAWFIXED && initial_height != height + 8) ok((r.bottom - r.top) == expected_height, "Unexpected client rect height %ld, expected %d.\n", r.bottom - r.top, expected_height); SendMessageA(hCombo, WM_SETFONT, 0, FALSE);
Helps Black Squad launcher which otherwise gets broken language selection combo box.