comctl32/tab: Implement TCM_REMOVEIMAGE.

This commit is contained in:
Nikolay Sivov 2009-03-23 15:45:44 -04:00 committed by Alexandre Julliard
parent e9ef9911d0
commit 4585148547
2 changed files with 96 additions and 3 deletions

View File

@ -53,7 +53,6 @@
* TCN_KEYDOWN
*
* Messages:
* TCM_REMOVEIMAGE
* TCM_DESELECTALL
* TCM_GETEXTENDEDSTYLE
* TCM_SETEXTENDEDSTYLE
@ -3099,6 +3098,37 @@ TAB_SetItemExtra (TAB_INFO *infoPtr, INT cbInfo)
return TRUE;
}
static LRESULT TAB_RemoveImage (TAB_INFO *infoPtr, INT image)
{
if (!infoPtr)
return 0;
if (ImageList_Remove (infoPtr->himl, image))
{
INT i, *idx;
RECT r;
/* shift indices, repaint items if needed */
for (i = 0; i < infoPtr->uNumItem; i++)
{
idx = &infoPtr->items[i].iImage;
if (*idx >= image)
{
if (*idx == image)
*idx = -1;
else
(*idx)--;
/* repaint item */
if (TAB_InternalGetItemRect (infoPtr, i, &r, NULL))
InvalidateRect (infoPtr->hwnd, &r, TRUE);
}
}
}
return 0;
}
static LRESULT WINAPI
TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@ -3159,8 +3189,7 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return TAB_SetItemSize (infoPtr, lParam);
case TCM_REMOVEIMAGE:
FIXME("Unimplemented msg TCM_REMOVEIMAGE\n");
return 0;
return TAB_RemoveImage (infoPtr, wParam);
case TCM_SETPADDING:
return TAB_SetPadding (infoPtr, lParam);

View File

@ -984,6 +984,69 @@ static void test_delete_focus(HWND parent_wnd)
DestroyWindow(hTab);
}
static void test_removeimage(HWND parent_wnd)
{
static const BYTE bits[32];
HWND hwTab;
INT i;
TCITEM item;
HICON hicon;
HIMAGELIST himl = ImageList_Create(16, 16, ILC_COLOR, 3, 4);
hicon = CreateIcon(NULL, 16, 16, 1, 1, bits, bits);
ImageList_AddIcon(himl, hicon);
ImageList_AddIcon(himl, hicon);
ImageList_AddIcon(himl, hicon);
hwTab = create_tabcontrol(TCS_FIXEDWIDTH, TCIF_TEXT|TCIF_IMAGE);
SendMessage(hwTab, TCM_SETIMAGELIST, 0, (LPARAM)himl);
memset(&item, 0, sizeof(TCITEM));
item.mask = TCIF_IMAGE;
for(i = 0; i < 3; i++) {
SendMessage(hwTab, TCM_GETITEM, i, (LPARAM)&item);
expect(i, item.iImage);
}
/* remove image middle image */
SendMessage(hwTab, TCM_REMOVEIMAGE, 1, 0);
expect(2, ImageList_GetImageCount(himl));
item.iImage = -1;
SendMessage(hwTab, TCM_GETITEM, 0, (LPARAM)&item);
expect(0, item.iImage);
item.iImage = 0;
SendMessage(hwTab, TCM_GETITEM, 1, (LPARAM)&item);
expect(-1, item.iImage);
item.iImage = 0;
SendMessage(hwTab, TCM_GETITEM, 2, (LPARAM)&item);
expect(1, item.iImage);
/* remove first image */
SendMessage(hwTab, TCM_REMOVEIMAGE, 0, 0);
expect(1, ImageList_GetImageCount(himl));
item.iImage = 0;
SendMessage(hwTab, TCM_GETITEM, 0, (LPARAM)&item);
expect(-1, item.iImage);
item.iImage = 0;
SendMessage(hwTab, TCM_GETITEM, 1, (LPARAM)&item);
expect(-1, item.iImage);
item.iImage = -1;
SendMessage(hwTab, TCM_GETITEM, 2, (LPARAM)&item);
expect(0, item.iImage);
/* remove the last one */
SendMessage(hwTab, TCM_REMOVEIMAGE, 0, 0);
expect(0, ImageList_GetImageCount(himl));
for(i = 0; i < 3; i++) {
item.iImage = 0;
SendMessage(hwTab, TCM_GETITEM, i, (LPARAM)&item);
expect(-1, item.iImage);
}
DestroyWindow(hwTab);
ImageList_Destroy(himl);
DestroyIcon(hicon);
}
START_TEST(tab)
{
HWND parent_wnd;
@ -1021,6 +1084,7 @@ START_TEST(tab)
test_insert_focus(parent_wnd);
test_delete_focus(parent_wnd);
test_removeimage(parent_wnd);
DestroyWindow(parent_wnd);
}