|
IDL Connectivity Bridges: Using ActiveX Controls in IDL |
|
This example uses an ActiveX control that displays a calendar interface. The control, contained in the file mscal.ocx, is installed along with a typical installation of Microsoft Office 97, and may also be present on your system if you have upgraded to a more recent version of Microsoft Office. If the control is not present on your system (you'll know the control is not present if the example code does not display a calendar similar to the one shown in Figure 4-1), you can download a the control as part of a package of sample ActiveX controls included in the file actxsamp.exe, discussed in Microsoft Knowledge Base Article 165437.
If you download the control, place the file mscal.exe in a known location and execute the file; you will be prompted for a directory in which to place mscal.ocx. Open a command prompt window in the directory you chose and register the control as described in Registering COM Components on a Windows Machine.
The calendar control has the program ID:
MSCAL.Calendar.7
and the class ID:
{8E27C92B-1264-101C-8A2F-040224009C02}
| Example Code The following section develops an IDL routine called ActiveXCal that illustrates use of the calendar ActiveX control within an IDL widget hierarchy. The complete .pro file is included in the examples\doc\bridges\COM subdirectory of the IDL distribution as ActiveXCal.pro. |
ActiveXCal.pro file, this procedure occurs last.)PRO ActiveXCal
wBase = WIDGET_BASE(COLUMN = 1, SCR_XSIZE = 400, $ TITLE='IDL ActiveX Widget Calendar Control')
wSubBase = WIDGET_BASE(wBase, /ROW) wVoid = WIDGET_LABEL(wSubBase, value = 'Month: ') wMonth = WIDGET_LABEL(wSubBase, value = 'October') wSubBase = WIDGET_BASE(wBase, /ROW) wVoid = WIDGET_LABEL(wSubBase, VALUE = 'Day: ') wDay = WIDGET_LABEL(wSubBase, VALUE = '22') wSubBase = WIDGET_BASE(wBase, /ROW) wVoid = WIDGET_LABEL(wSubBase, VALUE = 'Year: ') wYear = WIDGET_LABEL(wSubBase, VALUE = '1999')
wAx=WIDGET_ACTIVEX(wBase, $
'{8E27C92B-1264-101C-8A2F-040224009C02}')
WIDGET_CONTROL, wBase, /REALIZE
WIDGET_CONTROL, wBase, $
SET_UVALUE = {month:wMonth, day:wDay, year:wYear}
WIDGET_CONTROL, wAx, GET_VALUE = oAx oAx->GetProperty, month=month, day=day, year=year
WIDGET_CONTROL, wMonth, SET_VALUE=STRTRIM(month, 2) WIDGET_CONTROL, wDay, SET_VALUE=STRTRIM(day, 2) WIDGET_CONTROL, wYear, SET_VALUE=STRTRIM(year, 2)
XMANAGER, 'ActiveXCal', wBase END
ActiveXCal.pro file, this procedure occurs before the ActiveXCal procedure.)PRO ActiveXCal_event, ev
WIDGET_CONTROL, ev.ID, GET_VALUE = oCal
state.WIDGET_CONTROL, ev.TOP, GET_UVALUE = state
ocal->GetProperty, month=month, day=day, year=year
WIDGET_CONTROL, state.month, SET_VALUE = STRTRIM(month,2) WIDGET_CONTROL, state.day, SET_VALUE = STRTRIM(day,2) WIDGET_CONTROL, state.year, SET_VALUE = STRTRIM(year,2)
HEAP_FREE, ev END
Running the ActiveXCal procedure displays a widget that looks like the following:
![]() |
IDL Online Help (March 06, 2007)