翻译以得到原作者的授权。在此向他表示感谢!
-译者
3.0 - Resource file资源文件We will only add some icons to our resource file for now, and change it later.
现在我们仅仅添加一些图标到我们的资源文件中,再后面还要改变它。
Create a new empty text file called mosaic.rc in your mosaic folder. Put the following text in the file:
在你的mosaic文件加中创建一个名为mosaic.rc的空白文本文件。把一下文本输入文件:
#include "\masm32\include\resource.h"
#define ICON1_BIG 400
#define ICON2_SMALL 401
ICON1_BIG ICON DISCARDABLE "resources\\big.ico"
ICON2_SMALL ICON DISCARDABLE "resources\\small.ico"
If you have a resource editor and you know how to use it, you can make the resource file with an editor, but I will show you how to do it by hand, so everyone can create a resource file, even without a resource editor.
如果你有一个资源编辑器而且你知道如何使用它。你可以用编辑器创建资源文件,但我会向你展示如何用手工的方法完成它。因此每个人都可以创建资源文件,即使没有资源编辑器。
The #include statement includes a file called resourece.h from the masm32 package. This file is included in the masm package so you can use some constants in your resource definitions (like dialog styles etc.). The #defines associate a resource name (ICON1_BIG) with an ID (400 decimal). After you've defined a name, you can define the resource:
#include语句从masm包中包含了一个名为resource.h的文件。这个文件在masm包中因而使得你可以在资源定义中使用一些常熟(比如对话框的样式等)。#define把资源名(ICON1_BIG)和ID(十进制400)关联起来。在你定义了名字后,你可以定义资源:
ICON1_BIG ICON DISCARDABLE "resources\\big.ico"
This line adds an icon to the resource file (note the double backslash in the filename, always do this, a single backslash is an escape character). The resource is read from the file big.ico in the resources folder. For the small icon it works the same.
这行代码把一个图标加入资源文件(注意文件名中的两个反斜杠,每次都要这么作,单个的反斜杠试转义字符)。资源从资源文件夹中的big.ico中读取。对于小图标也是一样。
3.1 - Resource IDs资源IDIn order to use the resources, you will have to know their IDs. We will define IDs in the include file mosaic.inc. Add the two IDs for the icons to your mosaic.inc file:
为了使用资源,你要知道它们的ID。我们将在包含文件mosaic.inc中定义ID。把这两个图标的ID加入你的mosaic.inc文件:
ICON1_BIG equ 400
ICON2_SMALL equ 401
Now you can use ICON_BIG and ICON_SMALL in your programs as an ID.
西拿在你可以在你的程序中把ICON_BIG 和 ICON_SMALL当作ID来用。
本文地址:http://com.8s8s.com/it/it29707.htm