anchor.diff:    cal.CloseOnSelect := TfpgCheckBox(Sender).Checked;
   end;
   
  +type
  +  TStartDay = (wdSun, wdMon, wdTue, wdWed, wdThu, wdFri, wdSat);
  +
  +procedure TMainForm.DrawCalendar(month, year: integer);
  +var
  +  weekstartday: TStartDay;
  +  i: integer;
  +  dayIndex: Byte;
  +  startingPos: integer;
  +  days: integer;
  +  currentDay: integer;
  +  s: string;
  +begin
  +  weekstartday := wdMon;  // 0=Sun, 1=Mon, 2=Tue etc.
  +  weekstartday := TStartDay(Ord(cbName1.FocusItem-1));
  +  
  +  // Month and year
  +  writeln('');
  +  writeln(LongMonthNames[month], ' ', year);
  +
  +  // draw day-of-week header
  +  for i := Ord(weekstartday) to Ord(weekstartday)+6 do
  +  begin
  +    if (i < 7) then
  +      dayIndex := i
  +    else
  +      dayIndex := i - 7;
  +
  +    write(ShortDayNames[dayIndex+1] + ' ');
  +  end;
  +  writeln('');
  +  
  +  startingPos := DayOfTheWeek(EncodeDate(year, month, 1)-Ord(weekstartday))-1;
  +  days := DaysInAMonth(year, month);
  +//  writeln('startingpos:', startingPos, '  days:', days);
  +
  +  // draw blanks before first of month
  +  if not (startingPos = 6) then
  +  for i := 0 to startingPos do
  +    write('    ');
  +
  +  // draw days of month
  +  currentDay := 1;
  +  i := startingPos;
  +  //for i := startingPos to days do
  +  while currentDay <= days do
  +  begin
  +    i := i + 1;
  +    if ((i mod 7) = 0) and (currentDay <> 1) then
  +      writeln('');
  +    if currentDay <= 9 then
  +      s := ' '
  +    else
  +      s := '';
  +    write(currentDay, '  ' + s);
  +    currentDay := currentDay + 1;
  +  end;
  +  
  +  writeln('');
  +  writeln('-----');
  +end;
  +
   procedure TMainForm.btnDownClicked(Sender: TObject);
   begin
     DoDropDown;
  
positive.code: var
    old: string;
  begin
    old := ShortDateFormat;
    ShortDateFormat := 'yyyy-mm-dd';
    try
  
negative.code:   cthreads,
    {$ENDIF}{$ENDIF}
    Classes, SysUtils, gfxbase, fpgfx, gui_form, gui_popupcalendar, gui_edit,
    gui_button, gui_label, gfx_popupwindow, gui_combobox, gui_checkbox, dateutils;
  
  type
    TMainForm = class(TfpgForm)
  