home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TURBCA.ZIP / TURBCALC.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1989-04-22  |  21.1 KB  |  595 lines

  1. unit TurbCalc;
  2.  
  3. interface
  4.  
  5. uses Dos,
  6.      TPCrt,
  7.      TPDate,
  8.      TPMouse,
  9.      TPString,
  10.      TPWindow;
  11.  
  12. procedure Calendar(X,Y,
  13.                    Current_Attr,
  14.                    Select_Attr,
  15.                    Other_Attr,
  16.                    CalFrame_Attr,
  17.                    CalHeader_Attr,
  18.                    HelpFrame_Attr,
  19.                    HelpHeader_Attr,
  20.                    HelpText_Attr,
  21.                    HelpChars_Attr : byte;
  22.                    Flag : boolean;
  23.                    var Year,Month,Day : word);
  24.  
  25. implementation
  26. {$V-}
  27.  
  28. const
  29.  
  30.   IntenseAttr : byte = $0F;   {default attribute for days of current month}
  31.   ReverseAttr : byte = $70;   {default attribute for selected day}
  32.   NormalAttr  : byte = $07;   {default attribute for days of non-current months}
  33.   BlinkAttr   : byte = $80;   {blink attribute, ORed with other attribute to
  34.                                cause blinking of current system date}
  35.  
  36.  
  37.   NULL  = #0;          {defines for ScanKey Function from MISCTOOL unit}
  38.   BELL  = #7;          {MISCTOOL is a unit supplied in the Turbo Pascal}
  39.   BS    = #8;          {Database Toolbox for TP4.  That software is NOT}
  40.   LF    = #10;         {required for operation of this unit, the necessary}
  41.   CR    = #13;         {code is included here}
  42.   ESC   = #27;
  43.   Space = #32;
  44.   Tab   = #9;
  45.  
  46.   {
  47.   The following constants are based on the scheme used by the scan key
  48.   function to convert a two key scan code sequence into one character
  49.   by adding 128 to the ordinal value of the second character.
  50.   }
  51.  
  52.   F1           = #187;
  53.   F2           = #188;
  54.   F3           = #189;
  55.   F4           = #190;
  56.   F5           = #191;
  57.   F6           = #192;
  58.   F7           = #193;
  59.   F8           = #194;
  60.   F9           = #195;
  61.   F10          = #196;
  62.   UpKey        = #200;
  63.   DownKey      = #208;
  64.   LeftKey      = #203;
  65.   RightKey     = #205;
  66.   PgUpKey      = #201;
  67.   PgDnKey      = #209;
  68.   HomeKey      = #199;
  69.   EndKey       = #207;
  70.   InsKey       = #210;
  71.   DelKey       = #211;
  72.   CopyRightKey = #255;
  73.  
  74.   Dpm   : array[0..11] of integer   = (31,28,31,30,31,30,31,31,30,31,30,31);
  75.   Names : array[0..11] of string[9] = ('January','February','March','April',
  76.                        'May','June','July','August','September',
  77.                            'October','November','December');
  78.  
  79. type
  80.  
  81.   BoxType  = array[1..242] of byte;   { this is an array type used to store
  82.                                         information about the month which is
  83.                                         being displayed
  84.                                        }
  85.  
  86.   DateType = record                    { type used internally, corresponds with }
  87.     Year,                              { the values returned by the GetDate     }
  88.     Month,                             { procedure in TP4                       }
  89.     Day,
  90.     DayofWeek : word;
  91.   end;
  92.  
  93.  
  94. var
  95.  
  96.   HelpWindow     : WindowPtr;              {window types from TPWindow}
  97.   CalendarWindow : WindowPtr;
  98.   KeyCode        : word;
  99.   Ch3            : char absolute KeyCode;
  100.   Tday,C,Extra,
  101.   Mo,TYear       : integer;
  102.   DayStr         : string[4];
  103.   Ch             : char;
  104.   Color          : byte;
  105.   YrStr          : string[4];
  106.   TodaysDate     : Datetype; {internal storage of current system date}
  107.   Date           : Datetype; {internal useage of date passed in var parameters}
  108.   Buffer         : pointer;  {needed for use by savewindow and restorewindow}
  109.   CalBox         : BoxType;  {
  110.                               actual array variable used to store calendar. This
  111.                               array contains one byte for the character of the
  112.                               display and one byte for its attribute
  113.                              }
  114.  
  115.   CalPtr         : pointer;  {pointer to location of calbox}
  116.   Chr1, Chr2     : char;
  117.   TempDate       : DateType;
  118.   N              : integer;
  119.   OldXY,
  120.   ScanLines      : word;
  121.  
  122. {.$DEFINE USEMOUSE}  { Remove the period to enable mouse support }
  123. {$IFDEF USEMOUSE}
  124.  
  125. {$F+}
  126. procedure MouseCalendarHandler;
  127.  
  128. begin
  129.   case MouseStatus of
  130.      BothButtons  : StuffKey($3B00); { simulate F1 key          }
  131.      LeftButton   : case MouseLastY of
  132.                       3 : if (MouseLastX = 11)
  133.                             then StuffKey($4B00)    { Decrement date }
  134.                           else
  135.                             if (MouseLastX = 18)
  136.                               then StuffKey($4D00); { Increment date }
  137.                       4 : if (MouseLastX = 11)
  138.                             then StuffKey($4800)    { Decrement month }
  139.                           else
  140.                             if (MouseLastX = 18)
  141.                               then StuffKey($5000); { Increment month }
  142.                       5 : if (MouseLastX in [10..13])
  143.                             then StuffKey($4900)    { Increment year }
  144.                           else
  145.                             if (MouseLastX in [16..19])
  146.                               then StuffKey($5100); { Decrement year }
  147.                       6 : if (MouseLastX in [7..9])
  148.                             then StuffKey($1C0D);   { Return with date }
  149.                     end; { of case }
  150.      RightButton  : case MouseLastY of
  151.                       7 : if (MouseLastX in [7..9]) then StuffKey($011B);
  152.                     end; { of case }
  153.   end; { of case }
  154. end;
  155. {$F-}
  156.  
  157. {$ENDIF}
  158.  
  159. function ScanKey : char;
  160.  
  161. {
  162. Reads a key from the keyboard and converts 2 scan code escape
  163. sequences into 1 character.
  164. }
  165.  
  166. begin
  167.   KeyCode := ReadKeyWord;
  168.   if lo(KeyCode) = 0 then begin
  169.     KeyCode := swap(KeyCode);
  170.     if ord(Ch3) < 128 then
  171.       Ch3 := Chr(Ord(Ch3) + 128);
  172.     ScanKey := Ch3;
  173.   end
  174.    else ScanKey := Ch3;
  175. end; { ScanKey }
  176.  
  177.   {*********************************************************}
  178.   {* The following two functions: leap_year and            *}
  179.   {* day_of_week are from the file EXDATE.PAS which is     *}
  180.   {* available in Data Library 2 of the Borland Turbo      *}
  181.   {* Pascal SIG on Compuserve.  These functions were       *}
  182.   {* authored by Ted Lassagne.                             *}
  183.   {*********************************************************}
  184.  
  185.  
  186. function Leap_Year(Year : integer) : boolean;
  187.  
  188. { Returns true for a leap year and false for others }
  189.  
  190. begin
  191.   if Year and 3 <> 0 then Leap_Year := false
  192.     else
  193.      if year mod 100 <> 0 then Leap_Year := true
  194.        else
  195.          if year mod 400 <> 0 then Leap_Year := false
  196.            else leap_year := true;
  197. end;
  198.  
  199. function Day_Of_Week(Day, Month, Year : integer) : integer;
  200.  
  201. {
  202. Returns integer day of week for date.  0 = Sunday, 6 = Saturday
  203. Uses Zeller's congruence.
  204. }
  205.  
  206. var Century, Yr, Dw : integer;
  207.  
  208. begin
  209.   if Month < 3 then begin
  210.     Month := Month + 10;
  211.     Year := Year -1
  212.   end
  213.   else
  214.      Month := Month - 2;
  215.   Century := Year div 100;
  216.   Yr := Year mod 100;
  217.   Dw := (((26*Month - 2) div 10)+Day+Yr+(Yr div 4)+
  218.     (Century div 4) - (2*Century)) mod 7;
  219.   if Dw < 0 then Day_Of_Week := Dw + 7
  220.     else Day_Of_Week := Dw;
  221. end;
  222.  
  223. procedure Calendar;
  224.  
  225. procedure StuffCal;
  226. {
  227. Tthis is the procedure which actually places the calendar on the screen.  The
  228. calendar is constructed in memory in its entirety and then placed on to the
  229. screen with the restorewindow procedure.  This is actually a trick since the
  230. calbox window was never saved.
  231. }
  232.  
  233. var
  234.   Count,S : integer;
  235.   Limit   :integer;
  236.  
  237. begin
  238.   Str(Date.Year,YrStr);              {make year string for display}
  239.  
  240.   { write name of month on top line of calendar window }
  241.   FastWrite(Center(Names[Date.Month-1]+' '+YrStr,20),Y+1,X+1,CalHeader_Attr);
  242.   { clear array each time }
  243.   for count:=1 to 242 do
  244.     if odd(Count) then
  245.       CalBox[count] := 32            {set character to 'space'}
  246.     else
  247.       CalBox[count] := NormalAttr;   {set attribute for character}
  248.   Count := 1;
  249.  
  250.   { get day of week for the month in question }
  251.   TDay  := Day_Of_Week(1,integer(Date.Month),integer(Date.Year));
  252.   TYear := Date.Year;
  253.   Mo    := Date.Month-1;  {constant dpm and names arrays are zero based}
  254.   Color := NormalAttr;    {set attribute to low intensity for days of month
  255.                            which precede month to be displayed}
  256.   S := 0;
  257.   C := 0;
  258.  
  259.   { set up calendar for last days of previous month }
  260.   if (TDay > 0) then
  261.     for S := 0 to TDay - 1 do begin
  262.       if ((Mo - 1 = 1) and (Leap_Year(Date.Year))) then
  263.                                                    { if the last month was }
  264.         Extra := 2                                 { February, check for   }
  265.       else                                         { leap year             }
  266.         Extra :=1;
  267.       if (Mo = 0) then
  268.         DayStr := Long2Str((Dpm[Mo+1]+S-TDay+Extra)) { make 2 character string }
  269.       else                                           { for number value of day }
  270.         DayStr := Long2Str((Dpm[Mo-1]+S-TDay+Extra));{ pad left with blank for }
  271.       DayStr := LeftPad(DayStr,2);                   { single digit days       }
  272.  
  273.       CalBox[Count]   := ord(DayStr[1]);             { for each day, place ord }
  274.       CalBox[Count+1] := Color;                      { value of string char in }
  275.       CalBox[Count+2] := ord(DayStr[2]);             { array, followed by attr }
  276.       CalBox[Count+3] := Color;                      { for that value.  Each   }
  277.       CalBox[Count+4] := 32;                         { day needs to be followed}
  278.       CalBox[Count+5] := Color;                      { by a space character for}
  279.       C := C + 1;                                    { separation from the next}
  280.       Count := Count + 6;                            { day                     }
  281.     end;
  282.  
  283.   TDay  := 1;
  284.   Color := IntenseAttr;  { change color to that for days of month to be
  285.                            displayed }
  286.  
  287.   while (TDay <= Dpm[Mo]) do begin
  288.     DayStr := Long2Str(TDay);
  289.     DayStr := LeftPad(DayStr,2);
  290.     if (TDay = Date.Day) then begin
  291.       CalBox[Count]   := ord(DayStr[1]);   { as above stuff array with values }
  292.       CalBox[Count+1] := ReverseAttr;      { and attributes.  This section    }
  293.       CalBox[Count+2] := ord(DayStr[2]);   { tests to see if day being        }
  294.       CalBox[Count+3] := ReverseAttr;      { stuffed is the current selection }
  295.       CalBox[Count+4] := 32;               { day and if so, sets attribute to }
  296.       CalBox[Count+5] := Color;            { the attribute for selected day   }
  297.     end
  298.     else begin
  299.       CalBox[count]   := ord(DayStr[1]);   { if day being stuffed was NOT the  }
  300.       CalBox[count+1] := Color;            { selected day, then attribute is   }
  301.       CalBox[count+2] := ord(DayStr[2]);   { the attribute for days of current }
  302.       CalBox[count+3] := Color;            { month                             }
  303.       CalBox[count+4] := 32;
  304.       CalBox[count+5] := Color;
  305.     end;
  306.     if ((TDay = TodaysDate.Day) and (Mo = TodaysDate.Month-1) and
  307.        (TYear = TodaysDate.Year) and (Flag)) then begin
  308.           CalBox[Count+1] := (CalBox[Count+1] or Blink);
  309.                                                     { if the day being stuffed }
  310.           CalBox[Count+3] := (CalBox[Count+3] or Blink);
  311.                                                     { is the current day as in }
  312.     end;                                            { system date cause to     }
  313.                                                     { blink                    }
  314.  
  315.     TDay := TDay + 1;
  316.     C := C + 1;
  317.     Count := Count + 6;
  318.     if (C > 6) then begin
  319.       C := 0;
  320.       Count := Count - 2;
  321.     end;
  322.   end;
  323.  
  324.   { the following sections makes adjustments to February for leap year }
  325.  
  326.   if ((Mo = 1) and (Leap_Year(Date.Year))) then begin
  327.     DayStr := Long2Str(TDay);
  328.     DayStr := LeftPad(DayStr,2);
  329.     C := C + 1;
  330.     CalBox[Count] := ord(DayStr[1]);
  331.     if (Date.Day <> 29) then
  332.       CalBox[Count+1] := Color
  333.     else
  334.       CalBox[Count+1] := ReverseAttr;
  335.     CalBox[Count+2]   := ord(DayStr[2]);
  336.     if (Date.Day <> 29) then
  337.       CalBox[Count+3] := Color
  338.     else
  339.       CalBox[Count+3] := ReverseAttr;
  340.     CalBox[Count+4]   :=32;
  341.     CalBox[count+5]   :=color;
  342.     Count := Count + 6;
  343.   end;
  344.  
  345.   Color := NormalAttr;  { set attribute back in order to display days of }
  346.   if (C > 0) then       { month which follow the displayed month         }
  347.     for S := 1 to 7-C do begin
  348.       DayStr := Long2Str(S);
  349.       DayStr := LeftPad(DayStr,2);      { stuff days as before }
  350.       CalBox[Count]   := ord(DayStr[1]);
  351.       CalBox[Count+1] := Color;
  352.       CalBox[Count+2] := Ord(DayStr[2]);
  353.       CalBox[Count+3] := Color;
  354.       CalBox[count+4] := 32;
  355.       CalBox[Count+5] :=color;
  356.       Count := Count + 6;
  357.     end;
  358.  
  359.   CalPtr := @CalBox;  { set pointer to point to calendar array, this is the
  360.                         trick which allows restorewindow to restore a window
  361.                         which has never been saved
  362.                       }
  363.  
  364.   RestoreWindow(X+1,Y+2,X+20,Y+7,False,CalPtr);
  365. end;
  366.  
  367.  
  368. {
  369. This procedure is used to adjust the displayed month based upon the key
  370. pressed while in the selection mode
  371. }
  372.  
  373. procedure GetCalKey(var Date : DateType);
  374.  
  375. begin
  376.   GetCursorState(OldXY,ScanLines);   { hide the cursor }
  377.   HiddenCursor;
  378.   TempDate := Date;
  379.   repeat
  380.     Date := TempDate;
  381.     StuffCal;           { draw calendar }
  382.     Chr1 := ScanKey;    { get keypress  }
  383.     {$IFDEF USEMOUSE}
  384.     SetMouseEventHandler(AllMouseEvents,nil);  { disable mouse handler  }
  385.     {$ENDIF}
  386.     case Chr1 of
  387.       NULL    : ;
  388.       CR      : begin      { this accepts the date displayed }
  389.                 end;
  390.       ESC     : begin      { exit set date values to 0       }
  391.                   TempDate.Year  := 0;
  392.                   TempDate.Month := 0;
  393.                   TempDate.Day   := 0;
  394.                 end;
  395.       F1      : ;
  396.                 {
  397.                   The mouse handler simulates this function key if both
  398.                   mouse buttons are pressed (LEFT and RIGHT)
  399.                 }
  400.       LeftKey : if TempDate.Day > 1 then        { decrement day value }
  401.                   TempDate.Day := TempDate.Day - 1
  402.                 else
  403.                  if TempDate.Month > 1 then begin
  404.                    TempDate.Month := TempDate.Month - 1;
  405.                    TempDate.Day   := Dpm[TempDate.Month - 1];
  406.                    if ((TempDate.Month = 2) and (Leap_Year(TempDate.Year))) then
  407.                      TempDate.Day := 29;
  408.                  end
  409.                  else begin
  410.                   if (TempDate.Year > 1) then
  411.             TempDate.Year := TempDate.Year - 1;
  412.                   TempDate.Month  := 12;
  413.                   TempDate.Day    := 31;
  414.                  end;
  415.       RightKey: if TempDate.Day < Dpm[TempDate.Month-1] then
  416.                                             { increment day value }
  417.                   TempDate.Day := TempDate.Day + 1
  418.                 else
  419.                  if ((TempDate.Month = 2) and (Leap_Year(TempDate.Year))) then
  420.                    if (TempDate.Day <> 29) then
  421.                      TempDate.Day := 29
  422.                    else begin
  423.                      TempDate.Day   := 1;
  424.                      TempDate.Month := TempDate.Month + 1;
  425.                    end
  426.                  else
  427.                   if TempDate.Month < 12 then begin
  428.                    TempDate.Month := TempDate.Month + 1;
  429.                    TempDate.Day   := 1;
  430.                  end
  431.                  else begin
  432.                    if (TempDate.Year < 65535) then
  433.                   TempDate.Year := TempDate.Year + 1;
  434.                    TempDate.Month  := 1;
  435.                    TempDate.Day    :=1;
  436.                  end;
  437.       UpKey   : if TempDate.Month > 1 then begin   { decrement month value }
  438.                   TempDate.Month := TempDate.Month - 1;
  439.                   if TempDate.Day > Dpm[TempDate.Month - 1] then
  440.                     TempDate.Day := Dpm[TempDate.Month - 1];
  441.                 end
  442.                 else begin
  443.                   TempDate.Month := 12;
  444.                   if (TempDate.Year > 1) then
  445.                TempDate.Year := TempDate.Year - 1;
  446.                 end;
  447.       DownKey : if TempDate.Month < 12 then begin  { increment month value }
  448.                   TempDate.Month := TempDate.Month + 1;
  449.                   if TempDate.Day > Dpm[TempDate.Month - 1] then
  450.                     TempDate.Day := Dpm[TempDate.Month - 1];
  451.                 end
  452.                 else begin
  453.                   if (TempDate.Year < 65535) then
  454.                   TempDate.Year := TempDate.Year + 1;
  455.                   TempDate.Month  := 1;
  456.                 end;
  457.       PgUpKey : begin                              { increment year value }
  458.                   if (TempDate.Year > 1) then begin
  459.                 TempDate.Year := TempDate.Year - 1;
  460.                     if ((TempDate.Month = 2) and (TempDate.Day = 29)) then
  461.                       TempDate.Day:=28;
  462.               end;
  463.                 end;
  464.       PgDnKey : begin                              { decrement year value }
  465.                   if (TempDate.Year < 65535) then begin
  466.             TempDate.Year := TempDate.Year + 1;
  467.                     if ((TempDate.Month = 2) and (TempDate.Day = 29)) then
  468.                       TempDate.Day:=28;
  469.           end;
  470.                 end;
  471.                   else write(BELL)
  472.     end;{case}
  473.     {$IFDEF USEMOUSE}
  474.     SetMouseEventHandler(AllMouseEvents,@MouseCalendarHandler);
  475.     {$ENDIF}
  476.   until Chr1 in [CR,ESC];    { can only exit with these two key values }
  477.   Date := TempDate;
  478.   RestoreCursorState(OldXY,ScanLines);    { restore cursor }
  479. end;
  480.  
  481. begin { calendar }
  482.   { set up mouse handler }
  483.   {$IFDEF USEMOUSE}
  484.   SetMouseEventHandler(AllMouseEvents,@MouseCalendarHandler);
  485.   {$ENDIF}
  486.   if (CalFrame_Attr = 0) then                { check attribute values }
  487.     CalFrame_Attr   := NormalAttr;
  488.   if (CalHeader_Attr = 0) then
  489.     CalHeader_Attr  := ReverseAttr;
  490.   if (HelpFrame_Attr = 0) then
  491.     HelpFrame_Attr  := NormalAttr;
  492.   if (HelpHeader_Attr = 0) then
  493.     HelpHeader_Attr := NormalAttr;
  494.   if (Helptext_Attr = 0) then
  495.     HelpText_Attr   := NormalAttr;
  496.   if (HelpChars_Attr=0) then
  497.     HelpChars_Attr  :=IntenseAttr;
  498.   if (Other_Attr<>0) then
  499.     NormalAttr      := Other_Attr;
  500.   if (Current_Attr<>0) then
  501.     IntenseAttr     := Current_Attr;
  502.   if (Select_Attr<>0) then
  503.     ReverseAttr     := Select_Attr;
  504.  
  505.   if (X < 1) then                          { check display coordinates }
  506.     X := 1;
  507.   if (Y < 1) then
  508.     Y := 1;
  509.   if (X > 58) then
  510.      x := 58;
  511.   if (Flag) then begin
  512.     if (Y > 8) then
  513.       Y := 8;
  514.   end
  515.   else
  516.     if (Y > 16) then
  517.       Y := 16;
  518.  
  519.   with TodaysDate do
  520.     getdate(Year,Month,Day,DayofWeek);     { get current system date    }
  521.     if (not(Month in [1..12])) then        { check VAR parameter values }
  522.       Month := 1;
  523.     if (Month = 2) then begin
  524.       if (Leap_Year(Year)) then begin
  525.     if (Day > 29) then Day:=29;
  526.       end
  527.       else
  528.     if (Day > 28) then Day:=28;
  529.     end
  530.     else
  531.        case month of
  532.     1,3,5,7,8,10,12 : if (Day > 31) then Day := 31;
  533.         2,4,6,8,11      : if (Day > 30) then Day := 30;
  534.        end;
  535.     if (Year < 1) then Year := 1;
  536.     if (Day < 1) then Day:=1;
  537.     Date.Year  := Year;
  538.     Date.Month := Month;
  539.     Date.Day   := Day;
  540.  
  541.   {
  542.   Make the calendar window, however nothing is done if this fails.  This is
  543.   because likelyhood of failure is remote due to small size of window
  544.   }
  545.  
  546.   if not MakeWindow(CalendarWindow,X,Y,X+21,Y+8,True,False,False,
  547.                     NormalAttr,CalFrame_Attr,7,'') then;
  548.   if not DisplayWindow(CalendarWindow) then;
  549.   if Flag then begin
  550.     if not MakeWindow(HelpWindow,X,Y+11,X+21,Y+18,True,True,False,
  551.                       NormalAttr,HelpFrame_Attr,HelpHeader_Attr,
  552.                       'Calendar Keys') then;
  553.     if not DisplayWindow(HelpWindow) then;
  554.  
  555.     { Set up mouse window and adjust for frame around window }
  556.     {$IFDEF USEMOUSE}
  557.     MouseWindow(X,Y+11,X+21,Y+18); ShowMouse;
  558.     {$ENDIF}
  559.     FastWrite('Prev  Next',Y+12,X+9,HelpText_Attr); { draw instruction screen  }
  560.     FastWrite('Day    '+chr(27)+'      '+chr(26),Y+13,X+3,HelpText_Attr);
  561.     FastWrite('Month  '+chr(24)+'      '+chr(25),Y+14,X+3,HelpText_Attr);
  562.     FastWrite('Year  PgUp  PgDn',Y+15,X+3,HelpText_Attr);
  563.     FastWrite(chr(17)+chr(196)+chr(217)+' Accept',Y+16,X+6,HelpText_Attr);
  564.     FastWrite('Esc Cancel',Y+17,X+6,HelpText_Attr);
  565.     ChangeAttribute(8,Y+13,X+10,HelpChars_Attr);
  566.     ChangeAttribute(8,Y+14,X+10,HelpChars_Attr);
  567.     ChangeAttribute(10,y+15,X+9,HelpChars_Attr);
  568.     ChangeAttribute(3,Y+16,X+6,HelpChars_Attr);
  569.     ChangeAttribute(3,Y+17,X+6,HelpChars_Attr);
  570.     GetCalKey(Date); HideMouse;
  571.     repeat                        { reclaim heap and erase windows    }
  572.       HelpWindow := EraseTopWindow;
  573.     until HelpWindow = nil;
  574.   end
  575.   else begin            { if not using selection mode, then just draw }
  576.     StuffCal;           { calendar }
  577.     {$IFDEF USEMOUSE}
  578.     HideMouse;
  579.     {$ENDIF}
  580.     if SaveWindow(X,Y,X+21,Y+18,True,Buffer) then;
  581.     DisposeWindow(EraseTopWindow);   { restore heap and erase window  }
  582.     RestoreWindow(X,Y,X+21,Y+18,True,Buffer);  { restore window       }
  583.   end;
  584.   Year  := Date.Year;   { return selected date in VAR parameters      }
  585.   Month := Date.Month;
  586.   Day   := Date.Day;
  587.   {$IFDEF USEMOUSE}
  588.   SetMouseEventHandler(AllMouseEvents,nil);  { disable mouse handler  }
  589.   MouseWindow(1,2,ScreenWidth,ScreenHeight-1);
  590.   {$ENDIF}
  591. end;
  592.  
  593. begin
  594. end.
  595.