In this section:
This format defines a bit mapped button or a whole toolbar. The names of three bitmap resources representing the off state, on state, and depressed state should be supplied as character string arguments, followed by an INTEGER argument that represents the state (0 = off, 1 = on). In the absence of a call-back function, pressing the button toggles the state, but does not close the format window. The correct order for the arguments is as follows:
'BMPoff', 'BMPon', 'BMPdown', ControlVariable, Callback
Any button on the toolbar can be set to an inactive/disabled state by using the (~) tilde format modifier. An extra bitmap will be required to represent this state.
BMPoff', 'BMPon', 'BMPdown', 'BMPdisabled', ControlVariable,
The caret character (^) is used in association with a call-back function and this will be called whenever the user clicks on the button.
In order to obtain the effect of a non-toggling button, simply specify the same bitmap for the on and off states, and supply a call-back function to respond to each button press. Note that bitmaps may look different on screens of different resolutions. Where necessary the program should supply the appropriate bitmaps for the resolution in use. Bitmaps can be created using the standard Microsoft "Paint" accessory.
Here is a simple example of the use of bitmap buttons:
The file d20.rc contains:
BT_OFF BITMAP "BT1.BMP"
BT_ON BITMAP "BT2.BMP"
BT_DOWN BITMAP "BT3.BMP"
Using the optional parameters n and m it is possible to create a whole toolbar as a rectangular array of buttons n items across by m deep. For example, a 1-deep horizontal bar of 10 items would be represented by %10.1tb (or just %10tb) together with 30 bitmap resources as the corresponding arguments.
If call-back functions are used, these follow each set of bitmaps thus: 'off1', 'on1', 'down1', func1, 'off2', 'on2', 'down2', func2,... etc. If the "?" modifier is used, then n × m help strings must be provided. It is particularly valuable to provide such help in the case of toolbar buttons, since their meaning is not always obvious. The following example creates a 3-element horizontal toolbar with help information and call-back functions. The second button is initially set to the on state.
INTEGER function func1()
The file d21.rc contains:
OFF1 BITMAP "BT1.BMP"
ON1 BITMAP "BT2.BMP"
DWN1 BITMAP "BT3.BMP"
OFF2 BITMAP "BT1.BMP"
ON2 BITMAP "BT2.BMP"
DWN2 BITMAP "BT3.BMP"
OFF3 BITMAP "BT1.BMP"
ON3 BITMAP "BT2.BMP"
DWN3 BITMAP "BT3.BMP"