Style properties for TDateTimePicker

后端 未结 2 1731
一生所求
一生所求 2020-12-06 18:18

A TDateTime picker is a ComboBox where the drop-down list is replaced with a calendar. I use XE2 VCL Styles and changing style does\'nt affect TDateTimePicker Color & Fo

2条回答
  •  粉色の甜心
    2020-12-06 18:38

    For the Calendar itself... based on your other question...

    procedure SetVclStylesMonthCalColors( calColors: TMonthCalColors);
    var
      LTextColor, LBackColor : TColor;
    begin
       //get the vcl styles colors
       LTextColor:=StyleServices.GetSystemColor(clWindowText);
       LBackColor:=StyleServices.GetSystemColor(clWindow);
    
       //set the colors of the calendar
       calColors.BackColor:=LBackColor;
       calColors.MonthBackColor:=LBackColor;
       calColors.TextColor:=LTextColor;
       calColors.TitleBackColor:=LBackColor;
       calColors.TitleTextColor:=LTextColor;
       calColors.TrailingTextColor:=LTextColor;
    end;
    
    Procedure SetVclStylesColorsCalendar( MonthCalendar: TMonthCalendar);
    Var
      LTextColor, LBackColor : TColor;
    begin
       uxTheme.SetWindowTheme(MonthCalendar.Handle, '', '');//disable themes in the calendar
       MonthCalendar.AutoSize:=True;//remove border
    
       SetVclStylesMonthCalColors(MonthCalendar.CalColors);
    end;
    
    
    procedure TForm1.dtp1DropDown(Sender: TObject);
    var
      rec: TRect;
    begin
      uxTheme.SetWindowTheme(DateTime_GetMonthCal(dtp1.Handle), '', '');
      MonthCal_GetMinReqRect(DateTime_GetMonthCal(dtp1.Handle), rec);
      SetWindowPos(GetParent(DateTime_GetMonthCal(dtp1.Handle)), 0, rec.Left, rec.Top, rec.Width, rec.Height,0);
      SetWindowPos(DateTime_GetMonthCal(dtp1.Handle), 0, rec.Left, rec.Top, rec.Width, rec.Height,0);
      SetVclStylesMonthCalColors(dtp1.CalColors);
    end;
    

提交回复
热议问题