Step 3. Add a Pop-up Menu to the Status Bar
VFW082 – Toolbars, Menus and Pop–up Menus
A
component can be associated with most of the visual components on a form. A right click on this visual component will then display the "context menu".You will add date and time fields to the right side of the
bar and the will then control whether the date and time fields are visible.1. From the
tab, drag and drop the STD_DATEX field into the right hand side of the S .2. Hide its label by changing its 0 and then reduce its as required..
property to3. Add field STD_TIMX to the right hand side of the
. Hide its label and adjust its width. Your form should now look like the following:
Hint: If you have difficulty adding the Time field, drop it onto the buttons and it will be positioned on the right hand side of the status bar.
4. Set both the date and time fields true.
property to5. In this step you will ensure both the date and time fields have a value.
a. Add logic to the form's Initialize event routine to set STD_DATEX to current date:
#STD_DATEX := *date
b. Drag and drop a
component onto your form. This is a non-visual component. The component definition is:Define_Com Class(#PRIM_TIMR) Name(#TIMR_1)
c. In the source editor, select the timer component name and use the context menu to create a click event routine.
d. Add logic to the timer click event to set STD_TIMX to current time:
Evtroutine Handling(#TIMR_1.Tick) Options(*NOCLEARMESSAGES *NOCLEARERRORS)
#STD_TIMX := *time
Endroutine
Note: In this case, there is no need for other code. The standard timer behavior is to fire a click event every second. This is defined by its property of 1,000. Setting the to 0 will stop the timer.
The also has a and method.
6. Compile and execute your form to check that you are displaying a date and time.
7. Close your form.
8. Continue on the
tab, by dragging and dropping a component onto the .The
will be shown at the top of the tab:
9. Define two menu items, Show &Date and Show &Time. Create a event for the new menu items.
10. In the PMNU_1.
view, select the and review its properties. Note that it now has a property of
Date and time are initially visible.
11. On the
tab, select the and use the context menu to .a. Set both True.
items property tob. Complete the true / false and = true / false.
event code for the component, to switch the date and time from =Your code should look like the following:
Evtroutine Handling(#MITM_16.Click)
#STD_DATEX.visible := *Not #STD_DATEX.visible
#MITM_16.checked := *Not #MITM_16.checked
Endroutine
Evtroutine Handling(#MITM_17.Click)
#STD_TIMX.visible := *Not #STD_TIMX.visible
#MITM_17.checked := *Not #MITM_17.checked
Endroutine
12. Compile and test your form.