!short: IhDate              Date input with an attached calendar
   NAME
      Ihdate

   DESCRIPTION
      The 'Date' item is an edit field like the IhEdit item,
      but with the difference of having an associated drop
      down calendat where the user can select a date. The user can 
      either enter data in the Date edit window in the same manner as 
      an IhEdit item, or select a date for the edit window from 
      the attached calendar. The iDate item is guranteed to return
      a valid date if the user exits normally (F10). If the user
      cancels (F9 or ESC), the return field is undefined.


   POSITION/DIMENSION
      PosX and PosY define the upper left corner of the Date item.

      The Width information should always be -11 (the longest possible
      date DD/MM/YYYY, plus 1).

      Information in the 'Depth' field is ignored - the depth of
      the item depends only on the font that you chose to use in
      it.

   TEXT
      The Text field is used to display the label preceding the
      actual edit area. Since you have two choices for the date
      format (DD/MM/YY or MM/DD/YY), we recommend that you tell
      your users which format you expect by including 'DD/MM/YY'
      or 'MM/DD/YY' as part of the text (or somewhere nearby using
      a static item).

   FLAGS
      None are currently defined specifically for this item type.

   INIT
      The Combo item has this MANDATORY INIT structure:

      typedef struct {
	IHEDINIT Ei;   /* IhEdit structure (see IhEdit)   */
	int InitialDate[3]; /* Initial date to display */
	int Format;    /* DDMMYY or MMDDYY */
      }IHDTINIT;


      Ei          - This is an Edit Initialisation structure. See
		    IhEdit item description for more information
		    about this initialisation part of this structure.
		    Note that the initial string value should point
		    to an empty 11-character buffer. IHDATE uses this
		    to build the initial display string.


      InitialDate - This is a three element int array that contains
		    the day in the first element (InitialDate[0]),
		    the month in the second element and the year,
		    in four digit format, in the third element.
		    This date information overrides any initial
		    display string you specify in the Ei structure.
		    Note that the order of the element in this array
		    (DD, MM, YY) is not affected by the format you
		    specify (DDMMYY or MMDDYY). The Format only
		    affects how the user sees and enters dates.
		    To make it easier to work with, we have created
		    three definitions that correspond to the three
		    elements DAY, MON and YR.
		    Some restrictions:

		    - The day (InitialDate[0]) can be any value
		      between 1 and 31, assuming the day is valid
		      for the month you specify (don't forget
		      leap years!).
		    
		    - The month (InitialDate[1]) can be any value
		      between 1 and 12, with 1=jan, 2=Feb, etc.
		    
		    - The year (InitialDate[2]) can be any value
		      between 1971 and 2070. This limitation is based
		      on the fact that we have to allow users to
		      enter 2-digit years (i.e. 97), so we make some
		      assumptions about the century. If the user
		      enters a year more than 70, we assume 1900;
		      if it's 70 or less, we assume 2000 (no millenium
		      bug here!).

      Format      - This is an int that determines how the user
		    sees and enters dates manually. The two possible
		    values are MMDDYY (U.S) and DDMMYY (Europe).
		    


   FOCUS/KEYS
      The edit item displays a cursor when it has the input
      focus. It reacts to the DEL, BACKSPACE, HOME, END and
      cursor keys in the way you would expect. The INSERT key
      toggles insert/overstrike mode.

   GETDLGITEM
      int GetDlgItem(DIALOG *pDlg, int ItemNbr, int n, void *Dest)

      See the description of GetDlgItem for details on the
      parameters to this function. The combo item supports the
      following GetDlgItem variants:

      n = EDGI_INT: Dest should be a pointer to an integer. It
		    will get the integer value currently in the
		    edit field.

      Note: The Dest variable has to point to a three element int
      array (i.e. int ReturnDate[3] would be passed as ReturnDate).
      This array contains the selected day in the first element
      (i.e. ReturnDate[0]), the month in the second element
      (i.e. ReturnDate[1]), and the year in the last element
      (i.e. ReturnDate[2]). If the user cancel's out of the
      dialog box (F9 or ESC), these values are undefined.

   SETDLGITEM
      int SetDlgItem(DIALOG *pDlg, int ItmNbr, int n, void *pData)

      See the description of SetDlgItem for details on the
      parameters to this function. The date item supports only
      one SetDlgItem variant currently:

      n = EDSI_TXT: pData points to a date string that will be copied
		    into the edit area of the Date box. The date
		    has to be in the format you specified in the 
		    init structure (i.e. 'DD/MM/YY' or 'MM/DD/YY').
	 

   NOTE
      If you provide a pointer to an IHDATE structure in your
      combo item, you _must_ give valid values for all four
      fields. You cannot for example provide a value for
      'Contents', and leave RealLen and Font zero - this will
      yield erratic behavior.

   SAMPLE
#include <stdio.h>
#include <stdlib.h>
#include "pal.h"

#define CBSELECT 0
#define DATESEL 1

	IHCBINIT CBPICK1 = {
      {"Default text",  50, MEDIUM_FONT },
      " Alpha | Beta | Gamma | Delta | Epsilon"
      };
	char datebuf[11];
	IHDTINIT DATEINIT = {
      {datebuf,  11, MEDIUM_FONT },
      };

      DLGITEM pickItems[] = {
      /* X  Y   W   D   FLAGS     LABEL       INIT       TYPE           SIZE        PRIV */
      { 57, 44,274, 14,   0L, "Name:",     &CBPICK1,   IhCombo , sizeof(IHCOMBO ), NULL },
      { 57, 64, -11,  0,   0L, "Date:",      &DATEINIT,  IhDate  , sizeof(IHDATE  ), NULL },
      { 90, 14,220, 10,   0L, "Please select.", NULL,  IhStatic, sizeof(IHSTATIC), NULL }
      };

      DIALOG pick = {
      410, 122, 0L, 0, 3, pickItems, DhStandard, NULL, NULL, 0
      };

      void main(void)
      {
	 char Buffer[200];
	 char Buffer1[200];
	 char buf[80];
	 int  DateBuf[3];

	 DATEINIT.InitialDate[0] = 0;
	 DATEINIT.InitialDate[1] = 0;
	 DATEINIT.InitialDate[2] = 0;
	 DATEINIT.Format = MMDDYY;
	 if(!PalInit(1)) exit(-1); /* Initialize PAL */
	 InitDialog(&pick);   /* init dialog */
	 ShowDialog(&pick, 10, 10, " Select values, F10 when done");
	 HandleDialog(&pick, NULL);
	 GetDlgItem(&pick, CBSELECT, EDGI_TXT, Buffer);
	 GetDlgItem(&pick, DATESEL, EDGI_TXT, DateBuf );
	 CloseDialog(&pick);     /* close dialog */
	 PalDeInit(1);

	 printf("You have selected: %s\n", Buffer);
	 printf("Date selected: %d/%d/%d\n", DateBuf[1], 
		 DateBuf[0], DateBuf[2]);
      }
