Presentation is loading. Please wait.

Presentation is loading. Please wait.

Resource scripts.

Similar presentations


Presentation on theme: "Resource scripts."— Presentation transcript:

1 Resource scripts

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

3 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.)

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

5 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”.

6 Using resources... Load* functions:
LoadString LoadIcon etc... We need to know instance handle of executable.

7 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.

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

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

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

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

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

13 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 DestroyObject.

14 Mouse cursors Cursors are defined similar to icons and loaded with the function LoadCursor.

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

16 Table is loaded with function LoadString:
hInst – handle of library, containing string uID – identificator of string lpBuffer – array to acquire strings value nBufferMax – how many characters should be read Function returns number of characters read.

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

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

19 VIRTKEYS

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

21 LoadAccelerators Accelerators are loaded with LoadAccelerators function:

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

23

24 When multiple document interface (MDI) program is written, we need to react to subwindows accelerators. Function TranslateMDISysAccel is used:

25 Menu

26

27 Ampersand (&)

28 Version Version information is stored in resource file:

29 Dialogs Dialog window has such structure:

30 Dialog example


Download ppt "Resource scripts."

Similar presentations


Ads by Google