Rein Klazes : comctl32: Fix for owner draw statusbar.
Alexandre Julliard
julliard at winehq.org
Mon Feb 16 09:35:43 CST 2009
Module: wine
Branch: master
Commit: da257e33011badf0a929dee03dd8390d1b439794
URL: http://source.winehq.org/git/wine.git/?a=commit;h=da257e33011badf0a929dee03dd8390d1b439794
Author: Rein Klazes <wijn at online.nl>
Date: Sun Feb 15 14:27:55 2009 +0100
comctl32: Fix for owner draw statusbar.
Ownerdraw status bar should update on receiveing a SB_SETTEXT message,
even if the 'text' parameter has not changed. Fix with conformance
test.
---
dlls/comctl32/status.c | 2 -
dlls/comctl32/tests/status.c | 50 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/dlls/comctl32/status.c b/dlls/comctl32/status.c
index 35d3bd4..a56c2a0 100644
--- a/dlls/comctl32/status.c
+++ b/dlls/comctl32/status.c
@@ -759,8 +759,6 @@ STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style,
if (style & SBT_OWNERDRAW) {
if (!(oldStyle & SBT_OWNERDRAW))
Free (part->text);
- else if (part->text == text)
- return TRUE;
part->text = (LPWSTR)text;
} else {
LPWSTR ntext;
diff --git a/dlls/comctl32/tests/status.c b/dlls/comctl32/tests/status.c
index 4fe6249..4ae663f 100644
--- a/dlls/comctl32/tests/status.c
+++ b/dlls/comctl32/tests/status.c
@@ -42,6 +42,8 @@ static HWND g_hMainWnd;
static int g_wmsize_count = 0;
static DWORD g_ysize;
static DWORD g_dpisize;
+static int g_wmdrawitm_ctr;
+static WNDPROC g_wndproc_saved;
static HWND create_status_control(DWORD style, DWORD exstyle)
{
@@ -407,6 +409,53 @@ static void test_status_control(void)
DestroyWindow(hWndStatus);
}
+static LRESULT WINAPI ownerdraw_test_wndproc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT ret;
+ if (msg == WM_DRAWITEM)
+ g_wmdrawitm_ctr++;
+ ret = CallWindowProc(g_wndproc_saved, hwnd, msg, wParam, lParam);
+ return ret;
+}
+
+static void test_status_ownerdraw(void)
+{
+ HWND hWndStatus;
+ int r;
+ const char* statustext = "STATUS TEXT";
+ LONG oldstyle;
+
+ /* subclass the main window and make sure it is visible */
+ g_wndproc_saved = (WNDPROC) SetWindowLongPtr( g_hMainWnd, GWLP_WNDPROC,
+ (LONG_PTR)ownerdraw_test_wndproc );
+ ok( g_wndproc_saved != 0, "failed to set the WndProc\n");
+ SetWindowPos( g_hMainWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
+ oldstyle = GetWindowLong( g_hMainWnd, GWL_STYLE);
+ SetWindowLong( g_hMainWnd, GWL_STYLE, oldstyle | WS_VISIBLE);
+ /* create a status child window */
+ ok((hWndStatus = CreateWindowA(SUBCLASS_NAME, "", WS_CHILD|WS_VISIBLE, 0, 0, 100, 100,
+ g_hMainWnd, NULL, NULL, 0)) != NULL, "CreateWindowA failed\n");
+ /* set text */
+ g_wmdrawitm_ctr = 0;
+ r = SendMessage(hWndStatus, SB_SETTEXT, 0, (LPARAM)statustext);
+ ok( r == TRUE, "Sendmessage returned %d, expected 1\n", r);
+ ok( 0 == g_wmdrawitm_ctr, "got %d drawitem messages expected none\n", g_wmdrawitm_ctr);
+ /* set same text, with ownerdraw flag */
+ g_wmdrawitm_ctr = 0;
+ r = SendMessage(hWndStatus, SB_SETTEXT, SBT_OWNERDRAW, (LPARAM)statustext);
+ ok( r == TRUE, "Sendmessage returned %d, expected 1\n", r);
+ ok( 1 == g_wmdrawitm_ctr, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr);
+ /* ;and again */
+ g_wmdrawitm_ctr = 0;
+ r = SendMessage(hWndStatus, SB_SETTEXT, SBT_OWNERDRAW, (LPARAM)statustext);
+ ok( r == TRUE, "Sendmessage returned %d, expected 1\n", r);
+ ok( 1 == g_wmdrawitm_ctr, "got %d drawitem messages expected 1\n", g_wmdrawitm_ctr);
+ /* clean up */
+ DestroyWindow(hWndStatus);
+ SetWindowLong( g_hMainWnd, GWL_STYLE, oldstyle);
+ SetWindowLongPtr( g_hMainWnd, GWLP_WNDPROC, (LONG_PTR)g_wndproc_saved );
+}
+
START_TEST(status)
{
hinst = GetModuleHandleA(NULL);
@@ -423,4 +472,5 @@ START_TEST(status)
test_status_control();
test_create();
test_height();
+ test_status_ownerdraw();
}
More information about the wine-cvs
mailing list