ImageList_Merge should not fail if indices are bad.
Add tests for this case, a visible test mode and fix DrawIndirect test under some native comctl32.dll's.
This commit is contained in:
parent
0fa33cad49
commit
ce0fbb5b28
|
@ -587,7 +587,7 @@ ImageList_Create (INT cx, INT cy, UINT flags,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Default to ILC_COLOR4 if non of the ILC_COLOR* flags are specified */
|
||||
/* Default to ILC_COLOR4 if none of the ILC_COLOR* flags are specified */
|
||||
if (ilc == ILC_COLOR)
|
||||
ilc = ILC_COLOR4;
|
||||
|
||||
|
@ -1719,8 +1719,7 @@ ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow,
|
|||
/*************************************************************************
|
||||
* ImageList_Merge [COMCTL32.@]
|
||||
*
|
||||
* Creates a new image list that contains a merged image from the specified
|
||||
* images of both source image lists.
|
||||
* Create an image list containing a merged image from two image lists.
|
||||
*
|
||||
* PARAMS
|
||||
* himl1 [I] handle to first image list
|
||||
|
@ -1731,10 +1730,16 @@ ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow,
|
|||
* dy [I] Y offset of the second image relative to the first.
|
||||
*
|
||||
* RETURNS
|
||||
* Success: handle of the merged image list.
|
||||
* Failure: NULL
|
||||
* Success: The newly created image list. It contains a single image
|
||||
* consisting of the second image merged with the first.
|
||||
* Failure: NULL, if either himl1 or himl2 are invalid.
|
||||
*
|
||||
* NOTES
|
||||
* - The returned image list should be deleted by the caller using
|
||||
* ImageList_Destroy() when it is no longer required.
|
||||
* - If either i1 or i2 are not valid image indices they will be treated
|
||||
* as a blank image.
|
||||
*/
|
||||
|
||||
HIMAGELIST WINAPI
|
||||
ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2,
|
||||
INT dx, INT dy)
|
||||
|
@ -1750,17 +1755,6 @@ ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2,
|
|||
if (!is_valid(himl1) || !is_valid(himl2))
|
||||
return NULL;
|
||||
|
||||
/* check indices */
|
||||
if ((i1 < 0) || (i1 >= himl1->cCurImage)) {
|
||||
ERR("Index 1 out of range! %d\n", i1);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((i2 < 0) || (i2 >= himl2->cCurImage)) {
|
||||
ERR("Index 2 out of range! %d\n", i2);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dx > 0) {
|
||||
cxDst = max (himl1->cx, dx + himl2->cx);
|
||||
xOff1 = 0;
|
||||
|
@ -1794,23 +1788,28 @@ ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2,
|
|||
}
|
||||
|
||||
himlDst = ImageList_Create (cxDst, cyDst, ILC_MASK | ILC_COLOR, 1, 1);
|
||||
if (!himlDst)
|
||||
return NULL;
|
||||
|
||||
if (himlDst) {
|
||||
if (himlDst)
|
||||
{
|
||||
nX1 = i1 * himl1->cx;
|
||||
nX2 = i2 * himl2->cx;
|
||||
|
||||
/* copy image */
|
||||
BitBlt (himlDst->hdcImage, 0, 0, cxDst, cyDst, himl1->hdcImage, 0, 0, BLACKNESS);
|
||||
BitBlt (himlDst->hdcImage, xOff1, yOff1, himl1->cx, himl1->cy, himl1->hdcImage, nX1, 0, SRCCOPY);
|
||||
BitBlt (himlDst->hdcImage, xOff2, yOff2, himl2->cx, himl2->cy, himl2->hdcMask , nX2, 0, SRCAND);
|
||||
BitBlt (himlDst->hdcImage, xOff2, yOff2, himl2->cx, himl2->cy, himl2->hdcImage, nX2, 0, SRCPAINT);
|
||||
BitBlt (himlDst->hdcImage, 0, 0, cxDst, cyDst, himl1->hdcImage, 0, 0, BLACKNESS);
|
||||
if (i1 >= 0 && i1 < himl1->cCurImage)
|
||||
BitBlt (himlDst->hdcImage, xOff1, yOff1, himl1->cx, himl1->cy, himl1->hdcImage, nX1, 0, SRCCOPY);
|
||||
if (i2 >= 0 && i2 < himl2->cCurImage)
|
||||
{
|
||||
BitBlt (himlDst->hdcImage, xOff2, yOff2, himl2->cx, himl2->cy, himl2->hdcMask , nX2, 0, SRCAND);
|
||||
BitBlt (himlDst->hdcImage, xOff2, yOff2, himl2->cx, himl2->cy, himl2->hdcImage, nX2, 0, SRCPAINT);
|
||||
}
|
||||
|
||||
/* copy mask */
|
||||
BitBlt (himlDst->hdcMask, 0, 0, cxDst, cyDst, himl1->hdcMask, 0, 0, WHITENESS);
|
||||
BitBlt (himlDst->hdcMask, xOff1, yOff1, himl1->cx, himl1->cy, himl1->hdcMask, nX1, 0, SRCCOPY);
|
||||
BitBlt (himlDst->hdcMask, xOff2, yOff2, himl2->cx, himl2->cy, himl2->hdcMask, nX2, 0, SRCAND);
|
||||
BitBlt (himlDst->hdcMask, 0, 0, cxDst, cyDst, himl1->hdcMask, 0, 0, WHITENESS);
|
||||
if (i1 >= 0 && i1 < himl1->cCurImage)
|
||||
BitBlt (himlDst->hdcMask, xOff1, yOff1, himl1->cx, himl1->cy, himl1->hdcMask, nX1, 0, SRCCOPY);
|
||||
if (i2 >= 0 && i2 < himl2->cCurImage)
|
||||
BitBlt (himlDst->hdcMask, xOff2, yOff2, himl2->cx, himl2->cy, himl2->hdcMask, nX2, 0, SRCAND);
|
||||
|
||||
himlDst->cCurImage = 1;
|
||||
}
|
||||
|
@ -2250,7 +2249,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
|
|||
ICONINFO ii;
|
||||
BITMAP bmp;
|
||||
|
||||
TRACE("(0x%lx 0x%x %p)\n", (DWORD)himl, i, hIcon);
|
||||
TRACE("(%p %d %p)\n", himl, i, hIcon);
|
||||
|
||||
if (!is_valid(himl))
|
||||
return -1;
|
||||
|
@ -2308,6 +2307,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
|
|||
if (ii.hbmMask)
|
||||
DeleteObject (ii.hbmMask);
|
||||
|
||||
TRACE("Insert index = %d, himl->cCurImage = %d\n", nIndex, himl->cCurImage);
|
||||
return nIndex;
|
||||
}
|
||||
|
||||
|
@ -2853,6 +2853,6 @@ static HBITMAP ImageList_CreateImage(HDC hdc, HIMAGELIST himl, UINT width, UINT
|
|||
|
||||
hbmNewBitmap = CreateBitmap (width, height, 1, himl->uBitsPixel, NULL);
|
||||
}
|
||||
|
||||
TRACE("returning %p\n", hbmNewBitmap);
|
||||
return hbmNewBitmap;
|
||||
}
|
||||
|
|
|
@ -21,28 +21,199 @@
|
|||
#include <assert.h>
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
#undef VISIBLE
|
||||
|
||||
#ifdef VISIBLE
|
||||
#define WAIT Sleep (1000)
|
||||
#define REDRAW(hwnd) RedrawWindow (hwnd, NULL, 0, RDW_UPDATENOW)
|
||||
#else
|
||||
#define WAIT
|
||||
#define REDRAW(hwnd)
|
||||
#endif
|
||||
|
||||
|
||||
static BOOL (WINAPI *pImageList_DrawIndirect)(IMAGELISTDRAWPARAMS*) = NULL;
|
||||
|
||||
static HDC desktopDC;
|
||||
static HINSTANCE hinst;
|
||||
|
||||
/* These macros build cursor/bitmap data in 4x4 pixel blocks */
|
||||
#define B(x,y) ((x?0xf0:0)|(y?0xf:0))
|
||||
#define ROW1(a,b,c,d,e,f,g,h) B(a,b),B(c,d),B(e,f),B(g,h)
|
||||
#define ROW32(a,b,c,d,e,f,g,h) ROW1(a,b,c,d,e,f,g,h), ROW1(a,b,c,d,e,f,g,h), \
|
||||
ROW1(a,b,c,d,e,f,g,h), ROW1(a,b,c,d,e,f,g,h)
|
||||
#define ROW2(a,b,c,d,e,f,g,h,i,j,k,l) ROW1(a,b,c,d,e,f,g,h),B(i,j),B(k,l)
|
||||
#define ROW48(a,b,c,d,e,f,g,h,i,j,k,l) ROW2(a,b,c,d,e,f,g,h,i,j,k,l), \
|
||||
ROW2(a,b,c,d,e,f,g,h,i,j,k,l), ROW2(a,b,c,d,e,f,g,h,i,j,k,l), \
|
||||
ROW2(a,b,c,d,e,f,g,h,i,j,k,l)
|
||||
|
||||
static const BYTE empty_bits[48*48/8];
|
||||
|
||||
static const BYTE icon_bits[32*32/8] =
|
||||
{
|
||||
ROW32(0,0,0,0,0,0,0,0),
|
||||
ROW32(0,0,1,1,1,1,0,0),
|
||||
ROW32(0,1,1,1,1,1,1,0),
|
||||
ROW32(0,1,1,0,0,1,1,0),
|
||||
ROW32(0,1,1,0,0,1,1,0),
|
||||
ROW32(0,1,1,1,1,1,1,0),
|
||||
ROW32(0,0,1,1,1,1,0,0),
|
||||
ROW32(0,0,0,0,0,0,0,0)
|
||||
};
|
||||
|
||||
static const BYTE bitmap_bits[48*48/8] =
|
||||
{
|
||||
ROW48(0,0,0,0,0,0,0,0,0,0,0,0),
|
||||
ROW48(0,1,1,1,1,1,1,1,1,1,1,0),
|
||||
ROW48(0,1,1,0,0,0,0,0,0,1,1,0),
|
||||
ROW48(0,1,0,0,0,0,0,0,1,0,1,0),
|
||||
ROW48(0,1,0,0,0,0,0,1,0,0,1,0),
|
||||
ROW48(0,1,0,0,0,0,1,0,0,0,1,0),
|
||||
ROW48(0,1,0,0,0,1,0,0,0,0,1,0),
|
||||
ROW48(0,1,0,0,1,0,0,0,0,0,1,0),
|
||||
ROW48(0,1,0,1,0,0,0,0,0,0,1,0),
|
||||
ROW48(0,1,1,0,0,0,0,0,0,1,1,0),
|
||||
ROW48(0,1,1,1,1,1,1,1,1,1,1,0),
|
||||
ROW48(0,0,0,0,0,0,0,0,0,0,0,0)
|
||||
};
|
||||
|
||||
static HIMAGELIST createImageList(cx, cy)
|
||||
{
|
||||
/* Create an ImageList and put an image into it */
|
||||
HDC hdc = CreateCompatibleDC(desktopDC);
|
||||
HIMAGELIST himl = ImageList_Create(cx, cy, ILC_COLOR, 1, 1);
|
||||
HBITMAP hbm = CreateCompatibleBitmap(hdc, cx, cy);
|
||||
|
||||
SelectObject(hdc, hbm);
|
||||
HBITMAP hbm = CreateBitmap(48, 48, 1, 1, bitmap_bits);
|
||||
ImageList_Add(himl, hbm, NULL);
|
||||
DeleteObject(hbm);
|
||||
DeleteDC(hdc);
|
||||
|
||||
return himl;
|
||||
}
|
||||
|
||||
static HWND create_a_window(void)
|
||||
{
|
||||
char className[] = "bmwnd";
|
||||
char winName[] = "Test Bitmap";
|
||||
HWND hWnd;
|
||||
static int registered = 0;
|
||||
|
||||
if (!registered)
|
||||
{
|
||||
WNDCLASSA cls;
|
||||
|
||||
cls.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
|
||||
cls.lpfnWndProc = DefWindowProcA;
|
||||
cls.cbClsExtra = 0;
|
||||
cls.cbWndExtra = 0;
|
||||
cls.hInstance = 0;
|
||||
cls.hIcon = LoadIconA (0, (LPSTR)IDI_APPLICATION);
|
||||
cls.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW);
|
||||
cls.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
|
||||
cls.lpszMenuName = 0;
|
||||
cls.lpszClassName = className;
|
||||
|
||||
RegisterClassA (&cls);
|
||||
registered = 1;
|
||||
}
|
||||
|
||||
/* Setup window */
|
||||
hWnd = CreateWindowA (className, winName,
|
||||
WS_OVERLAPPEDWINDOW ,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 300, 300, 0,
|
||||
0, hinst, 0);
|
||||
|
||||
#ifdef VISIBLE
|
||||
ShowWindow (hWnd, SW_SHOW);
|
||||
#endif
|
||||
REDRAW(hWnd);
|
||||
WAIT;
|
||||
|
||||
return hWnd;
|
||||
}
|
||||
|
||||
static HDC show_image(HWND hwnd, HIMAGELIST himl, int idx, int size,
|
||||
LPCSTR loc, BOOL clear)
|
||||
{
|
||||
HDC hdc = NULL;
|
||||
#ifdef VISIBLE
|
||||
if (!himl) return NULL;
|
||||
|
||||
SetWindowText(hwnd, loc);
|
||||
hdc = GetDC(hwnd);
|
||||
ImageList_Draw(himl, idx, hdc, 0, 0, ILD_TRANSPARENT);
|
||||
|
||||
REDRAW(hwnd);
|
||||
WAIT;
|
||||
|
||||
if (clear)
|
||||
{
|
||||
BitBlt(hdc, 0, 0, size, size, hdc, size+1, size+1, SRCCOPY);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
hdc = NULL;
|
||||
}
|
||||
#endif /* VISIBLE */
|
||||
return hdc;
|
||||
}
|
||||
|
||||
/* Useful for checking differences */
|
||||
static void dump_bits(const BYTE *p, const BYTE *q, int size)
|
||||
{
|
||||
#if 0
|
||||
int i, j;
|
||||
|
||||
size /= 8;
|
||||
|
||||
for (i = 0; i < size * 2; i++)
|
||||
{
|
||||
printf("|");
|
||||
for (j = 0; j < size; j++)
|
||||
printf("%c%c", p[j] & 0xf0 ? 'X' : ' ', p[j] & 0xf ? 'X' : ' ');
|
||||
printf(" -- ");
|
||||
for (j = 0; j < size; j++)
|
||||
printf("%c%c", q[j] & 0xf0 ? 'X' : ' ', q[j] & 0xf ? 'X' : ' ');
|
||||
printf("|\n");
|
||||
p += size * 4;
|
||||
q += size * 4;
|
||||
}
|
||||
printf("\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
static void check_bits(HWND hwnd, HIMAGELIST himl, int idx, int size,
|
||||
const BYTE *checkbits, LPCSTR loc)
|
||||
{
|
||||
#ifdef VISIBLE
|
||||
BYTE bits[100*100/8];
|
||||
COLORREF c;
|
||||
HDC hdc;
|
||||
int x, y, i = -1;
|
||||
|
||||
if (!himl) return;
|
||||
|
||||
memset(bits, 0, sizeof(bits));
|
||||
hdc = show_image(hwnd, himl, idx, size, loc, FALSE);
|
||||
|
||||
c = GetPixel(hdc, 0, 0);
|
||||
|
||||
for (y = 0; y < size; y ++)
|
||||
{
|
||||
for (x = 0; x < size; x++)
|
||||
{
|
||||
if (!(x & 0x7)) i++;
|
||||
if (GetPixel(hdc, x, y) != c) bits[i] |= (0x80 >> (x & 0x7));
|
||||
}
|
||||
}
|
||||
|
||||
BitBlt(hdc, 0, 0, size, size, hdc, size+1, size+1, SRCCOPY);
|
||||
ReleaseDC(hwnd, hdc);
|
||||
|
||||
ok (memcmp(bits, checkbits, (size * size)/8) == 0,
|
||||
"%s: bits different\n", loc);
|
||||
if (memcmp(bits, checkbits, (size * size)/8))
|
||||
dump_bits(bits, checkbits, size);
|
||||
#endif /* VISIBLE */
|
||||
}
|
||||
|
||||
static void testHotspot (void)
|
||||
{
|
||||
struct hotspot {
|
||||
|
@ -64,6 +235,8 @@ static void testHotspot (void)
|
|||
int i, j, ret;
|
||||
HIMAGELIST himl1 = createImageList(SIZEX1, SIZEY1);
|
||||
HIMAGELIST himl2 = createImageList(SIZEX2, SIZEY2);
|
||||
HWND hwnd = create_a_window();
|
||||
|
||||
|
||||
for (i = 0; i < HOTSPOTS_MAX; i++) {
|
||||
for (j = 0; j < HOTSPOTS_MAX; j++) {
|
||||
|
@ -72,15 +245,22 @@ static void testHotspot (void)
|
|||
int dx2 = hotspots[j].dx;
|
||||
int dy2 = hotspots[j].dy;
|
||||
int correctx, correcty, newx, newy;
|
||||
char loc[256];
|
||||
HIMAGELIST himlNew;
|
||||
POINT ppt;
|
||||
|
||||
ret = ImageList_BeginDrag(himl1, 0, dx1, dy1);
|
||||
ok(ret != 0, "BeginDrag failed for { %d, %d }\n", dx1, dy1);
|
||||
sprintf(loc, "BeginDrag (%d,%d)\n", i, j);
|
||||
show_image(hwnd, himl1, 0, max(SIZEX1, SIZEY1), loc, TRUE);
|
||||
|
||||
/* check merging the dragged image with a second image */
|
||||
ret = ImageList_SetDragCursorImage(himl2, 0, dx2, dy2);
|
||||
ok(ret != 0, "SetDragCursorImage failed for {%d, %d}{%d, %d}\n",
|
||||
dx1, dy1, dx2, dy2);
|
||||
sprintf(loc, "SetDragCursorImage (%d,%d)\n", i, j);
|
||||
show_image(hwnd, himl2, 0, max(SIZEX2, SIZEY2), loc, TRUE);
|
||||
|
||||
/* check new hotspot, it should be the same like the old one */
|
||||
himlNew = ImageList_GetDragImage(NULL, &ppt);
|
||||
ok(ppt.x == dx1 && ppt.y == dy1,
|
||||
|
@ -93,6 +273,8 @@ static void testHotspot (void)
|
|||
ok(newx == correctx && newy == correcty,
|
||||
"Expected drag image size [%d,%d] got [%d,%d]\n",
|
||||
correctx, correcty, newx, newy);
|
||||
sprintf(loc, "GetDragImage (%d,%d)\n", i, j);
|
||||
show_image(hwnd, himlNew, 0, max(correctx, correcty), loc, TRUE);
|
||||
ImageList_EndDrag();
|
||||
}
|
||||
}
|
||||
|
@ -101,13 +283,9 @@ static void testHotspot (void)
|
|||
#undef SIZEX2
|
||||
#undef SIZEY2
|
||||
#undef HOTSPOTS_MAX
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
static HINSTANCE hinst;
|
||||
|
||||
static const BYTE icon_bits[32*32/8];
|
||||
static const BYTE bitmap_bits[48*48/8];
|
||||
|
||||
static BOOL DoTest1(void)
|
||||
{
|
||||
HIMAGELIST himl ;
|
||||
|
@ -180,9 +358,6 @@ static BOOL DoTest2(void)
|
|||
hicon3 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
||||
ok(hicon3 != 0, "no hicon3\n");
|
||||
|
||||
/* remove when nothing exists */
|
||||
ok(!ImageList_Remove(himl,0),"removed non-existent icon\n");
|
||||
|
||||
/* add three */
|
||||
ok(0==ImageList_AddIcon(himl, hicon1),"failed to add icon1\n");
|
||||
ok(1==ImageList_AddIcon(himl, hicon2),"failed to add icon2\n");
|
||||
|
@ -199,42 +374,13 @@ static BOOL DoTest2(void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static HWND create_a_window(void)
|
||||
{
|
||||
WNDCLASSA cls;
|
||||
char className[] = "bmwnd";
|
||||
char winName[] = "Test Bitmap";
|
||||
HWND hWnd;
|
||||
|
||||
cls.style = CS_HREDRAW | CS_VREDRAW | CS_GLOBALCLASS;
|
||||
cls.lpfnWndProc = DefWindowProcA;
|
||||
cls.cbClsExtra = 0;
|
||||
cls.cbWndExtra = 0;
|
||||
cls.hInstance = 0;
|
||||
cls.hIcon = LoadIconA (0, (LPSTR)IDI_APPLICATION);
|
||||
cls.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW);
|
||||
cls.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
|
||||
cls.lpszMenuName = 0;
|
||||
cls.lpszClassName = className;
|
||||
|
||||
RegisterClassA (&cls);
|
||||
|
||||
/* Setup windows */
|
||||
hWnd = CreateWindowA (className, winName,
|
||||
WS_OVERLAPPEDWINDOW ,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT, 100, 100, 0,
|
||||
0, hinst, 0);
|
||||
|
||||
return hWnd;
|
||||
}
|
||||
|
||||
static BOOL DoTest3(void)
|
||||
{
|
||||
HIMAGELIST himl ;
|
||||
HIMAGELIST himl;
|
||||
|
||||
HBITMAP hbm1 ;
|
||||
HBITMAP hbm2 ;
|
||||
HBITMAP hbm3 ;
|
||||
HBITMAP hbm1;
|
||||
HBITMAP hbm2;
|
||||
HBITMAP hbm3;
|
||||
|
||||
IMAGELISTDRAWPARAMS imldp;
|
||||
HDC hdc;
|
||||
|
@ -267,9 +413,6 @@ static BOOL DoTest3(void)
|
|||
hbm3 = CreateBitmap(48, 48, 1, 1, bitmap_bits);
|
||||
ok(hbm3 != 0, "no bitmap 3\n");
|
||||
|
||||
/* remove when nothing exists */
|
||||
ok(!ImageList_Remove(himl,0),"removed non-existent bitmap\n");
|
||||
|
||||
/* add three */
|
||||
ok(0==ImageList_Add(himl, hbm1, 0),"failed to add bitmap 1\n");
|
||||
ok(1==ImageList_Add(himl, hbm2, 0),"failed to add bitmap 2\n");
|
||||
|
@ -278,25 +421,32 @@ static BOOL DoTest3(void)
|
|||
/*ok(2==ImageList_Add(himl, hbm3, NULL),"failed to add bitmap 3\n"); */
|
||||
ok(ImageList_Replace(himl, 2, hbm3, 0),"failed to replace bitmap 3\n");
|
||||
|
||||
Rectangle(hdc, 100, 100, 74, 74);
|
||||
memset(&imldp, 0, sizeof imldp);
|
||||
memset(&imldp, 0, sizeof (imldp));
|
||||
ok(!pImageList_DrawIndirect(&imldp), "zero data succeeded!\n");
|
||||
imldp.cbSize = sizeof imldp;
|
||||
imldp.cbSize = sizeof (imldp);
|
||||
ok(!pImageList_DrawIndirect(&imldp), "zero hdc succeeded!\n");
|
||||
imldp.hdcDst = hdc;
|
||||
ok(!pImageList_DrawIndirect(&imldp),"zero himl succeeded!\n");
|
||||
imldp.himl = himl;
|
||||
ok(pImageList_DrawIndirect(&imldp),"should succeeded\n");
|
||||
if (!pImageList_DrawIndirect(&imldp))
|
||||
{
|
||||
/* Earlier versions of native commctl32 use a smaller structure */
|
||||
imldp.cbSize -= 3 * sizeof(DWORD);
|
||||
ok(pImageList_DrawIndirect(&imldp),"DrawIndirect should succeed\n");
|
||||
}
|
||||
REDRAW(hwndfortest);
|
||||
WAIT;
|
||||
|
||||
imldp.fStyle = SRCCOPY;
|
||||
imldp.rgbBk = CLR_DEFAULT;
|
||||
imldp.rgbFg = CLR_DEFAULT;
|
||||
imldp.y = 100;
|
||||
imldp.x = 100;
|
||||
ok(pImageList_DrawIndirect(&imldp),"should succeeded\n");
|
||||
ok(pImageList_DrawIndirect(&imldp),"should succeed\n");
|
||||
imldp.i ++;
|
||||
ok(pImageList_DrawIndirect(&imldp),"should succeeded\n");
|
||||
ok(pImageList_DrawIndirect(&imldp),"should succeed\n");
|
||||
imldp.i ++;
|
||||
ok(pImageList_DrawIndirect(&imldp),"should succeeded\n");
|
||||
ok(pImageList_DrawIndirect(&imldp),"should succeed\n");
|
||||
imldp.i ++;
|
||||
ok(!pImageList_DrawIndirect(&imldp),"should fail\n");
|
||||
|
||||
|
@ -308,7 +458,7 @@ static BOOL DoTest3(void)
|
|||
/* destroy it */
|
||||
ok(ImageList_Destroy(himl),"destroy imagelist failed\n");
|
||||
|
||||
/* icons should be deleted by the imagelist */
|
||||
/* bitmaps should not be deleted by the imagelist */
|
||||
ok(DeleteObject(hbm1),"bitmap 1 can't be deleted\n");
|
||||
ok(DeleteObject(hbm2),"bitmap 2 can't be deleted\n");
|
||||
ok(DeleteObject(hbm3),"bitmap 3 can't be deleted\n");
|
||||
|
@ -319,6 +469,82 @@ static BOOL DoTest3(void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void testMerge()
|
||||
{
|
||||
HIMAGELIST himl1, himl2, hmerge;
|
||||
HICON hicon1;
|
||||
HWND hwnd = create_a_window();
|
||||
|
||||
himl1 = ImageList_Create(32,32,0,0,3);
|
||||
ok(himl1 != NULL,"failed to create himl1\n");
|
||||
|
||||
himl2 = ImageList_Create(32,32,0,0,3);
|
||||
ok(himl2 != NULL,"failed to create himl2\n");
|
||||
|
||||
hicon1 = CreateIcon(hinst, 32, 32, 1, 1, icon_bits, icon_bits);
|
||||
ok(hicon1 != NULL, "failed to create hicon1\n");
|
||||
|
||||
if (!himl1 || !himl2 || !hicon1)
|
||||
return;
|
||||
|
||||
ok(0==ImageList_AddIcon(himl2, hicon1),"add icon1 to himl2 failed\n");
|
||||
check_bits(hwnd, himl2, 0, 32, icon_bits, "add icon1 to himl2");
|
||||
|
||||
/* If himl1 has no images, merge still succeeds */
|
||||
hmerge = ImageList_Merge(himl1, -1, himl2, 0, 0, 0);
|
||||
ok(hmerge != NULL, "merge himl1,-1 failed\n");
|
||||
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1,-1");
|
||||
if (hmerge) ImageList_Destroy(hmerge);
|
||||
|
||||
hmerge = ImageList_Merge(himl1, 0, himl2, 0, 0, 0);
|
||||
ok(hmerge != NULL,"merge himl1,0 failed\n");
|
||||
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1,0");
|
||||
if (hmerge) ImageList_Destroy(hmerge);
|
||||
|
||||
/* Same happend if himl2 is empty */
|
||||
ImageList_Destroy(himl2);
|
||||
himl2 = ImageList_Create(32,32,0,0,3);
|
||||
ok(himl2 != NULL,"failed to recreate himl2\n");
|
||||
if (!himl2)
|
||||
return;
|
||||
|
||||
hmerge = ImageList_Merge(himl1, -1, himl2, -1, 0, 0);
|
||||
ok(hmerge != NULL, "merge himl2,-1 failed\n");
|
||||
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl2,-1");
|
||||
if (hmerge) ImageList_Destroy(hmerge);
|
||||
|
||||
hmerge = ImageList_Merge(himl1, -1, himl2, 0, 0, 0);
|
||||
ok(hmerge != NULL, "merge himl2,0 failed\n");
|
||||
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl2,0");
|
||||
if (hmerge) ImageList_Destroy(hmerge);
|
||||
|
||||
/* Now try merging an image with itself */
|
||||
ok(0==ImageList_AddIcon(himl2, hicon1),"re-add icon1 to himl2 failed\n");
|
||||
|
||||
hmerge = ImageList_Merge(himl2, 0, himl2, 0, 0, 0);
|
||||
ok(hmerge != NULL, "merge himl2 with itself failed\n");
|
||||
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl2 with itself");
|
||||
if (hmerge) ImageList_Destroy(hmerge);
|
||||
|
||||
/* Try merging 2 different image lists */
|
||||
ok(0==ImageList_AddIcon(himl1, hicon1),"add icon1 to himl1 failed\n");
|
||||
|
||||
hmerge = ImageList_Merge(himl1, 0, himl2, 0, 0, 0);
|
||||
ok(hmerge != NULL, "merge himl1 with himl2 failed\n");
|
||||
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1 with himl2");
|
||||
if (hmerge) ImageList_Destroy(hmerge);
|
||||
|
||||
hmerge = ImageList_Merge(himl1, 0, himl2, 0, 8, 16);
|
||||
ok(hmerge != NULL, "merge himl1 with himl2 8,16 failed\n");
|
||||
check_bits(hwnd, hmerge, 0, 32, empty_bits, "merge himl1 with himl2, 8,16");
|
||||
if (hmerge) ImageList_Destroy(hmerge);
|
||||
|
||||
ImageList_Destroy(himl1);
|
||||
ImageList_Destroy(himl2);
|
||||
DeleteObject(hicon1);
|
||||
DestroyWindow(hwnd);
|
||||
}
|
||||
|
||||
START_TEST(imagelist)
|
||||
{
|
||||
desktopDC=GetDC(NULL);
|
||||
|
@ -330,4 +556,5 @@ START_TEST(imagelist)
|
|||
DoTest1();
|
||||
DoTest2();
|
||||
DoTest3();
|
||||
testMerge();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue