Pushbuttons can be created either using the Designer or in code.
Designer: You can use the Designer to create a pushbutton field. If you do not use the Designer to generate your main program, you will need to remember to #include vv_push.h.
Code: To create a pushbutton in code, follow the steps outlined below:
Step 1: Include the header file vv_push.h.
Include the pushbutton header file vv_push.h in all modules that use pushbuttons and in your main() module before vv_main.h.
Step 2: (Optional) Place a box around the pushbutton.
If you want a box around your pushbutton, define the box first by calling the function bg_boxdef(). See Chapter 15, "Changing the Appearance of Data Forms," for more information on the function bg_boxdef().
Step 3: Define the pushbutton field using pb_def().
Pushbuttons are defined using the special pushbutton definition function, pb_def():
|
where act_func is a pointer to the function you want to execute when the button is pushed. This function is called a pushbutton action function; see Chapter 31, "Writing User Functions," for more information on how to write a pushbutton action function.
The following code fragment illustrates Steps 2 and 3:
|