AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Ticker-Text

Ein Thema von Privateer3000 · begonnen am 6. Jan 2003 · letzter Beitrag vom 15. Aug 2003
Antwort Antwort
Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: Unterhaching
11.413 Beiträge
 
Delphi 12 Athens
 
#1
  Alt 8. Jan 2003, 18:17
Und jetzt das pixelweise Scrollen als kleine liebe Komponente.
Delphi-Quellcode:
unit uDPTicker;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TdpTicker = class(TGraphicControl)
  private
    FTimer: TTimer;
    FXPos, FTextWidth: Integer;
    FRunAtDesignTime: Boolean;
    procedure OnTimer(Sender: TObject);
    function GetCaption: TCaption;
    procedure SetCaption(const Value: TCaption);
    function GetSpeed: Integer;
    procedure SetSpeed(const Value: Integer);
    procedure SetRunAtDesignTime(const Value: Boolean);
  protected
    procedure Paint; override;
    procedure SetEnabled(Value: Boolean); override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property Speed: Integer read GetSpeed write SetSpeed;
    property Caption: TCaption read GetCaption write SetCaption;
    property RunAtDesignTime: Boolean read FRunAtDesignTime write SetRunAtDesignTime;

    property Align;
    property Anchors;
    property Color;
    property Enabled;
    property Constraints;
    property DragCursor;
    property DragKind;
    property DragMode;
    property Font;
    property Height;
    property ParentColor;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property Width;
    property Visible;
    property OnClick;
    property OnContextPopup;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDock;
    property OnEndDrag;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnStartDock;
    property OnStartDrag;

  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Delphi-PRAXiS', [TdpTicker]);
end;

{ TdpTicker }

constructor TdpTicker.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Width := 150;
  Height := 25;
  FTimer := TTimer.Create(Self);
  FTimer.Interval := 15;
  FTimer.OnTimer := OnTimer;
  FRunAtDesignTime := False;
  FTimer.Enabled := not (csDesigning in ComponentState);
end;

destructor TdpTicker.Destroy;
begin
  FTimer.Free;
  inherited Destroy;
end;

function TdpTicker.GetCaption: TCaption;
begin
  Result := inherited Caption;
end;

function TdpTicker.GetSpeed: Integer;
begin
  Result := FTimer.Interval;
end;

procedure TdpTicker.OnTimer(Sender: TObject);
begin
  Paint;
end;

procedure TdpTicker.Paint;
var
  Bmp: TBitmap;
begin
  Bmp := TBitmap.Create;
  try
    Bmp.Canvas.Brush.Color := Color;
    Bmp.Canvas.Brush.Style := bsSolid;

    Bmp.Canvas.Font.Assign(Font);
    Bmp.Width := Width;
    Bmp.Height := Height;

    Bmp.Canvas.TextOut(FXPos, (Height - Canvas.TextHeight(Caption)) div 2,
        Caption);
    Dec(FXPos);
    if FXPos + FTextWidth < 0 then
      FXPos := Width;

    Canvas.CopyRect(Canvas.ClipRect, Bmp.Canvas, Canvas.ClipRect);
  finally
    Bmp.Free;
  end;
end;

procedure TdpTicker.SetCaption(const Value: TCaption);
begin
  inherited Caption := Value;
  FXPos := Width;
  if Canvas <> nil then
    FTextWidth := Canvas.TextWidth(Caption);
end;

procedure TdpTicker.SetEnabled(Value: Boolean);
begin
  inherited Enabled := Value;
  FTimer.Enabled := ((not (csDesigning in ComponentState)) or FRunAtDesignTime)
      and Enabled;
end;

procedure TdpTicker.SetRunAtDesignTime(const Value: Boolean);
begin
  FRunAtDesignTime := Value;
  FTimer.Enabled := ((not (csDesigning in ComponentState)) or FRunAtDesignTime)
      and Enabled;
end;

procedure TdpTicker.SetSpeed(const Value: Integer);
begin
  FTimer.Interval := Value;
end;

end.
......
Daniel Lizbeth
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat
Antwort Antwort

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:38 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz