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

相关阅读 >>

win7下使用Delphi7的方法

Delphi代码获取网卡物理地址三种方法

Delphi 62 进制的简单实现

Delphi tstringlist 保存txt文本文件最后一行不留空行

Delphi中判断窗体最大化和最小化事件

Delphi出现 no mapping for the unicode character exists in the target multi-byte code page 处理方法

Delphi 过滤所有空格的函数

Delphi中如何向某个ip不间断的发送数据

Delphi inttostransi

Delphi用内存流方式获取页面验证码图片

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...