Resource scripts rc exe Windows SDK has a






























- Slides: 30

Resource scripts

rc. exe • Windows SDK has a special tool – rc. exe – resource script compiler.

What is it? • File containing GUI data and when compiled can be linked with program. • When linked, program can use data in resource scripts (e. g. version, icon, etc. )

Resource types • • • drop-down menu popup menu strings keyboard accelerators icons bitmap images dialog boxes Version mouse cursors

Before we start. . . • RS syntax is similar to taht of C. For example, rc. exe uses standard C preprocessor. • It is possible to write macro commands • Header file “resource. h”.

Using resources. . . • Load* functions: • Load. String • Load. Icon • etc. . . • We need to know instance handle of executable.

MAKEINTRESOURCE • Resources has a name, which can be string or numeric identificator. • On numeric case number can not be longer than 16 bits. • When addressing resource we use name – unikodine string. . . To not confuse numeric identificator with string, the macro MAKEINTRESOURCE is used, which converts an integer value to a resource type compatible with the resource-management functions.

Prefixes for resource names • • IDS – string IDM – menu IDC – command IDD – dialog IDA – accelerators IDI – icon or bitmap IDB – bitmap ID – unknown type

DISCARDABLE • To free memory from unused resources. • This keyword in 32 bits Windows systems is ignored.

Icons • Keyword ICON: • Executable will use first icon if there are few of them:

• Header file: • Loading icon from executable: • Alternatively with string:

• WNDCLASSEX has two types of icons: big and small. Small icon is made from 16 x 16 px, big – 32 x 32 px. If small icon is not provided – big icon is reduced. • If we use NULL handle, Windows will return default icon.

Bitmaps • Bitmaps can be used as icons: • Size of bitmaps can be big, thus Windows can return NULL value. • Remove bitmaps from memory by passing on the handle to function Destroy. Object.

Mouse cursors Cursors are defined similar to icons and loaded with the function Load. Cursor.

String tables • Strings are defined in the next way: • It possible to use BEGIN. . . END instead of { }.

• Table is loaded with function Load. String: • • h. Inst – handle of library, containing string u. ID – identificator of string lp. Buffer – array to acquire strings value n. Buffer. Max – how many characters should be read Function returns number of characters read.

Accelerators • Accelerators are common part of almost all software. • Accelerators table is described as such:

Examples Keys combinations are defined as characters or virtual key’s value:

VIRTKEYS

If accelerators are related with menu commands, then menu command will reveal on pressing accelerator, unless we use a keyword NOINVERT:

Load. Accelerators are loaded with Load. Accelerators function:

Translate. Accelerator • For program to “understand” accelerators message loop should be changed. • Function Translate. Accelerator changes keys values to relevant command messages


• When multiple document interface (MDI) program is written, we need to react to subwindows accelerators. Function Translate. MDISys. Accel is used:

Menu


Ampersand (&)

Version • Version information is stored in resource file:

Dialogs • Dialog window has such structure:

Dialog example