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  点击打开链接

  • 相关阅读:
    第一个Struts1步骤
    struts框架学习过程中的问题
    struts2笔记
    搭建struts2框架
    一个系统钩子
    TMemIniFile 与TIniFile 区别
    rc4加密
    注册dll
    delphi 功能函数大全-备份用
    VC中文件路径问题
  • 原文地址:https://www.cnblogs.com/jijm123/p/10432796.html
Copyright © 2011-2022 走看看