CreateIconIndirect

The CreateIconIndirect function creates an icon or cursor from an ICONINFO structure.

HICON CreateIconIndirect(
  PICONINFO piconinfo   // pointer to icon information structure
);
 

Parameters

piconinfo
Pointer to an ICONINFO structure the function uses to create the icon or cursor.

Return Values

If the function succeeds, the return value is a handle to the icon or cursor that is created.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

The system copies the bitmaps in the ICONINFO structure before creating the icon or cursor. Because the system may temporarily select the bitmaps in a device context, the hbmMask and hbmColor members of the ICONINFO structure should not already be selected into a device context. The application must continue to manage the original bitmaps and delete them when they are no longer necessary.

When you are finished using the icon, destroy it using the DestroyIcon function.

Windows CE: The icon component does not support cursors. When using this component, always set the fIcon field of the ICONINFO structure to TRUE.

When using the iconcurs component, you can use the CreateIconIndirect function to create either icons or monochrome cursors. Windows CE does not support color cursors.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in winuser.h.
  Import Library: Use user32.lib.

See Also

Icons Overview, Icon Functions, DestroyIcon, ICONINFO