お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





FDelphi FAQ
16番会議室「玉石混淆みんなで作るSample蔵」に寄せられたサンプル

"土日の色が設定できるTCalender"



皆さん こんにちは らせん企画の佐々木です


unit IroCalendar;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, Calendar;

type
  TIroCalendar = class(TCalendar)
  private
    { Private 宣言 }
    FCSunday, FCSaturday: TColor;
  protected
    { Protected 宣言 }
    procedure DrawCell(ACol, ARow: Longint;
                       ARect: TRect; AState: TGridDrawState); override;
  public
    { Public 宣言 }
  published
    { Published 宣言 }
    Property ColorSaturday: TColor Read FCSaturday Write FCSaturday;
    Property ColorSunday: TColor Read FCSunday Write FCSunday;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TIroCalendar]);
end;

procedure TIroCalendar.DrawCell(ACol, ARow: Longint;
                             ARect: TRect; AState: TGridDrawState);
var
  TheText: string;
  WSunday, WSaturday: Byte;
  WColor: TColor;
begin
  TheText := CellText[ACol, ARow];
  If StartOfWeek = 0 Then
    WSunday := 0
  Else
    WSunday := 7 - StartOfWeek;
  WSaturDay := 6 - StartOfWeek;
  with ARect, Canvas do
  Begin
    If (ARow > 0)
    and (ACol in [WSunday, WSaturday])
    and not (gdSelected in AState) Then
    Begin
      WColor := Brush.Color;
      If ACol = WSunday Then
        Brush.Color := FCSunday
      Else If ACol = WSaturday Then
        Brush.Color := FCSaturday;
      FillRect(ARect);
    End;
    Inherited;
  End;
end;

end.

             98/7/9(Thu) 05:44pm  BYQ05322 らせん企画の佐々木

Original document by らせん企画      氏 ID:(BYQ05322)


ここにあるドキュメントは NIFTY SERVEの Delphi Users' Forum の16番会議室「玉石混淆みんなで作るSample蔵」に投稿されたサンプルです。これらのサンプルはボーランド株式会社がサポートする公式のものではありません。また、必ずしも動作が検証されているものではありません。これらのサンプルを使用したことに起因するいかなる損害も投稿者、およびフォーラムスタッフはその責めを負いません。使用者のリスクの範疇でご使用下さい。

Copyright 1996-2002 Delphi Users' Forum