To store the date for the calendar, you need a private field to hold the date and a runtime-only property that provides access to that date.
type TSampleCalendar = class(TCustomGrid) private FDate: TDateTime; . . .
class PACKAGE TSampleCalendar : public TCustomGrid { public: __property TDateTime CalendarDate = {read=FDate, write=SetCalendarDate, nodefault}; . . . };
class PACKAGE TSampleCalendar : public TCustomGrid { private: TDateTime FDate; . . . };
constructor TSampleCalendar.Create(AOwner: TComponent); begin inherited Create(AOwner); { this is already here } . { other initializations here } . . FDate := Date; { get current date from RTL } end;
__fastcall TSampleCalendar::TSampleCalendar(TComponent *Owner) : TCustomGrid(Owner)
{
.
.
.
FDate = FDate.CurrentDate();
}
type TSampleCalendar = class(TCustomGrid) private procedure SetCalendarDate(Value: TDateTime); public property CalendarDate: TDateTime read FDate write SetCalendarDate; . . . procedure TSampleCalendar.SetCalendarDate(Value: TDateTime); begin FDate := Value; { set new date value } Refresh; { update the onscreen image } end;
class PACKAGE TSampleCalendar : public TCustomGrid { private: void __fastcall SetCalendarDate(TDateTime Value); . . . };
void __fastcall TSampleCalendar::SetCalendarDate(TDateTime Value) { FDate = Value; // Set the new date value Refresh(); // Update the onscreen image }
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|