(译)win32asm实例-3

 翻译以得到原作者的授权。在此向他表示感谢!

-译者

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资源ID

In 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来用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值