继承Tcalendar控件,让当天日期醒目显示

继承Tcalendar控件,让当天日期醒目显示

    一、新建一控件

    打开Delphi主菜单Cpmponent—New Cpmponent:


    二、配置参数

.        

    点击OK键,打开Unit单元文件。

    三、修改单元文件

unit LyCalendar;


interface

 

uses

 Windows,

 Messages, SysUtils, Variants, Classes, Graphics, Controls, //Forms,

 Dialogs, Grids, Calendar, ComCtrls, StdCtrls,DateUtils;

 

type

 TLyCalendar = class(TCalendar)

 private

    {Private declarations }

 protected

    {Protected declarations }

   procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState:TGridDrawState); override;

 public

    {Public declarations }

 published

    {Published declarations }

 end;

 

procedure Register;

 

implementation

 

procedure Register;

begin

 RegisterComponents('LyComMy', [TLyCalendar]);

end;

 

procedure TLyCalendar.DrawCell(ACol, ARow:Integer; ARect: TRect; AState: TGridDrawState);

var  TheText: string;

    vDay: string;

begin

 TheText := CellText[ACol, ARow];

 vDay := IntToStr(DateUtils.DayOf(Now));

  ifvDay = TheText then

 begin

    //当天显示样式

   Canvas.Font.Color := clRed;

   Canvas.Font.Style:=Canvas.Font.Style+[fsBold];

  end

 else begin

    //被选择日期显示样式

   if  (gdSelected in AState) or(gdFocused in AState) then

   begin

     Canvas.Brush.Color := clBlue;

   end;

 end;

 inherited;

end;

 

end.

    四、安装控件

    1、将新的单元文件,存入C:\ProgramFiles\Borland\Delphi7\Projects\Bpl\ 目录;

    2、打开Delphi主菜单Cpmponent—Insert  Cpmponent:

 

    3、指定安装的参数:

 

    按“OK”键,打开对话框:

 

    按“compile”键,完成安装。

    四、新的控件样式:


    五、源码下载地址:http://download.csdn.net/detail/lyhoo163/9631356  点击打开链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值