message,
You will be able to figure out what this .RC file does by observing the execution of the program. A menu-bar with only one selection, “File”, drops down two menu-items: “Quit” and “Message...“. The next chapter has the same “Hi there” program, but written using high-level assembly constructs.
and are arbitrary labels, assigned
(almost) arbitrary values. One of these values is passed within a message as an identifier to Windows, if a menu-item is selected.
Message Format
Selecting a menu-item generates a message,
which is one of many possible messages that can be sent to the callback. It is a value, and
n o t a b l y and attached to the message.
So, this is what constitutes a message:
has other parameters, that constitute extra data
l message l l number) number) (32-bit number) (32-bit 32 bits) ( ) ( )
is 16 bits also, hence the (word) prefix. Every message has two parameters attached to it, and
the latter being 32 bits (hence the “1” prefix, meaning “long”). What these parameters contain depends upon the message. The prefixes are just a convenient notation for labels, so that we know what they represent (see page 82). Note that for applications, these parameters are all 32 bits (making the and “1” rather confusing, as these prefixes are still used).
Before we delve further in this direction, here is the file:
. . NAME DESCRIPTION EXETYPE STUB CODE DATA STACKSIZE EXPORTS SKELETON t h e r e ! p r o g r a m ’ WINDOWS PRELOAD PRELOAD MULTIPLE 1024 8192 SKELETONPROC
Skeletonproc() is the callback function, referred to as
in earlier notes. This is where Windows sends messages to be processed. An application can have a separate callback function for each window, dialog box, or control.
DOS stub fn sl $ $ rc link rc Borland Make
I have explained various aspects of the .DEF tile throughout this book, so investigate via the index. Some of the lines are self-explanatory. is a program supplied by the software vendor, that is incorporated into the overall .EXE tile, and is executed if you try to run the program from the DOS command line. It just displays a short message and quits.
I have put the DOS stub to very interesting use in Chapter 14.
Make File
Before we go ahead with the application itself, let’s consider the Make file. This determines the assemble, compile, and link steps. With reference to Figure 3.2 on page 74, the first step is to assemble SKELETON.ASM to produce SKELETON.OBJ (any Include files are also assembled). MASM and TASM have various directives to aid with creating Windows applications; however, by writing the program at the most fundamental level I have avoided these, which means that just about any assembler should work. You can see in the listing below how RC.EXE is used to compile SKELETON.RC and how to incorporate into SKELETON.EXE. LINK converts the .OBJ to and LIBW.LIB provides connection to the Windows functions. LIBW.LIB is itself a library. Note also that LINK refers to the .DEF tile.
#
= s k e l e t o n
$ . r c
-r $
.exe
link /NOD, libw rc
You create this on a text editor. It requires a certain syntax, and Make programs from different vendors have their own peculiarities. The above will work with Microsoft’s NMAKE.EXE and is for MASM versions prior to 6.00. The latest MASM requires modifications to the Make file (refer page though it can be made command line compatible with
B o r l a n d v s Borland’s TASM is different again (refer to page because TASM and TLINK have their own command line syntax. M a k e Borland’s MAKE.EXE also has its own peculiar syntax
3.00 (and later) is supposed to be more compatible with NMAKE (this is doubtful see my comments in Chapter 14).
use a
The Make file saves you the trouble of typing in all the assemble, Make fife? compile, and link steps at the command line. Some integrated environments generate the Make file automatically, so you don’t even have to do that much, but there are some sound reasons for learning about and using Make files, not the least of which is flexibility. Some integrated environments generate what is called a project file, which is saved with a special extension, and with some products it is possible to convert a project tile into a Make file. The fundamental difference in usage is that in the integrated environment you do everything via pull-down menus, while you run the Make file from the command line.Programmer’s Microsoft’s Programmer’s Workbench (PWB) is an example of an Workbench
of above Make file
Windows
integrated environment that works with Make files in its native mode, though the Make files are highly stylised. can, however, read ordinary Make tiles, and you can open a “project” by opening many of the Make files given in this book.
You can figure out what the above Make does: it assembles SKELETON.ASM using t h e n i t c o m p i l e s
SKELETON.RC using then links everything
together, and finally RC.EXE is executed again to combine
SKELETON.EXE and (the compiled output
from the first RC execution) to produce the final SKELETON.EXE.