TPlannerCalendar is a highly configurable, non-database-aware calendar component included in the TMS VCL UI Pack for Delphi and C++Builder Win32/Win64 application development. It provides developers with a rich interface to display months, look up dates, handle multi-select fields, and highlight specific events.
Below is a step-by-step technical execution strategy to implement TPlannerCalendar within your VCL application. 1. Initialize the Component on Your Form
To use TPlannerCalendar, ensure your environment paths point to your TMS installation folder. Open your Delphi IDE and select your target VCL Form.
Locate TPlannerCalendar on the tool palette (typically under the “TMS Planners” tab). Drop the component onto your form.
Add PlannerCal to your unit’s uses clause if it does not add automatically. 2. Configure Key Component Properties
Modify the following properties in the Object Inspector to align the calendar control with your application requirements:
SelectMode: Define user selection capabilities. Choose smSingleDate for a standard date lookup, or smDateRange / smMultiDate to allow users to select multiple dates or date blocks.
EventDisplay: Set how dates containing logged events are highlighted (e.g., using specific background styles or text colors).
ShowFocus: Toggles whether a distinct frame highlights the hovered or tracked date during navigation.
Look properties: Customize the calendar’s aesthetic theme, including header backgrounds, font properties, and day grid styling. 3. Handle Date Selection Events
Capture interactions using standard event handlers. It is critical to distinguish between calendar navigation and actual data selection:
OnDaySelect: This event triggers exclusively when a user clicks a day to alter the chosen value. Use it to grab the final output:
procedure TForm1.PlannerCalendar1DaySelect(Sender: TObject; Date: TDate); begin ShowMessage(‘User selected date: ’ + DateToStr(Date)); end; Use code with caution.
OnGetEvent: Hook into this event to tell the control which specific dates contain calendar events, allowing it to apply automatic target styling or hints. 4. Implement Custom Drawing for Key Dates
To dynamically alter cell backgrounds, add bold fonts, or apply company branding to specific dates (such as holidays or the current day), write code into the OnCellDraw event handler.
The example below customizes the current date cell with a yellow background and draws text manually:
procedure TForm1.PlannerCalendar1CellDraw(Sender: TObject; Canvas: TCanvas; Day: TDate; Selected, Marked, InMonth: Boolean; Rect: TRect); var DayString: string; Year, Month, DayNum: Word; begin DecodeDate(Day, Year, Month, DayNum); DayString := IntToStr(DayNum); // If the cell being drawn is today’s date if Day = Int(Now) then begin Canvas.Brush.Color := clYellow; Canvas.Rectangle(Rect); Canvas.Font.Color := clBlue; end; // Make odd calendar numbers bold if Odd(DayNum) then Canvas.Font.Style := [fsBold]; // Adjust borders and draw text properly centered InflateRect(Rect, -1, -1); DrawText(Canvas.Handle, PChar(DayString), Length(DayString), Rect, DT_CENTER or DT_VCENTER); end; Use code with caution. 5. Prevent Potential Access Violations
A common edge case occurs when initialization logic triggers mouse or paint routines while the form structure is still loading (specifically if the control is set to invisible initially). Avoid FCanvas errors by forcing initialization inside your form’s loading routine:
type // Cracker class to expose the protected Paint method safely TPlannerCalendarCracker = class(TPlannerCalendar); procedure TForm1.FormCreate(Sender: TObject); begin PlannerCalendar1.BeginUpdate; try TPlannerCalendarCracker(PlannerCalendar1).Paint; // Safely forces internal canvas building finally PlannerCalendar1.EndUpdate; end; end; Use code with caution. Alternative Variants to Consider
Depending on your application layout, you may swap out the standalone TPlannerCalendar for closely related components within the same TMS VCL UI Pack library: Component Name Primary Use Case TDBPlannerCalendar
Data-aware engine that binds straight to database engines containing event tables. TPlannerDatePicker
Dropdown calendar variant that tucks safely inside standard, low-profile data fields. TPlannerCalendarGroup
A multi-month visual layout ideal for wide grid monitoring dashboards. If you want to refine this implementation, let me know:
Are you binding this component directly to a database backend or storing events in memory?
Should users be able to select multiple disconnected dates, or just single days? What version of Delphi are you building your app on? Confused about TPlannerCalendar events – TMS VCL UI Pack