DRAFT - TAKE MORE THAN YOUR USUAL CARE

IImgCtx

IID_IImgCtx {3050F3D7-98B5-11CF-BB82-00AA00BDCE0B}

The IImgCtx methods are (as ordered in the virtual function table after the IUnknown methods):

Offset Method
0x0C Load
0x10 SelectChanges
0x14 SetCallback
0x18 Disconnect
0x1C GetUpdateRects
0x20 GetStateInfo
0x24 GetPalette
0x28 Draw
0x2C Tile
0x30 StretchBlt

with prototypes:

HRESULT Load (PCWSTR, ULONG);
HRESULT SelectChanges (ULONG, ULONG, BOOL);
HRESULT SetCallback (PFNIMGCTXCALLBACK, PVOID);
HRESULT Disconnect (VOID);
HRESULT GetUpdateRects (RECT *, RECT *, LONG *);
HRESULT GetStateInfo (ULONG *, SIZE *, BOOL);
HRESULT GetPalette (HPALETTE *);
HRESULT Draw (HDC, RECT *);
HRESULT Tile (HDC, POINT *, RECT *, SIZE *);
HRESULT StretchBlt (HDC, INT, INT, INT, INT, INT, INT, INT, INT, ULONG);

in which the callback function for SetCallback has the type

typedef VOID (CALLBACK *PFNIMGCTXCALLBACK) (PVOID, PVOID);

Implementations

The one implementation in MSHTML is for a class that Microsoft’s published symbol files name as CImgCtx. Instances are created internally to support images for backgrounds and list items. Instances are also creatable from a CLSID:

CLSID_IImgCtx {3050F3D6-98B5-11CF-BB82-00AA00BDCE0B}

The standard, though probably not the only, use of this CLSID is by COMCTL32.DLL so that a List-View control may take a background image from a URL. This has the curious effect of making the Windows shell depend on Internet Explorer for what looks very like a Windows feature that need have nothing to do with Internet access. Indeed, even if some other web browser is selected for use with the Internet, putting a background image into a List-View control will use Internet Explorer unless the writers of this other browser have known of this class and interface and have set the registry to point this CLSID away from MSHTML.

The List-View Control

The interface is also implemented in COMCTL32 versions 6.00 and higher, so that the LVBKIF_SOURCE_HBITMAP feature in setting a background image for a List-View control finally works.

Availability

The IImgCtx interface and the creatable IImgCtx class are implemented in MSHTML versions 4.71 and higher.

Though this interface dates from as long ago as 1997, it was still not documented by Microsoft as late as the January 2007 edition of the Windows Software Development Kit (SDK).

That said, from at least as long ago as the January 1998 edition, the SDK has provided a header file, IIMGCTX.H, in which the interface, methods, class and related constants are all defined. There are no comments that might sensibly be described as instructive. There is just enough that a programmer who (somehow) already knows the interface can use it in code without having to write definitions for it. Even so, the publishing of this header does mean that the interface has possibly never been especially secret, just obscure.