CImageList::DrawIndirect

BOOL DrawIndirect( IMAGELISTDRAWPARAMS* pimldp );

BOOL DrawIndirect( CDC* pDC, int nImage, POINT pt, SIZE sz, POINT ptOrigin, UINT fStyle = ILD_NORMAL, DWORD dwRop = SRCCOPY, COLORREF rgbBack = CLR_DEFAULT, COLORREF rgbFore = CLR_DEFAULT );

Return Value

TRUE if the image is successfully drawn; otherwise FALSE.

Parameters

pimldp

A pointer to an IMAGELISTDRAWPARAMS structure that contains information about the draw operation.

pDC

A pointer to the destination device context. You must delete this CDC object when you are done with it.

nImage

The zero-based index of the image to be drawn.

pt

A POINT structure containing the x– and y– coordinates where the image will be drawn.

sz

A SIZE structure indicating the size of the image to be drawn.

ptOrigin

A POINT structure containing the x– and y–coordinates specifying the upper-left corner of the drawing operation with respect to the image itself. Pixels of the image that are to the left of the x–coordinate and above the y–coordinate are not drawn.

fStyle

Flag specifying the drawing style and, optionally, the overlay image. See the Remarks section for information on the overlay image. MFC’s default implementation, ILD_NORMAL, draws the image using the background color for the image list. If the background color is the CLR_NONE value, the image is drawn transparently using a mask.

Other possible styles are described under the fStyle member of the IMAGELISTDRAWPARAMS structure.

dwRop

Value specifying a raster-operation code. These codes define how the color data for the source rectangle will be combined with the color data for the destination rectangle to achieve the final color. MFC’s default implementation, SRCCOPY, copies the source rectangle directly to the destination rectangle. This parameter is ignored if the fStyle parameter does not include the ILD_ROP flag.

Other possible values are described under the dwRop member of the IMAGELISTDRAWPARAMS structure.

rgbBack

The image background color, by default CLR_DEFAULT. This parameter can be an application-defined RGB value or one of the following values:

Value Meaning
CLR_DEFAULT Default background color. The image is drawn using the image list background color.
CLR_NONE No background color. The image is drawn transparently.

rgbFore

Image foreground color, by default CLR_DEFAULT. This parameter can be an application-defined RGB value or one of the following values:

Value Meaning
CLR_DEFAULT Default foreground color. The image is drawn using the system highlight color as the foreground color.
CLR_NONE No blend color. The image is blended with the color of the destination device context.

This parameter is used only if fStyle includes the ILD_BLEND25 or ILD_BLEND50 flag.

Remarks

Call this member function to draw an image from an image list. Use the first version if you want to fill the Win32 structure yourself. Use the second version if you want to take advantage of one or more of MFC’s default arguments, or avoid managing the structure.

An overlay image is an image that is drawn on top of the primary image, specified in this member function by the nImage parameter. Draw an overlay mask by using the Draw member function with the one-based index of the overlay mask specified by using the INDEXTOOVERLAYMASK macro.

Example

// The pointer to my image list.
extern CImageList* pmyImageList;
// the pointer to the DC for drawing.
extern CDC* pmyDC;

int i, dx, cx, cy, nCount = pmyImageList->GetImageCount();

::ImageList_GetIconSize(*pmyImageList, &cx, &cy);

// Draw the images of the image list on the DC.
for (dx=0,i=0;i < nCount;i++)
{
   pmyImageList->DrawIndirect(pmyDC, i, CPoint(dx, 0), 
      CSize(cx, cy), CPoint(0, 0));
   dx += cx;
}

CImageList OverviewClass MembersHierarchy Chart

See Also   CImageList::SetOverlayImage