user32: Invalidate the listbox in LB_SETCOUNT.

This commit is contained in:
Huw Davies 2013-03-28 10:21:22 +00:00 committed by Alexandre Julliard
parent 5bfc411ae7
commit 698c7f0f3f
2 changed files with 65 additions and 15 deletions

View File

@ -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;
}

View File

@ -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();
}