zoukankan      html  css  js  c++  java
  • 继承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:ProgramFilesBorlandDelphi7ProjectsBpl 目录;

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

     3、指定安装的参数:

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

     按“compile”键,完成安装。

        四、新的控件样式:

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

  • 相关阅读:
    Smarty简介
    简易调用及实例化视图
    简易调用及实例化模型
    简易调用及实例化控制器
    MVC错误(一)
    单一入口及MVC目录规范
    MVC各个层的作用
    MVC工作流程
    【学习笔记】字符串—马拉车(Manacher)
    【题解】邻值查找 [CH1301]
  • 原文地址:https://www.cnblogs.com/jijm123/p/10432796.html
Copyright © 2011-2022 走看看