Icons

Icons can be either described within the resource file or stored separately in files with the ICO filename extension. Consider the latter case. Suppose that you have a resource file called RESU.RC:

 #define IDI_ICON1 1     IDI_ICON1 ICON "Cdrom01.ico" 

As you can see, this file contains only two lines. The first line defines the icon identifier, and the second one associates this identifier to the CDROM01.ICO file. The DEFINE operator is the C preprocessor directive. As you'll see later, the resource description language is similar to C. Compile the resource file called RESU.RC by issuing the following command: RC resu.rc. The new object file, RESU.RES, will appear on the disk. When linking the program, specify this file in the command line as follows :

 LINK /subsystem:windows resu.obj resu.res 

A question might arise: How do you use this resource in the program? The answer to this question is straightforward: Suppose that you need to set a new icon for the window. Here is a fragment of the program that sets a standard icon for the main window:

 PUSH IDI_APPLICATION     PUSH 0     CALL LoadIconA@8     MOV [WC.CLSHICON], EAX 

And here is the program fragment for setting the icon specified in the resource file.

 PUSH  1       ; Icon identifier (see the RESU.RC file) PUSH  [HINST] ; Process identifier CALL  LoadIconA@8 MOV   [WC.CLSHICON], EAX 

The BRCC32.EXE resource compiler (included with TASM32) allows the icon to be included in the project code. In this case, the project will appear as shown in Listing 9.1.

Listing 9.1: A resource file with an icon code
image from book
 #define IDI_ICON1 1 IDI_ICON1 ICON { '00 00 01 00 02 00 20 20 10 00 00 00 00 00 E8 02' '00 00 26 00 00 00 10 10 10 00 00 00 00 00 28 01' '00 00 0E 03 00 00 28 00 00 00 20 00 00 00 40 00' '00 00 01 00 04 00 00 00 00 00 80 02 00 00 00 00' '00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00' '00 00 00 00 BF 00 00 BF 00 00 00 BF BF 00 BF 00' '00 00 BF 00 BF 00 BF BF 00 00 C0 C0 C0 00 80 80' '80 00 00 00 FF 00 00 FF 00 00 00 FF FF 00 FF 00' '00 00 FF 00 FF 00 FF FF 00 00 FF FF FF 00 00 00' '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' '00 00 00 00 77 78 33 AA 00 00 00 00 00 00 00 00' '00 00 07 7F 77 78 33 AA 77 80 00 00 00 00 00 00' '00 0F F7 F7 77 78 33 AA 77 C8 60 00 00 00 00 00' '00 FF FF 7F 77 78 33 AA 78 C6 66 00 00 00 00 00' '0F FF FF F7 77 78 38 A7 7C 86 66 60 00 00 00 00' '77 FF FF 7F 77 78 37 A7 8C 66 66 77 00 00 00 07' '87 7F FF F7 F7 78 37 A7 C8 66 67 77 70 00 00 08' '78 77 FF FF 77 78 3A A8 C6 66 77 77 E0 00 00 87' '87 87 7F FF F7 78 3A AC 86 67 77 EE EE 00 00 78' '78 78 77 FF 7F 78 3A 8C 66 77 EE EE BB 00 07 87' '87 87 87 7F F7 78 3A C8 67 7E EB BB BA A0 08 78' '78 78 78 77 F8 88 88 C6 7E BB BB AA AA A0 07 87' '87 87 87 87 88 00 00 88 BB BA AA A3 33 30 08 78' '78 78 78 78 80 8F F8 08 33 33 33 DD DD DO 08 88' '88 88 88 88 80 FF FF 08 5D 5D 5D 5D 5D 50 05 D5' 'D5 D5 D5 D5 80 FF FF 08 88 88 88 88 88 80 0D DD' 'DD 33 33 33 80 8F F8 08 87 87 87 87 87 80 03 33' '3A AA AB BB 88 00 00 88 78 78 78 78 78 70 0A AA' 'AA BB BB E7 6C 88 88 8F 77 87 87 87 87 80 0A AB' 'BB BE E7 76 8C A3 87 7F F7 78 78 78 78 70 00 BB' 'EE EE 77 66 C8 A3 87 F7 FF 77 87 87 87 00 00 EE' 'EE 77 76 68 CA A3 87 7F FF F7 78 78 78 00 00 0E' '77 77 66 6C 8A A3 87 77 FF FF 77 87 80 00 00 07' '77 76 66 8C 7A 73 87 7F 7F FF F7 78 70 00 00 00' '77 66 66 C8 7A 73 87 77 F7 FF FF 77 00 00 00 00' '06 66 68 C7 7A 83 87 77 7F FF FF F0 00 00 00 00' '00 66 6C 87 AA 33 87 77 F7 FF FF 00 00 00 00 00' '00 06 8C 77 AA 33 87 77 7F 7F FO 00 00 00 00 00' '00 00 08 77 AA 33 87 77 F7 70 00 00 00 00 00 00' '00 00 00 00 AA 33 87 77 00 00 00 00 00 00 00 00' '00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF F0' '0F FF FF 80 01 FF FE 00 00 7F FC 00 00 3F F8 00' '00 1F F0 00 00 0F E0 00 00 07 C0 00 00 03 C0 00' '00 03 80 00 00 01 80 00 00 01 00 00 00 00 00 00' '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' '00 00 80 00 00 01 80 00 00 01 CO 00 00 03 CO 00' '00 03 E0 00 00 07 F0 00 00 0F F8 00 00 1F FC 00' '00 3F FE 00 00 7F FF 80 01 FF FF F0 0F FF 28 00' '00 00 10 00 00 00 20 00 00 00 01 00 04 00 00 00' '00 00 C0 00 00 00 00 00 00 00 00 00 00 00 00 00' '00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 80' '00 00 00 80 80 00 80 00 00 00 80 00 80 00 80 80' '00 00 80 80 80 00 C0 C0 C0 00 00 00 FF 00 00 FF' '00 00 00 FF FF 00 FF 00 00 00 FF 00 FF 00 FF FF' '00 00 FF FF FF 00 00 00 00 00 00 00 00 00 00 00' '08 87 3A 80 00 00 00 0F F8 87 32 CC 60 00 00 08' 'F8 87 32 C6 68 00 00 87 8F 87 2C 66 86 00 08 78' '78 87 2C 68 AA A0 07 87 87 70 08 2A A2 20 08 78' '78 0F F0 11 15 50 05 51 11 0F F0 87 87 80 02 2A' 'A2 80 08 78 78 70 0A AA 86 C2 78 87 87 80 00 68' '66 C2 78 F8 78 00 00 86 6C 23 78 8F 88 00 00 06' 'CC 23 78 8F F0 00 00 00 08 A3 78 80 00 00 00 00' '00 00 00 00 00 00 F8 1F 00 00 E0 07 00 00 C0 03' '00 00 80 01 00 00 80 01 00 00 00 00 00 00 00 00' '00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00' '00 00.80 01 00 00 80 01 00 00 C0 03 00 00 E0 07' '00 00 F8 1F 00 00' 
image from book
 


The Assembly Programming Master Book
The Assembly Programming Master Book
ISBN: 8170088178
EAN: 2147483647
Year: 2004
Pages: 140
Authors: Vlad Pirogov

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net