ContentsIndex Previous Next

6.10.16 ActiveX Example

Here is an excerpt of the copybook generated by AXDEFGEN for Microsoft's "Calendar Control 8.0". The copybook includes object names so that the compiler can distinguish between two classes with the same name in different objects. For example, you might want to create a "APPLICATION OF WORD" and a "APPLICATION OF EXCEL" in the same COBOL program. In the Calendar copybook, the line "OBJECT @MSACAL" specifies the object name.

* CAL.DEF - ActiveX control definitions for MSACAL
* Generated: Tuesday, June 22, 1999


 OBJECT @MSACAL

* Calendar control

*** Primary Interface ***

* Calendar
     CLASS @Calendar
         CLSID, 8E27C92B-1264-101C-8A2F-040224009C02
         NAME, "Calendar"
         PRIMARY-INTERFACE
         ACTIVE-X-CONTROL
         DEFAULT-INTERFACE, "ICalendar"
         DEFAULT-SOURCE, "DCalendarEvents"
* BackColor
         PROPERTY-GET, -501, @BackColor
                 RETURNING "OLE_COLOR"
* BackColor
         PROPERTY-PUT, -501, @BackColor,
             "OLE_COLOR (Property Value)"
* Day
         PROPERTY-GET, 17, @Day
                 RETURNING "short"
* Day
         PROPERTY-PUT, 17, @Day,
             "short (Property Value)"
* DayFont
         PROPERTY-GET, 1, @DayFont
                 RETURNING "IFontDisp*"
* DayFont
         PROPERTY-PUT, 1, @DayFont,
             "IFontDisp* (Property Value)"
* DayFontColor
         PROPERTY-GET, 2, @DayFontColor
                 RETURNING "OLE_COLOR"
* DayFontColor
         PROPERTY-PUT, 2, @DayFontColor,
             "OLE_COLOR (Property Value)"

* NextDay
         METHOD, 22, @NextDay
* NextMonth
         METHOD, 23, @NextMonth
* NextWeek
         METHOD, 24, @NextWeek
* NextYear
         METHOD, 25, @NextYear
* PreviousDay
         METHOD, 26, @PreviousDay
* PreviousMonth
         METHOD, 27, @PreviousMonth
* PreviousWeek
         METHOD, 28, @PreviousWeek
* PreviousYear
         METHOD, 29, @PreviousYear
* Refresh
         METHOD, -550, @Refresh
* Today
         METHOD, 30, @Today
* AboutBox
         METHOD, -552, @AboutBox
* Click
         EVENT, -600, @CalendarClick
*            No Parameters
* DblClick
         EVENT, -601, @CalendarDblClick
*            No Parameters
* KeyDown
         EVENT, -602, @CalendarKeyDown
*            2 Parameters
                 short* KeyCode
                 short Shift
* KeyPress
         EVENT, -603, @CalendarKeyPress
*            1 Parameter
*                short* KeyAscii
* KeyUp
         EVENT, -604, @CalendarKeyUp
*            2 Parameters
*                short* KeyCode
*                short Shift
* BeforeUpdate
         EVENT, 2, @CalendarBeforeUpdate
*            1 Parameter
*                short* Cancel
* AfterUpdate
         EVENT, 1, @CalendarAfterUpdate
*            No Parameters
* NewMonth
         EVENT, 3, @CalendarNewMonth
*            No Parameters
* NewYear
         EVENT, 4, @CalendarNewYear
*            No Parameters

After generating the copy book, you may create and use a Calendar control. You can add the control to your SCREEN SECTION as described in Sections 1.2.2 and 1.2.2.1 of this document, or you can use the DISPLAY statement in the PROCEDURE DIVISION to create the control. Note that the following two statements are equivalent:

    DISPLAY Calendar HANDLE IN my-cal.
    DISPLAY Calendar OF MSACAL HANDLE IN my-cal.

Here is an example of how you might update your PROCEDURE DIVISION to create, and then modify, the control: