Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TPlannerRangeSelector
Custom drawing in TPlannerCalendar

Via the OnCellDraw event, the days on a TPlannerCalendar can be fully custom drawn. In the code snippet presented, today is drawn with a yellow rectangular background while every odd day is painted with a bold font.
procedure TForm2.PlannerCalendar1CellDraw(Sender: TObject; Canvas: TCanvas;
  Day: TDate; Selected, Marked, InMonth: Boolean; Rect: TRect);
var
  da,mo,ye: word;
  s: string;
begin
  DecodeDate(day, ye, mo, da);
  if day = int(Now) then
  begin
    Canvas.Brush.Color := clYellow;
    Canvas.Rectangle(Rect);
    Canvas.Font.Color := clBlue;
  end;
  s := inttostr(da);

  if odd(Da) then
    Canvas.Font.Style := [fsBold];
  inflateRect(rect,-1,-1);
  DrawText(Canvas.Handle, pchar(s), length(s), rect, DT_CENTER or DT_VCENTER);
end;