(譯)win32asm例項-3 (轉)

worldblog發表於2007-12-12
(譯)win32asm例項-3 (轉)[@more@]

 翻譯以得到原作者的授權。在此向他表示感謝!

-譯者

3.0 - Re 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 "masm32includeresource.h"

#define ICON1_BIG 400
#define ICON2_SMALL 401

ICON1_BIG ICON DISCARDABLE "resourcesbig.ico"
ICON2_SMALL ICON DISCARDABLE "resourcessmall.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 "resourcesbig.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來用。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-991737/,如需轉載,請註明出處,否則將追究法律責任。

相關文章