Icons:图标

  • 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.您的应用程序应该提供以下大小的图标图像组.
148x48, 256 color:
232x32, 16 color 
316x16 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.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值