Icon information

xiaoxiao2021-03-06  226

Vchelp Copathway Izee Project Compile: YZ Email: Yzfree@sina.com Date: 2000-8-5ICON Data According to VC5 Online Help

● Icon icon is a picture, which is a transparent image area generated by a bitmap and a mask image. The following describes how to create, display, destroy, and copy icons. ● About iCons can be seen everywhere in the Windows system, which is generally used to describe an object, such as files, folders, shortcuts, applications, and various documents. The icon function in the Win32 API can allow applications to create, read, arrange, and destroy icons. For information on the type of file type with a specific icon, see the Icon Handlers section. ● The Icon Hotspot icon is specified as a hotspot, and the operating system will track and locate icons based on this point. In general, the hotspots of the icon are positioned on the center of the icon. If you create an icon with the CreateiconIndirect () function, you can specify any point of the icon as its hotspot. (Translator Note: In fact, the icon does not use hotspots. This may be that Microsoft's document is not written. The use of hotspots are cursors.) ● Icon Types operating system provides a set of standard icons for applications to use In the Windows header file (Windows.h), there is a resource ID value (definition of IDi_ is a prefix). Each standard icon has a default image with the standard cursor (?) To replace these default images at any time. Custom Custom Icons You can be used for special programs or any purpose (translator Note: Microsoft is very interesting, we can't use standard icons without your own icons :-), below is a few custom icons: ● icon Icon Sizes Windows uses four icons size: system small, system large, housing, housing large. The system small icon is used to display the title bar of the window. If you want to change the size of this icon, you can start the display control panel program, click the "Appearance" card, and select the "Caption Buttons" from the "Item" list and modify the "size" value. If you want to get the size of the system small icon in the application, you can call the getSystemMetrics () function (using SM_CXSMICON and SM_CYSMICON as a parameter). The system large icon is mainly used by the application itself (such as in the "About" dialog), but it is also displayed in the Alt Tab dialog. CreateiconFromResource (), drawicon (), extracton (), and loadicon () functions are using the system large icon. Because the size of the system's large icon is defined by the video device, it cannot be modified. If you want to get the size of this icon, you can call the getSystemMetrics () function (using SM_CXICON and SM_CYICON as a parameter). Createicon (), CreateiconFromResourceEx () and createiconIndirect () These three functions can create different icons that are different from the system large icon. Shell small icons are used for Windows Exploer programs and some public dialogs, usually, the size of this icon is equal to the size of the system small icon. You can use the SHGETFILEINFO () function to get the icon list handle (using SHGFI_SHELLICONSIZE | SHGFI_SMALLICON as a parameter), then use the ImageList_Geticonsize () function to get the size of the icon. Shell large icons will be used for desktop. If you want to modify the size of this icon, start the display control panel program, click the "Appearance" card, select "Icon" from the "Item" and set it.

(Note: This value will be saved in the system registry, the address is: hkey_current_user / control panel / desktop / windowmetrics / shell icon size), you also need to click "Plus!" Card, and select "Use the big icon" Check box. To get the size of this icon, you can obtain a list of system images with a shGetfileinfo () function (using SHGFI_SHELLICIGIZE as a parameter), and then use the imagelist_geticonsize () function to obtain the size of the icon. The system "Start" menu will use a shell large icon or a small icon. Which of the specific use will depend on whether the "Using the Big Icon" check box is set. Your application icon should provide the following formats: * 48 × 48, 256 colors * 32 × 32, 16 colors

* 16 × 16, 16 colors

When your application is in the registration window class, the HICON member in the WNDCLASSEX structure should correspond to 32 × 32 icons, and the HiconSM member corresponds to 16 × 16 icon. For more information on class icons, see the Class ICONS section. ● The icon code creation standard icon is predefined, so they don't need to be created. To use the standard icon, the application can use the loadImage () function to obtain this icon's handle (the icon handle is a unique value of a Hicon type, which can be used to represent a standard icon or custom icon). If the application wants to use its own icon (called custom icon), the developer is generally first using image software to create an icon image, and then the image is included as an ICON resource into the program. When the program is run, the loadICON () or loadImage () function is called to obtain the handle of the icon. The icon resource generally contains several data required for different display devices, and the loadICON () and loadImage () functions are automatically transferred to the data that is mostly matched with the current display device when the icon is read. The application can also create a custom icon when running, and the method is to first fill in an iconifo structure and then create it using the CreateicONIndirect () function. You can also use the GeticonInfo () function to get the hotspots, mask bitmaps, and color bitmaps of the specified icon. But applications should try to avoid creating icons at runtime, the best way to make custom icons into resources, and then use loadicon () or loadImage () functions to call at runtime. The advantage of this is that the icon can be eliminated on the device, and the software is easier and can make the application to share icons. CreateiconFromResourceEx () function allows applications to browse from system resources, created icons, to several images such as resource data, CreateiconFromResourceEx () functions can also create icons according to binary resources in other EXE files or DLL files. . For more information on resource functions, see the Resource Functions section. ● Icon Display Application You can call the GeticonInfo () function to get an image of the specified icon (the translator Note: If you want to display the default image of an icon, specify the Di_Compat flag when calling the DrawicOnex () function. If this flag is not specified, the function will use the user specified by the user. ● Destruction icon (icon destruction) When an application is no longer required to create an icon created at runtime (using the CREATEICONDIRECT () function, it should destroy this icon. You can use the Destroyicon () function to achieve this, the destroyicon () function will destroy the icon handle and release the memory resources occupied by the specified icon. (Note: The destroyicon () function can only be used to destroy icons created by the CreateicONDirect () function, while other types of icons do not need to be destroyed). ● Icon Duplication Copyicon () function can copy the icon handle, which makes the application or DLL to get the icon (copy) of other programs, which will continue to be valid when those programs are released. CopyImage () function can create a new icon based on a specified icon. This new icon can be greater than or smaller than the original icon. See the Resources section for information on EXE files, minus, replacing icons. ● Creating an icon (CREATE AN icon) To use the icon, the application must first get the icon's handle.

The following example will show how to create two different types of icon handles: one is a standard icon (an exclamation mark) and the other is a custom icon (as the resources of the program). 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. Although the application is best not to create an icon at runtime, or place an example of creating a runtime icon with a createicon () function, its purpose is mainly explanation. The interpretation principle of the system on the mask bitmap. 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, // L INE 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 Createicon () function when creating icons Use the following principle table to and xor bit mask: And bit mask XOR bit mask display ---------------------------------------------------------- ---------------

0 0 black

0 1 white

1 0 screen

1 1 Front of the screen

Before shutting down, the application must use the Destroyicon () function to destroy any icon created with the createIcon Indirect () function (the translator Note: This can also see the benefits of the resource icon). ● Displaying an icon Your application can display or create icons in the program in the client area or sub-window. The following example shows how to display icons in a window (HDC representative window):

Hicon Hicon1; // icon handlehdc hdc; // handle of display context

Drawicon (HDC, 10, 20, Hicon1);

The Windows system will automatically display the class icon of the window, your application can specify this icon when the window class is registered. You can also call the setClasslong () function when the program is running to replace the class icon (this function modifies all the window settings of all classes), the following example demonstrates the method of replacing the class icon with an icon resource:

Hinstance Hinst; // Handle of 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 on window classes, see the Window Classes section. ● Sharing icon resources The following paradigm demonstrates how to extract icons from another application and display it in your own program. CreateiconFromResourceEx (), Drawicon (), LookuPiconidFromDirectoryex (), and several other resource functions are called. Hicon Hicon1; // icon handle

Hinstance Hexe; // Handle To Loaded .exe file

HRSRC HRESOURCE; / / HANDLE for FindResource

HRSRC HMEM; // Handle for LoadResource

BYTE * LPRESOURCE; / / Address of Resource Data

Int nid; // id of resource That Best Fits Current Screen

HDC HDC; // Handle Of 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 = CREATEICONFROMROMROMRESOURCEEX ((pbyte) LPRESOURCE,

SizeOfResource (Hexe, HResource), True, 0x00030000,

CXICON, CYICON, LR_DEFAULTCOLOR

// Draw the icon in the client isa.

Drawicon (HDC, 10, 20, Hicon1);

● Compliance with icons: (icon fuctions) Copyicon

Createicon

CreateiconFromResource

CreateiconFromResourceex

CreateiconIndirect

Destroyicon

Drawicon

Drawiconex

GeticonInfo

Loadicon

LookuPiconidFromDirectoryex

● Structure of icons: (icon structures) iconinfo

Iconmetrics

● Message about icons: (icon message) WM_ERASEBKGND

WM_ICONERASEBKGND

WM_PAINTICON

YZ 2000- 8-5 night 8:50 finally modified in 2000-8-9

转载请注明原文地址:https://www.9cbs.com/read-128821.html

New Post(0)