当前位置: 首页 > 工具软件 > Splashy Icons > 使用案例 >

Icons:图标

景光赫
2023-12-01
  • An icon is a picture that consists of a bitmap image combined with a mask to create transparent areas in the picture. The term icon can refer to either of the following: 图标是由位图图像和掩码组成的图片,用于在图片中创建透明区域。图标一词可指下列任何一项:
  • A single icon image. This is a resource of type RT_ICON. 一个图标图像。这是RT_ICON类型的资源。
  • A group of images, from which the system or an application can choose the most appropriate icon based on size and color depth. This is a resource of type RT_GROUP_ICON. 一组图像,系统或应用程序可以从中根据大小和颜色深度选择最合适的图标。这是RT_GROUP_ICON类型的资源。
  • This overview describes creating, displaying, destroying, and duplicating icons.此概述描述创建、显示、销毁和复制图标。

About Icons

  • The system uses icons throughout the user interface to represent objects such as files, folders, shortcuts, applications, and documents. The icon functions enable applications to create, load, display, arrange, animate, and destroy icons. This overview provides information on the following topics:系统在整个用户界面中使用图标来表示对象,如文件、文件夹、快捷方式、应用程序和文档。图标功能使应用程序能够创建、加载、显示、排列、动画和销毁图标。本概览提供下列主题的资料:
  • For information on specifying icons for file types, see IExtractIcon.有关为文件类型指定图标的信息,请参见IExtractIcon。

Icon Hot Spot:图标热点

The operating system provides a set of standard icons that are available for any application to use at any time. The SDK header files contain identifiers for the standard icons — the identifiers begin with the IDI_ prefix. 

Each standard icon has a corresponding default image associated with it. The user can replace the default image associated with any standard cursor at any time. 

Custom icons are designed for use in a particular application and can be any design. Following are several custom icons. 

Icon Types: 图标类型

The operating system provides a set of standard icons that are available for any application to use at any time. The SDK header files contain identifiers for the standard icons — the identifiers begin with the IDI_ prefix. 

Each standard icon has a corresponding default image associated with it. The user can replace the default image associated with any standard cursor at any time. 

Custom icons are designed for use in a particular application and can be any design. Following are several custom icons. 

Icon Sizes: 图标大小

The system uses four icon sizes. 系统使用四种图标大小
  1:System small 
  2:System large 
  3:Shell small
  4:Shell large 
The system small icon is displayed in the window caption. 系统小图标显示在窗口标题中.

To change the size of the system small icon. 改变系统小图标的大小
1:From Control Panel, click Display, then click the Appearance tab. 从“控制面板”中单击“显示”,然后单击“外观”选项卡.
2:Select Caption Buttons from the Item list, then set the Size field. 从项目列表中选择标题按钮,然后设置Size字段. 

To retrieve the size of the system small icon. 检索系统大小的小图标.
1:Call the GetSystemMetrics function with SM_CXSMICON and SM_CYSMICON. 

The system large icon is mainly used by applications, but it is also displayed in the Alt+Tab dialog. The CreateIconFromResource, DrawIcon, ExtractAssociatedIcon, ExtractIcon, ExtractIconEx, and LoadIcon functions all use system large icons. The size of the system large icon is defined by the video driver, therefore it cannot be changed. 

To retrieve the size of the system large icon. 检索系统大图标的大小. 
1:Call GetSystemMetrics with SM_CXICON and SM_CYICON. 使用SM_CXICON和SM_CYICON调用GetSystemMetrics.

The CreateIcon, CreateIconFromResourceEx, CreateIconIndirect, and SHGetFileInfo functions can be used to work with icons in sizes other than system large.

The shell small icon is used in the Windows® Explorer® and the common dialogs. Currently, this defaults to the system small size. 

To retrieve the size of the shell small icon 
1:Use the SHGetFileInfo function with SHGFI_SHELLICONSIZE | SHGFI_SMALLICON to retrieve a handle to the system image list. 
2:Then call the ImageList_GetIconSize function to get the icon size. 

The shell large icon is used on the desktop. 

To change the size of the large icon 
1:From Control Panel , click Display, then click the Appearance tab. 从“控制面板”中单击“显示”,然后单击“外观”选项卡. 
2:Select Icon from the Item list, then set the Size field. 从项目列表中选择Icon,然后设置Size字段.
(this size is stored in the registry, under HKEY_CURRENT_USER\Control Panel, Desktop\WindowMetrics\Shell Icon Size). 此大小存储在注册表中,位于HKEY_CURRENT_USER\Control面板下,Desktop\WindowMetrics\Shell图标Size.
3:Click the Plus! tab and then select the Use Large Icons check box. 单击+ !选项卡,然后选择“使用大图标”复选框.

To retrieve the size of the shell large icon. 要检索shell大图标的大小. 
1:Use the SHGetFileInfo function with SHGFI_SHELLICONSIZE to retrieve a handle to the system image list. 使用带有SHGFI_SHELLICONSIZE的SHGetFileInfo函数来检索系统映像列表的句柄.
2:Then call the ImageList_GetIconSize function to get the icon size. 然后调用imagelist_getize函数来获得图标大小. 

The Start menu uses either shell small icons or shell large icons. “开始”菜单使用shell小图标或shell大图标.
depending on whether the Use Large Icons check box is selected. 这取决于是否选中了“使用大图标”复选框.

Your application should supply groups of icon images in the following sizes.您的应用程序应该提供以下大小的图标图像组.
1:48x48, 256 color:
2:32x32, 16 color 
3:16x16 pixels, 16 color 

When filling in the WNDCLASSEX structure to be used in registering your window class. 在填写用于注册窗口类的WNDCLASSEX结构时.
set the hIcon member to the 32x32 icon and the hIconSm member to the 16x16 icon. 将hIcon成员设置为32x32图标,将hIconSm成员设置为16x16图标.
For more information about class icons, see Class Icons. 有关类图标的更多信息,请参见类图标.

Icon Creation:创建图标

Standard icons are predefined, so it is not necessary to create them. To use a standard icon, an application can obtain its handle by using the LoadImage function. An icon handle is a unique value of the HICON type that identifies a standard or custom icon. 

To create a custom icon for an application, you would typically use a graphics application and include the ICON resource in the application's resource-definition file. At run-time, you can call LoadIcon or LoadImage to retrieve a handle to the icon. An icon resource can contain a group of images for several different display devices. LoadIcon and LoadImage automatically select the most appropriate icon from the group for the current display device. 

An application can also create a custom icon at run-time by using the CreateIconIndirect function, which creates an icon based on the contents of an ICONINFO structure. The GetIconInfo function fills the structure with the hot-spot coordinates and information about the bitmask bitmap and color bitmap for the icon. 

Applications should implement custom icons as resources and should use LoadIcon or LoadImage, rather than create the icon at run-time. Using icon resources avoids device dependence, simplifies localization, and enables applications to share icon shapes. 

The CreateIconFromResourceEx function enables an application to browse through the system's resources and create icons and cursors based on resource data. CreateIconFromResourceEx creates an icon based on binary resource data from other executable files or dynamic-link libraries (DLLs). An application must precede this function with calls to the LookupIconIdFromDirectoryEx function and several of the resource functions. LookupIconIdFromDirectoryEx returns the identifier of the most appropriate icon data for the current display device. For more information about the resource functions, see Resource Functions. 


Icon Display:显示图标

You can retrieve the image for an icon by using the GetIconInfo function. 可以使用GetIconInfo函数检索图标的图像.
and can draw it by using the DrawIconEx function. 可以用DrawIconEx函数来绘制.
To draw the default image for a icon. 要为图标绘制默认图像.
specify the DI_COMPAT flag in the call to DrawIconEx. 在调用DrawIconEx时指定DI_COMPAT标志.
If you do not specify the DI_COMPAT flag. 如果不指定DI_COMPAT标志. 
DrawIconEx draws the icon using the image that the user specified. DrawIconEx使用用户指定的图像绘制图标. 
When the system displays an icon. 当系统显示图标时.
it must extract the appropriate icon image from the .exe or .dll file. 它必须从.exe或.dll文件中提取适当的图标图像.
The system uses the following steps to select the icon image. 系统使用以下步骤来选择图标图像.
1:Select the RT_GROUP_ICON resource. If more than one such resource exists, Windows NT/2000/XP uses the first resource listed in the resource script, while Windows 95/98/Me chooses the first resource listed in alphabetical order. 
2:Select the appropriate RT_ICON image from the RT_GROUP_ICON resource. If more than one image exists, the system uses the following criteria to choose an image: 
2.1:The image closest in size to the requested size is chosen. 
2.2:If two or more images of that size are present, the one that matches the color depth of the display is chosen. :
2.3:If no images exactly match the color depth of the display, the image with the greatest color depth that does not exceed the color depth of the display is chosen. If all exceed the color depth, the one with the lowest color depth is chosen. 
Note  The system treats all color depths of 8 or more bpp as equal. Therefore, there is no advantage of including a 16x16 256-color image and a 16x16 16-color image in the same resource  — the system will simply choose the first one it encounters. When the display is in 8-bpp mode, the system will choose a 16-color icon over a 256-color icon, and will display all icons using the system default palette. 

To display an animated icon, use a static control as shown in the following code fragment.

hIcon = LoadImage(NULL, "ico.ani", IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
SendMessage( hStatic, STM_SETIMAGE, IMAGE_ICON, (LPARAM)(UINT)hIcon);

Icon Destruction:销毁图标

When an application no longer needs an icon it created by using the CreateIconIndirect function, it should destroy the icon. 当应用程序不再需要使用CreateIconIndirect函数创建的图标时,它应该销毁该图标.
The DestroyIcon function destroys the icon handle and frees any memory used by the icon. DestroyIcon函数销毁图标句柄并释放图标使用的任何内存.
Applications should use this function only for icons created with CreateIconIndirect. 应用程序应该只对使用CreateIconIndirect创建的图标使用此函数.
it is not necessary to destroy other icons. 没有必要销毁其他图标.

Icon Duplication:图标的复制

The CopyIcon function copies an icon handle. This enables an application or DLL to get its own handle for an icon owned by another module. Then, if the other module is freed, the application that copied the icon will still be able to use the icon. CopyIcon函数复制一个图标句柄。这使应用程序或DLL能够为另一个模块拥有的图标获得自己的句柄。然后,如果释放了其他模块,复制图标的应用程序仍然可以使用图标。
The CopyImage function creates a new icon based on the specified source icon. The new icon can be larger or smaller than the source icon. CopyImage函数基于指定的源图标创建一个新图标。新图标可以大于或小于源图标。
For information about adding, removing, or replacing icon resources in executable (.exe) files, see Resources. 有关在可执行文件(.exe)中添加、删除或替换图标资源的信息,请参阅参考资料。
The DuplicateIcon function makes an actual copy of the icon.  DuplicateIcon函数实际复制图标。

Using Icons:The following topics describe how to perform certain tasks related to icons: 以下主题描述如何执行与图标相关的特定任务

Creating an icon:创建一个图标

To use an icon, your application must get a handle to the icon. The following example shows how to create two different icon handles: one for the standard exclamation icon and one for a custom icon included as a resource in the application's resource-definition file. 

HICON hIcon1;   // icon handle 
HICON hIcon2;   // icon handle 
 
// Create a standard question icon. 
 
hIcon1 = LoadIcon(NULL, IDI_QUESTION); 
 
// Create a custom icon based on a resource. 
 
hIcon2 = LoadIcon(hinst, MAKEINTRESOURCE(460)); 
 
// Create a custom icon at run time. 
An application should implement custom icons as resources and should use the LoadIcon or LoadImage function, rather than create the icons at run-time. This approach avoids device dependence, simplifies localization, and enables applications to share icon bitmaps. However, the following example uses CreateIcon to create a custom icon at run-time, based on bitmap bitmasks; it is included to illustrate how the system interprets icon bitmap bitmasks. 

HICON hIcon3;      // icon handle 
 
// Yang icon AND bitmask 
 
BYTE ANDmaskIcon[] = {0xFF, 0xFF, 0xFF, 0xFF,   // line 1 
                      0xFF, 0xFF, 0xC3, 0xFF,   // line 2 
                      0xFF, 0xFF, 0x00, 0xFF,   // line 3 
                      0xFF, 0xFE, 0x00, 0x7F,   // line 4 
 
                      0xFF, 0xFC, 0x00, 0x1F,   // line 5 
                      0xFF, 0xF8, 0x00, 0x0F,   // line 6 
                      0xFF, 0xF8, 0x00, 0x0F,   // line 7 
                      0xFF, 0xF0, 0x00, 0x07,   // line 8 
 
                      0xFF, 0xF0, 0x00, 0x03,   // line 9 
                      0xFF, 0xE0, 0x00, 0x03,   // line 10 
                      0xFF, 0xE0, 0x00, 0x01,   // line 11 
                      0xFF, 0xE0, 0x00, 0x01,   // line 12 
 
                      0xFF, 0xF0, 0x00, 0x01,   // line 13 
                      0xFF, 0xF0, 0x00, 0x00,   // line 14 
                      0xFF, 0xF8, 0x00, 0x00,   // line 15 
                      0xFF, 0xFC, 0x00, 0x00,   // line 16 
 
                      0xFF, 0xFF, 0x00, 0x00,   // line 17 
                      0xFF, 0xFF, 0x80, 0x00,   // line 18 
                      0xFF, 0xFF, 0xE0, 0x00,   // line 19 
                      0xFF, 0xFF, 0xE0, 0x01,   // line 20 
 
                      0xFF, 0xFF, 0xF0, 0x01,   // line 21 
                      0xFF, 0xFF, 0xF0, 0x01,   // line 22 
                      0xFF, 0xFF, 0xF0, 0x03,   // line 23 
                      0xFF, 0xFF, 0xE0, 0x03,   // line 24 
 
                      0xFF, 0xFF, 0xE0, 0x07,   // line 25 
                      0xFF, 0xFF, 0xC0, 0x0F,   // line 26 
                      0xFF, 0xFF, 0xC0, 0x0F,   // line 27 
                      0xFF, 0xFF, 0x80, 0x1F,   // line 28 
 
                      0xFF, 0xFF, 0x00, 0x7F,   // line 29 
                      0xFF, 0xFC, 0x00, 0xFF,   // line 30 
                      0xFF, 0xF8, 0x03, 0xFF,   // line 31 
                      0xFF, 0xFC, 0x3F, 0xFF};  // line 32 
 
// Yang icon XOR bitmask 
 
BYTE XORmaskIcon[] = {0x00, 0x00, 0x00, 0x00,   // line 1 
                      0x00, 0x00, 0x00, 0x00,   // line 2 
                      0x00, 0x00, 0x00, 0x00,   // line 3 
                      0x00, 0x00, 0x00, 0x00,   // line 4 
 
                      0x00, 0x00, 0x00, 0x00,   // line 5 
                      0x00, 0x00, 0x00, 0x00,   // line 6 
                      0x00, 0x00, 0x00, 0x00,   // line 7 
                      0x00, 0x00, 0x38, 0x00,   // line 8 
 
                      0x00, 0x00, 0x7C, 0x00,   // line 9 
                      0x00, 0x00, 0x7C, 0x00,   // line 10 
                      0x00, 0x00, 0x7C, 0x00,   // line 11 
                      0x00, 0x00, 0x38, 0x00,   // line 12 
 
                      0x00, 0x00, 0x00, 0x00,   // line 13 
                      0x00, 0x00, 0x00, 0x00,   // line 14 
                      0x00, 0x00, 0x00, 0x00,   // line 15 
                      0x00, 0x00, 0x00, 0x00,   // line 16 
 
                      0x00, 0x00, 0x00, 0x00,   // line 17 
                      0x00, 0x00, 0x00, 0x00,   // line 18 
                      0x00, 0x00, 0x00, 0x00,   // line 19 
                      0x00, 0x00, 0x00, 0x00,   // line 20 
 
                      0x00, 0x00, 0x00, 0x00,   // line 21 
                      0x00, 0x00, 0x00, 0x00,   // line 22 
                      0x00, 0x00, 0x00, 0x00,   // line 23 
                      0x00, 0x00, 0x00, 0x00,   // line 24 
 
                      0x00, 0x00, 0x00, 0x00,   // line 25 
                      0x00, 0x00, 0x00, 0x00,   // line 26 
                      0x00, 0x00, 0x00, 0x00,   // line 27 
                      0x00, 0x00, 0x00, 0x00,   // line 28 
 
                      0x00, 0x00, 0x00, 0x00,   // line 29 
                      0x00, 0x00, 0x00, 0x00,   // line 30 
                      0x00, 0x00, 0x00, 0x00,   // line 31 
                      0x00, 0x00, 0x00, 0x00};  // line 32 
 
hIcon3 = CreateIcon(hinst,    // application instance  
             32,              // icon width 
             32,              // icon height 
             1,               // number of XOR planes 
             1,               // number of bits per pixel 
             ANDmaskIcon,     // AND bitmask  
             XORmaskIcon);    // XOR bitmask  
To create the icon, 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

Before closing, your application must use DestroyIcon to destroy any icon it created by using CreateIconIndirect. It is not necessary to destroy icons created by other functions. 

Displaying an icon:显示一个图标

Your application can load and create icons to display in the application's client area or child windows. The following example demonstrates how to draw an icon in the client area of the window whose display context (DC) is identified by the hdc parameter. 

HICON hIcon1;   // icon handle  
HDC hdc;        // handle to display context 
 
DrawIcon(hdc, 10, 20, hIcon1); 
The system automatically displays the class icon(s) for a window. Your application can assign class icons while registering a window class. Your application can replace a class icon by using the SetClassLong function. This function changes the default window settings for all windows of a given class. The following example replaces a class icon with the icon whose resource identifier is 480. 

HINSTANCE hinst;            // handle to current instance 
HWND hwnd;                  // main window handle  
 
// Change the icon for hwnd's window class. 
 
SetClassLong(hwnd,          // window handle 
    GCL_HICON,              // changes icon 
    (LONG) LoadIcon(hinst, MAKEINTRESOURCE(480))
   ); 
For more information about window classes, see Window Classes. 

Sharing icon resources:分享图标资源

The following code uses the functions CreateIconFromResourceEx, DrawIcon, and LookupIconIdFromDirectoryEx, and several of the resource functions, to create an icon handle based on icon data from another executable file. Then, it displays the icon in a window. 

HICON hIcon1;       // icon handle 
HINSTANCE hExe;     // handle to loaded .EXE file 
HRSRC hResource;    // handle for FindResource  
HRSRC hMem;         // handle for LoadResource 
BYTE *lpResource;   // pointer to resource data  
int nID;            // ID of resource that best fits current screen 
 
HDC hdc;        // handle to display context 
 
// Load the file from which to copy the icon. 
 
hExe = LoadLibrary("myapp.exe"); 
 
// Find the icon directory whose identifier is 440. 
 
hResource = FindResource(hExe, 
    MAKEINTRESOURCE(440), 
    RT_GROUP_ICON); 
 
// Load and lock the icon directory. 
 
hMem = LoadResource(hExe, hResource); 
 
lpResource = LockResource(hMem); 
 
// Get the identifier of the icon that is most appropriate 
// for the video display. 
 
nID = LookupIconIdFromDirectoryEx((PBYTE) lpResource, TRUE, 
    CXICON, CYICON, LR_DEFAULTCOLOR); 
 
// Find the bits for the nID icon. 
 
hResource = FindResource(hExe, 
    MAKEINTRESOURCE(nID), 
    MAKEINTRESOURCE(RT_ICON)); 
 
// Load and lock the icon. 
 
hMem = LoadResource(hExe, hResource); 
 
lpResource = LockResource(hMem); 
 
// Create a handle to the icon. 
 
hIcon1 = CreateIconFromResourceEx((PBYTE) lpResource, 
    SizeofResource(hExe, hResource), TRUE, 0x00030000, 
    CXICON, CYICON, LR_DEFAULTCOLOR); 
 
// Draw the icon in the client area. 
 
DrawIcon(hdc, 10, 20, hIcon1); 

Icon Reference

  • The following elements are used with icons. 下列元素与图标一起使用.

Icon Functions

  • The following functions are used with icons. 下面的函数与图标一起使用.

CopyIcon

  • Copies an icon from another module. 从另一个模块复制图标.

CreateIcon

  • Creates an icon with a specified size, color, and bit pattern. 创建具有指定大小、颜色和位模式的图标.

CreateIconFromResource

  • Creates an icon or cursor from resource bits. 从资源位创建图标或光标.

CreateIconFromResourceEx

  • Creates an icon or cursor from resource bits. 从资源位创建图标或光标.

CreateIconIndirect

  • Creates an icon or cursor from an ICONINFO structure. 从ICONINFO结构创建图标或光标.

DestroyIcon

  • Destroys an icon. 销毁了一个图标.

DrawIcon

  • Draws an icon. 画一个图标.
  • The DrawIcon function draws an icon or cursor into the specified device context.DrawIcon函数将一个图标或光标绘制到指定的设备上下文中.To specify additional drawing options, use the DrawIconEx function.要指定额外的绘图选项,使用DrawIconEx函数.
  • Header: Declared in Winuser.h; include Windows.h
  • Library: Use User32.lib.
  • Return Values:If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.函数成功返回值!=0,函数失败返回值=0,要获取扩展的错误信息调用GetLastError
  • Remarks:DrawIcon places the icon’s upper-left corner at the location specified by the X and Y parameters.The location is subject to the current mapping mode of the device context.DrawIcon将图标的左上角放在X和Y参数指定的位置.位置取决于当前设备上下文的映射模式
  • Example Code:For an example, see Displaying an Icon. 示例代码参考显示图标
BOOL DrawIcon(
  HDC hDC,      // handle to DC  将绘制图标或光标的设备上下文的句柄 Handle to the device context into which the icon or cursor will be drawn. 
  int X,        // x-coordinate of upper-left corner 指定图标左上角的逻辑X坐标 Specifies the logical x-coordinate of the upper-left corner of the icon.
  int Y,        // y-coordinate of upper-left corner 指定图标左上角的逻辑Y坐标 Specifies the logical y-coordinate of the upper-left corner of the icon. 
  HICON hIcon   // handle to icon 要绘制的图标的句柄. Handle to the icon to be drawn.
);

DrawIconEx

  • Draws an icon or cursor, performing raster operations, and stretching or compressing the icon or cursor. 绘制图标或光标,执行光栅操作,并拉伸或压缩图标或光标.

DuplicateIcon

  • Creates a duplicate of a specified icon. 创建指定图标的副本.

ExtractAssociatedIcon

  • Gets a handle to an indexed icon in a file or an icon found in an executable file. 获取文件中索引图标或可执行文件中找到的图标的句柄.

ExtractIcon

  • Gets a handle to an icon from an executable file, dynamic-link library (DLL), or icon file. 从可执行文件、动态链接库或图标文件获取图标的句柄.

ExtractIconEx

  • Gets an array of handles to large or small icons extracted from an executable file, dynamic-link library (DLL), or icon file. 获取从可执行文件、动态链接库或图标文件中提取的大图标或小图标的句柄数组.

GetIconInfo

  • Gets information about an icon or cursor. 获取有关图标或光标的信息.

LoadIcon

  • Loads an icon from the executable file associated with an application. 从与应用程序关联的可执行文件中加载图标.

LookupIconIdFromDirectory

  • Searches for an icon or cursor that best fits the current display device. 搜索最适合当前显示设备的图标或光标.

LookupIconIdFromDirectoryEx

  • Searches for an icon or cursor that best fits the current display device. 搜索最适合当前显示设备的图标或光标.

Icon Structures

  • The following structures are used with icons. 下面的结构用于图标.

ICONINFO

/*The ICONINFO structure contains information about an icon or a cursor. ICONINFO结构包含关于图标或光标的信息.
  Header: Declared in Winuser.h; include Windows.h*/
  
typedef struct _ICONINFO { 
  BOOL    fIcon; //Specifies whether this structure defines an icon or a cursor. 指定此结构定义图标还是游标. A value of TRUE specifies an icon. TRUE值指定一个图标. FALSE specifies a cursor. FALSE指定游标. 
  DWORD   xHotspot; //Specifies the x-coordinate of a cursor's hot spot. 指定游标热点的x坐标. If this structure defines an icon. 如果这个结构定义了一个图标. the hot spot is always in the center of the icon. 热点总是在图标的中心. and this member is ignored. 这个元素被忽略了.
  DWORD   yHotspot; //Specifies the y-coordinate of the cursor's hot spot. If this structure defines an icon, the hot spot is always in the center of the icon, and this member is ignored. 
  HBITMAP hbmMask; //Specifies the icon bitmask bitmap. If this structure defines a black and white icon, this bitmask is formatted so that the upper half is the icon AND bitmask and the lower half is the icon XOR bitmask. Under this condition, the height should be an even multiple of two. If this structure defines a color icon, this mask only defines the AND bitmask of the icon. 
  HBITMAP hbmColor; //Handle to the icon color bitmap. This member can be optional if this structure defines a black and white icon. The AND bitmask of hbmMask is applied with the SRCAND flag to the destination; subsequently, the color bitmap is applied (using XOR) to the destination by using the SRCINVERT flag.
} ICONINFO; 

ICONMETRICS

  • The ICONMETRICS structure contains the scalable metrics associated with icons. This structure is used with the SystemParametersInfo function when the SPI_GETICONMETRICS or SPI_SETICONMETRICS action is specified.
  • Header: Declared in Winuser.h; include Windows.h.
  • Unicode: Declared as Unicode and ANSI structures.
  • Members:
    • cbSize:Specifies the size of the structure, in bytes.
    • iHorzSpacing:Horizontal and vertical space, in pixels, for each arranged icon.
    • iVertSpacing:Horizontal and vertical space, in pixels, for each arranged icon.
    • iTitleWrap:Title-wrapping flag. If this member is nonzero, icon titles wrap to a new line. If this member is zero, titles do not wrap.
    • LOGFONT lfFont:Specifies the font to use for icon titles.
typedef struct tagICONMETRICS { 
  UINT    cbSize;
  int     iHorzSpacing; 
  int     iVertSpacing; 
  int     iTitleWrap; 
  LOGFONT lfFont; 
} ICONMETRICS, FAR *LPICONMETRICS; 

Icon Messages

  • The following messages are used with icons.下面的消息与图标一起使用

WM_ERASEBKGND

WM_ICONERASEBKGND

WM_PAINTICON

 类似资料: