Huw Davies : user32: Invalidate the listbox in LB_SETCOUNT.
Alexandre Julliard
julliard at winehq.org
Thu Mar 28 15:30:23 CDT 2013
Module: wine
Branch: master
Commit: 698c7f0f3f8fa1d0ed33c629fa9e93279085d39d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=698c7f0f3f8fa1d0ed33c629fa9e93279085d39d
Author: Huw Davies <huw at codeweavers.com>
Date: Thu Mar 28 10:21:22 2013 +0000
user32: Invalidate the listbox in LB_SETCOUNT.
---
dlls/user32/listbox.c | 2 +
dlls/user32/tests/listbox.c | 78 ++++++++++++++++++++++++++++++++++--------
2 files changed, 65 insertions(+), 15 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c
index 0f4a8be..64691e4 100644
--- a/dlls/user32/listbox.c
+++ b/dlls/user32/listbox.c
@@ -1767,6 +1767,8 @@ static LRESULT LISTBOX_SetCount( LB_DESCR *descr, INT count )
if ((ret = LISTBOX_RemoveItem( descr, (descr->nb_items - 1) )) < 0)
return ret;
}
+
+ InvalidateRect( descr->self, NULL, TRUE );
return LB_OKAY;
}
diff --git a/dlls/user32/tests/listbox.c b/dlls/user32/tests/listbox.c
index ef4a35b..5d96f5c 100644
--- a/dlls/user32/tests/listbox.c
+++ b/dlls/user32/tests/listbox.c
@@ -274,30 +274,42 @@ static LRESULT WINAPI main_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
return DefWindowProc(hwnd, msg, wparam, lparam);
}
-static void test_ownerdraw(void)
+static HWND create_parent( void )
{
WNDCLASS cls;
- HWND parent, hLB;
- INT ret;
- RECT rc;
+ HWND parent;
+ static ATOM class;
- cls.style = 0;
- cls.lpfnWndProc = main_window_proc;
- cls.cbClsExtra = 0;
- cls.cbWndExtra = 0;
- cls.hInstance = GetModuleHandle(0);
- cls.hIcon = 0;
- cls.hCursor = LoadCursor(0, IDC_ARROW);
- cls.hbrBackground = GetStockObject(WHITE_BRUSH);
- cls.lpszMenuName = NULL;
- cls.lpszClassName = "main_window_class";
- ok (RegisterClass(&cls), "RegisterClass failed\n");
+ if (!class)
+ {
+ cls.style = 0;
+ cls.lpfnWndProc = main_window_proc;
+ cls.cbClsExtra = 0;
+ cls.cbWndExtra = 0;
+ cls.hInstance = GetModuleHandle(0);
+ cls.hIcon = 0;
+ cls.hCursor = LoadCursor(0, IDC_ARROW);
+ cls.hbrBackground = GetStockObject(WHITE_BRUSH);
+ cls.lpszMenuName = NULL;
+ cls.lpszClassName = "main_window_class";
+ class = RegisterClass( &cls );
+ }
parent = CreateWindowEx(0, "main_window_class", NULL,
WS_POPUP | WS_VISIBLE,
100, 100, 400, 400,
GetDesktopWindow(), 0,
GetModuleHandle(0), NULL);
+ return parent;
+}
+
+static void test_ownerdraw(void)
+{
+ HWND parent, hLB;
+ INT ret;
+ RECT rc;
+
+ parent = create_parent();
assert(parent);
hLB = create_listbox(LBS_OWNERDRAWFIXED | WS_CHILD | WS_VISIBLE, parent);
@@ -1498,6 +1510,41 @@ static void test_listbox_dlgdir(void)
DestroyWindow(hWnd);
}
+static void test_set_count( void )
+{
+ HWND parent, listbox;
+ LONG ret;
+ RECT r;
+
+ parent = create_parent();
+ listbox = create_listbox( LBS_OWNERDRAWFIXED | LBS_NODATA | WS_CHILD | WS_VISIBLE, parent );
+
+ UpdateWindow( listbox );
+ GetUpdateRect( listbox, &r, TRUE );
+ ok( IsRectEmpty( &r ), "got non-empty rect\n");
+
+ ret = SendMessage( listbox, LB_SETCOUNT, 100, 0 );
+ ok( ret == 0, "got %d\n", ret );
+ ret = SendMessage( listbox, LB_GETCOUNT, 0, 0 );
+ ok( ret == 100, "got %d\n", ret );
+
+ GetUpdateRect( listbox, &r, TRUE );
+ ok( !IsRectEmpty( &r ), "got empty rect\n");
+
+ ValidateRect( listbox, NULL );
+ GetUpdateRect( listbox, &r, TRUE );
+ ok( IsRectEmpty( &r ), "got non-empty rect\n");
+
+ ret = SendMessage( listbox, LB_SETCOUNT, 99, 0 );
+ ok( ret == 0, "got %d\n", ret );
+
+ GetUpdateRect( listbox, &r, TRUE );
+ ok( !IsRectEmpty( &r ), "got empty rect\n");
+
+ DestroyWindow( listbox );
+ DestroyWindow( parent );
+}
+
START_TEST(listbox)
{
const struct listbox_test SS =
@@ -1576,4 +1623,5 @@ START_TEST(listbox)
test_listbox_item_data();
test_listbox_LB_DIR();
test_listbox_dlgdir();
+ test_set_count();
}
More information about the wine-cvs
mailing list