Resources | Resources |



Using date and time widget

The date and time widgets are instantiated by passing AEECLSID_CJulianDateWidget or AEECLSID_CJulianTimeWidget to ISHELL_CreateInstance() or IEnv_CreateInstance().

This example creates both a date widget and a time widget, sets various properties for these widgets, and inserts them into a prop container.

   IWidget *piDateWidget = NULL;
   IWidget *piTimeWidget = NULL;
   IPropContainer *picProp = NULL;
   IWidget *piwProp = NULL;
   int nErr = AEE_SUCESS;
   WidgetProp WidProp;
   WidgetExtent we;
   IBitmap *pib = NULL;

   ERR_TRY( ISHELL_CreateInstance(piShell, AEECLSID_CPropContainer, (void**) 
   ERR_TRY( IPropContainer_QueryInterface(picProp, AEEIID_IWidget, (void**)
   ERR_TRY( ISHELL_CreateInstance(piShell, AEECLSID_CJulianDateWidget, (void**) 
   ERR_TRY( ISHELL_CreateInstance(piShell, AEECLSID_CJulianTimeWidget, (void**) 
   pib = ISHELL_LoadBitmap(piShell, "images/arrows.bmp");
   if (NULL == pib) {

   // Set arrow image for date/time widget
   ERR_TRY( IWidget_SetImageStrip(piDateWidget, pib));
   ERR_TRY( IWidget_SetImageStrip(piTimeWidget, pib));

   // Set arrow padding for date/time widget
   ERR_TRY( IWidget_SetArrowPad(piDateWidget, 5));
   ERR_TRY( IWidget_SetArrowPad(piTimeWidget, 5));

   we.height = 60;
   we.width = me->rcContainer.dx;

   IWidget_SetExtent(piDateWidget, &we);
   IWidget_SetExtent(piTimeWidget, &we);

   ERR_TRY(IWidget_SetTopPadding(piwProp, 20));
   ERR_TRY( IWidget_SetBGColor(piwProp, RGB_TAB_2));
   ERR_TRY( IWidget_SetFlags(piDateWidget, DTWF_USEUPDOWNKEYS | 
   ERR_TRY( IWidget_SetFlags(piTimeWidget, DTWF_USEUPDOWNKEYS | 

   WidProp.bVisible = TRUE;
   WidProp.prop = WIDGET_KEEP_EXTENT;
   ERR_TRY( IPropContainer_Insert(picProp, piDateWidget, WIDGET_ZNORMAL, 
   ERR_TRY( IPropContainer_Insert(picProp, piTimeWidget, WIDGET_ZNORMAL, 
   ERR_TRY( ICardContainer_Insert(picc, piwProp, WIDGET_ZBOTTOMMOST) );