Tutorial - Adding and Customizing a Menu Bar and Toolbar | Tutorial - Using Bitmaps to Change the Mouse Pointer |
This chapter describes how to add an ActiveX Control to your screenset. You need to have read the chapter Programming Your Own Controls and the previous tutorials before looking at this one.
The following sections take you step by step through changing a screenset to use the supplied clock ActiveX control.
The aim of this tutorial is to display the supplied ActiveX clock control when you double-click on the time on the status bar. You will be shown how to use an ActiveX control later, but for now we will open customer.gs in Net Express and define the following objects in the screenset:
BUTTON-SELECTED MOVE " " IO-TEXT-BUFFER2(1) SET-FOCUS SET-ALARM-DIALOG
BUTTON-SELECTED UNSHOW-WINDOW CLOCK-DIALOG $NULL
Do not delete the CLOCK-DIALOG dialog box, as this will cause the alarm not to function.
Link this to the ALARM-HOURS master field.
Link this to the ALARM-MINUTES master field.
The master field for this entry field should be IO-TEXT-BUFFER2.
BUTTON-SELECTED BRANCH-TO-PROCEDURE SET-ALARM
BUTTON-SELECTED DELETE-WINDOW SET-ALARM-DIALOG $NULL
CR BRANCH-TO-PROCEDURE SET-ALARM ESC DELETE-WINDOW SET-ALARM-DIALOG $NULL SET-ALARM * Dialog will be added here later.
Having completed these steps, you can add the dialog to use the left-mouse-button-double-click event that you added in the earlier tutorial to display the CLOCK-DIALOG dialog box. See the section Customizing the Status Bar Control Program in the chapter Tutorial - Adding and Customizing a Status Bar.
In the left-mouse-button-double-click event callback, you added code to send user event 34591 when the callback was triggered. The code you added also places the section number of the status bar on which the double-click event happened into the NUMERIC-VALUE(1) data item.
With this information, you can add the following to the MAIN-WINDOW dialog table to process the double-click user event:
USER-EVENT XIF= $EVENT-DATA 34591 DOUBLE-CLICK-EVENT DOUBLE-CLICK-EVENT IF= NUMERIC-VALUE(1) 5 DOUBLE-CLICK-ON-CLOCK DOUBLE-CLICK-ON-CLOCK SET-FOCUS CLOCK-DIALOG
This dialog causes the CLOCK-DIALOG dialog box to be shown if the MAIN-WINDOW window receives user event number 34591, and NUMERIC-VALUE(1) is set to 5 (the 5th section of the status bar contains the clock).
A separate demonstration of applying this functionality is provided in the clock.gs screenset and documented in the file clockds.txt
If you have followed the tutorial, you will have created a CLOCK-DIALOG dialog box in your screenset. You can now add the supplied Dialog System clock ActiveX control to this dialog box.
Add the following data definitions to your screenset:
CLOCK-DIALOG-ACTIVEX-OBJREF OBJ-REF ACTIVEX-PARAMETERS 1 PARM-NAME X 30.0 P1 C5 4.0 P2 C5 4.0 P3 OBJ-REF
You must make sure that the last four items are indented, to show they are group items.
The first data item listed is used to store the object reference of the ActiveX . The master field group specified is used as the second parameter when calling the ActiveX control program.
The next step is to position the ActiveX control on the CLOCK-DIALOG dialog box:
The control is added to the ActiveX toolbar, from where you can select it and place it on the status bar of the customer screenset.
The ActiveX Control Properties dialog box opens when you position the ActiveX control.
Click OK.
When the control has been painted, a Property List dialog box is displayed. This shows some (not always all) of the configurable properties that the control provides. You can change the values in either this list or use the Controls context menu to view the full list of properties via the ActiveX property page context menu choice.
In the case of the Dialog System clock ActiveX, the available properties are the background bitmap, and whether the clock displays as analog or digital.
You need to add the dialog to handle the user event that indicates that the alarm time has been reached. Add the following to the CLOCK-DIALOG dialog box:
USER-EVENT IF= $EVENT-DATA 34570 ALARMGONEOFF ALARMGONEOFF INVOKE-MESSAGE-BOX ALARM-GONE-OFF-MBOX IO-TEXT-BUFFER2(1) $REGISTER
Finally, you need to complete the SET-ALARM procedure that you added to the dialog for the SET-ALARM-DIALOG dialog box earlier. This procedure invokes the SetAlarm method in the ActiveX control to set the alarm. Add the following dialog below SET-ALARM:
SET-MOUSE-SHAPE SET-ALARM-DIALOG "SYS-WAIT" MOVE ALARM-HOURS P1(1) MOVE ALARM-MINUTES P2(1) NULL-TERMINATE IO-TEXT-BUFFER2(1) CLEAR-CALLOUT-PARAMETERS $NULL CALLOUT-PARAMETER 1 IO-TEXT-BUFFER2(1) $null CALLOUT-PARAMETER 8 P3(1) $NULL INVOKE "chararry" "withValue" $PARMLIST
This dialog demonstrates the passing of the Message text (in IO-TEXT-BUFFER2(1)) as an object reference to a CharacterArray instance. Note the use of the functions NULL-TERMINATE and INVOKE for the P3(1) variable. These functions are described in detail in the Help. Add the following dialog:
MOVE "INVOKE-ActiveX-METHOD" CALL-FUNCTION(1) SET OBJECT-REFERENCE(1) CLOCK-DIALOG-ActiveX-OBJREF MOVE "SetAlarm" PARM-NAME(1) CLEAR-CALLOUT-PARAMETERS $NULL CALLOUT-PARAMETER 1 FUNCTION-DATA $NULL CALLOUT-PARAMETER 2 ActiveX-PARAMETERS $NULL CALLOUT "ocxctrl" 0 $PARMLIST CLEAR-CALLOUT-PARAMETERS $NULL CALLOUT-PARAMETER 8 P3(1) $NULL INVOKE P3(1) "finalize" $PARMLIST DELETE-WINDOW SET-ALARM-DIALOG $NULL
You have now completed adding the Dialog System clock ActiveX control to your screenset. Save your screenset and run it to try out the changes you have made.
Copyright © 2000 MERANT International Limited. All rights reserved.
This document and the proprietary marks and names
used herein are protected by international law.
Tutorial - Adding and Customizing a Menu Bar and Toolbar | Tutorial - Using Bitmaps to Change the Mouse Pointer |