delphi DateTimePicker 宽度如何与Delphi自带Style同步  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi DateTimePicker 宽度如何与Delphi自带Style同步



解决办法1:把自带 style 的 client 项关闭



解决办法2:

网上一搜,Stack Overflow 给出了方案——去掉自动绘制 style,去提取 style 的相关元素来设置 CalColors 属性。


尝试一下,效果基本能接受了。记在这里备查。


http://stackoverflow.com/questions/10335310/style-properties-for-tdatetimepicker

uses

  Winapi.CommCtrl,

  Vcl.Styles,

  Vcl.Themes,

  uxTheme;


Procedure SetVclStylesColorsCalendar( DateTimePicker: TDateTimePicker);

Var

  LTextColor, LBackColor : TColor;

begin

   uxTheme.SetWindowTheme(DateTimePicker.Handle, '', '');//disable themes in the calendar

   //get the vcl styles colors

   LTextColor:=StyleServices.GetSystemColor(clWindowText);

   LBackColor:=StyleServices.GetSystemColor(clWindow);


   DateTimePicker.Color:=LBackColor;

   //set the colors of the calendar

   DateTimePicker.CalColors.BackColor:=LBackColor;

   DateTimePicker.CalColors.MonthBackColor:=LBackColor;

   DateTimePicker.CalColors.TextColor:=LTextColor;

   DateTimePicker.CalColors.TitleBackColor:=LBackColor;

   DateTimePicker.CalColors.TitleTextColor:=LTextColor;

   DateTimePicker.CalColors.TrailingTextColor:=LTextColor;

end;


procedure TForm2.DateTimePicker1DropDown(Sender: TObject);

var

  hwnd: WinAPi.Windows.HWND;

begin

  hwnd := SendMessage(TDateTimePicker(Sender).Handle, DTM_GETMONTHCAL, 0,0);

  uxTheme.SetWindowTheme(hwnd, '', '');//disable themes in the drop down window

end;

procedure TForm2.FormCreate(Sender: TObject);

begin

  SetVclStylesColorsCalendar(DateTimePicker1);

end;

 

来源:https://www.cnblogs.com/codingnote/archive/2014/10/24/4047264.html


推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.042702198028564 seconds