CreateIcon function
Creates an icon that has the specified size, colors, and bit patterns.
Syntax
HICON WINAPI CreateIcon( _In_opt_ HINSTANCE hInstance, _In_ int nWidth, _In_ int nHeight, _In_ BYTE cPlanes, _In_ BYTE cBitsPixel, _In_ const BYTE *lpbANDbits, _In_ const BYTE *lpbXORbits );
Parameters
- hInstance [in, optional]
-
Type: HINSTANCE
A handle to the instance of the module creating the icon.
- nWidth [in]
-
Type: int
The width, in pixels, of the icon.
- nHeight [in]
-
Type: int
The height, in pixels, of the icon.
- cPlanes [in]
-
Type: BYTE
The number of planes in the XOR bitmask of the icon.
- cBitsPixel [in]
-
Type: BYTE
The number of bits-per-pixel in the XOR bitmask of the icon.
- lpbANDbits [in]
-
Type: const BYTE*
An array of bytes that contains the bit values for the AND bitmask of the icon. This bitmask describes a monochrome bitmap.
- lpbXORbits [in]
-
Type: const BYTE*
An array of bytes that contains the bit values for the XOR bitmask of the icon. This bitmask describes a monochrome or device-dependent color bitmap.
Return value
Type: HICON
If the function succeeds, the return value is a handle to an icon.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Remarks
The nWidth and nHeight parameters must specify a width and height supported by the current display driver, because the system cannot create icons of other sizes. To determine the width and height supported by the display driver, use the GetSystemMetrics function, specifying the SM_CXICON or SM_CYICON value.
CreateIcon applies the following truth table to the AND and XOR bitmasks.
| AND bitmask | XOR bitmask | Display |
|---|---|---|
| 0 | 0 | Black |
| 0 | 1 | White |
| 1 | 0 | Screen |
| 1 | 1 | Reverse screen |
When you are finished using the icon, destroy it using the DestroyIcon function.
Examples
For an example, see Creating an Icon.
Requirements
|
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- Conceptual
- Icons
- Other Resources
- GetSystemMetrics