In this lesson you will create a simple mosaic game. You probably know this kind of puzzles. An image or a matrix of numbers have to be placed in the right order by shuffeling the pieces into place. This lesson will teach you how to create this game step by step. It is useful to read the tutorials first before you start with this lesson. It's level is aimed at the beginner, everything is explained.
This lesson is aimed at the beginner in asm. Every step in creating the program is explained. It is not just source code with comments, but it teaches you how to build up a program from scratch. My advice is to fully read the tutorial, and try to make the program yourself. This lesson is quite long but it will help you very much if you read it all.
Make sure you have the following installed:
· The masm32 package, version 6 with at least service pack 2 (.NET/">win32asm.cjb.net)
· A good resource editor. This is not necessary, but a lot easier to do it by hand. To make this lesson accessible for anyone, I'll explain how to write the resources by hand (they are simply text files), but if you know how to use a resource editor you can use that instead. Good resource editors are: Borland Resource Workshop* (protools.cjb.net) and the resource editor in Microsoft Visual Studio (Visual C++).
· A resource compiler (rc.exe will do for hand written files and microsoft visual studio's resource editor, but not for BRW).
· make sure that you have included the masm32bin folder and the paths of the other necessairy tools included in your path.
· 一个资源编译器（rc.exe可以用于手工写的文件和微软Visual Studio的资源编辑器，但不可以用于BRW）
* BRW is no longer supported by Borland so you can DOWNLOAD this legally (although I don't know for sure), but you need the brc32 tool to compile it (their resoure format is somewhat different from microsoft's, so using rc.exe wouldn't work). This tool is included in the TASM package but you cannot download this legally.
As this is a lesson for the real beginners, this list of definitions can be useful. Read them if you don't know them already, it will help you understand the rest of the lesson.
A resource is data that is stored in the program file. A resource can be an icon, a table with strings, menu, dialog, bitmap, user defined data etc. The resources are first defined in a .rc file. This is a simple text file which you can write manually but it's much easier to use a resource editor like borland resource workshop or the editor in visual studio. The resources are then compiled into a binary file (.res). This file is then linked (yes with link) to the executable. Resources are accessed by their IDs. These IDs can be set in the resource file and in your source code you use the same ID to access the resource.
Owner-drawn windows are windows that are drawn by the program instead of the system. In this lesson a static control is used as an owner-drawn window. A WM_DRAWITEM message is sent to the window when the control needs to be drawn.
Local variables are variables (i.e. data) that is used only in a specific procedure. Local data is saved while the procedure is running, but deleted afterwards (it is stored on the stack). Local variables are declared with LOCAL at the start of a procedure:
SomeProc proc ....
资源是储存在程序文件中的数据。一个资源可以是图标，字符串的表格，菜单，位图，用户定义的数据等。资源先在rc文件中定义。这是一个你可以手工写的简单纯文本文件但用像Borland Resource Workshop或Visual Studio中的工具会更简单。然后，资源被编译为二进制文件（.res）。再后，文件被链接（是的，用链接器）到可执行文件中。资源通过它们的ID(s),存储。这些ID可以在资源文件中设置而且在你的源代码中，你使用相同的ID来读取资源。
SomeProc proc ....
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/10752043/viewspace-991721/，如需转载，请注明出处，否则将追究法律责任。