Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

LMDCalendar How to Add SpecialDate Dynamically OnDateSel event

Hello,

I want to Add SpecialDate OnDateSel event.

---For example
procedure TfrmLMDCalendarControls_NewFeaturesDemo.LMDCalendar5DateSel(
  Sender: TObject; Date: TDateTime);
var
MyDate:TLMDDateListRecord;
begin
  with MyDate do
  begin
    Datefg := Date;
    Date   := Date;
    DateString := 'Test Day';
    Active := True;
    Calculated := True;
  end;
  LMDCalendar5.SpecialDates[0].Dates.AddDate(MyDate);
end;
-----
No error but can not display Selected date Cell.

OnShow event cording is OK.
--------------
procedure TfrmLMDCalendarControls_NewFeaturesDemo.FormShow(Sender: TObject);
var
MyDate:TLMDDateListRecord;
begin
  with MyDate do
  begin
    Datefg := StrToDate('2018/10/01');
    Date   := StrToDate('2018/10/01');
    DateString := 'Test Day';
    Active := True;
    Calculated := True;
  end;
  LMDCalendar5.SpecialDates[0].Dates.AddDate(MyDate);
end;

Best regards,
Hiroshi Shibata

Comments

  • 1 Comment sorted by Votes Date Added
  • You can do it asynchronously like this:

    type
      TForm2 = class(TForm)
        LMDCalendar1: TLMDCalendar;
        procedure LMDCalendar1DateSel(Sender: TObject; Date: TDateTime);
      private
        FDateToAdd: TDate;
        procedure WM_AddSpecialDate(var M: TMessage); message WM_USER + 1;
      end;

    .....

    procedure TForm2.LMDCalendar1DateSel(Sender: TObject; Date: TDateTime);
    begin
      FDateToAdd := Date;
      PostMessage(Handle, WM_USER + 1, 0, 0);
    end;

    procedure TForm2.WM_AddSpecialDate(var M: TMessage);
    var
      MyDate:TLMDDateListRecord;
    begin
      with MyDate do
      begin
        Datefg := FDateToAdd;
        Date   := FDateToAdd;
        DateString := 'Test Day';
        Active := True;
        Calculated := True;
      end;
      LMDCalendar1.SpecialDates[0].Dates.AddDate(MyDate);
      LMDCalendar1.Refresh;
    end;
Sign In or Register to comment.