AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

VCL für Microsoft-Style URL-Label

Offene Frage von "blackdrake"
Ein Thema von blackdrake · begonnen am 16. Aug 2008 · letzter Beitrag vom 3. Sep 2008
 
blackdrake

Registriert seit: 22. Aug 2003
Ort: Bammental
618 Beiträge
 
Delphi 10.3 Rio
 
#20

Re: VCL für Microsoft-Style URL-Label

  Alt 20. Aug 2008, 18:39
Ich habe folgendes nun nach langer Arbeit hinbekommen:

Im Header sind ToDo-Einträge gelistet. Hier habe ich noch einige Probleme... Bitte schreibt mir, wenn ihr weiter wisst!

Delphi-Quellcode:
{
  TSingleLinkLabel
  (c) 2008 Daniel Marschall / ViaThinkSoft

  Original code and partitions
  (c) 2008 by omata (Thorsten) - [url]http://www.delphipraxis.net[/url]
}


// ToDo
// + AutoSize
// + Transparent
// + ParentColor
// + ParentFont
// (+ Sonstige Eigenschaften von echten Labels)
// Enabled=False * Schrift wird nicht grau
// * Das nächste Item bekommt nicht den Focus
// Microsoft Hand-Cursor

unit SingleLinkLabel;

interface

uses Windows, Controls, Classes, Graphics, SysUtils;

type
  TSingleLinkLabel = class(TCustomControl)
  private
    FLines:TStringList;
    function GetCaption: string;
    procedure SetCaption(const Value: string);
  protected
    procedure Paint; override;
    procedure DoEnter; override;
    procedure DoExit; override;
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
      X, Y: Integer); override;
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
    procedure KeyDown(var Key: Word; Shift: TShiftState); override;
    procedure Resize; override;
  published
    property OnClick;
    property Font;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    property Caption:string read GetCaption write SetCaption;
  end;

implementation

{ TSingleLinkLabel }

constructor TSingleLinkLabel.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FLines := TStringList.Create;
  Width := 65;
  Height := 17;
  TabStop := True;

  Font.Color := clHotLight;
  Font.Style := [fsUnderline];
end;

destructor TSingleLinkLabel.Destroy;
begin
  FLines.free;
  inherited;
end;

procedure TSingleLinkLabel.DoEnter;
begin
  inherited;
  Paint;
end;

procedure TSingleLinkLabel.DoExit;
begin
  inherited;
  Paint;
end;

function TSingleLinkLabel.GetCaption: string;
begin
  Result := FLines.Text;
end;

procedure TSingleLinkLabel.KeyDown(var Key: Word; Shift: TShiftState);
begin
  inherited;

  if Key = 13 then Click;
end;

procedure TSingleLinkLabel.MouseDown(Button: TMouseButton; Shift: TShiftState;
  X, Y: Integer);
begin
  inherited;
  SetFocus;
end;

procedure TSingleLinkLabel.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
  inherited;
  Cursor := crHandPoint;
end;

procedure TSingleLinkLabel.Paint;
var
  i: integer;
begin
  inherited;

  Canvas.Font := Font;

  Canvas.Brush.Color := clBtnFace;
  Canvas.Brush.Style := bsSolid;
  Canvas.FillRect(Canvas.ClipRect);

  for i := 0 to FLines.Count - 1 do
  begin
    Canvas.TextOut(0, Canvas.TextHeight('X')*i, FLines.Strings[i]);
  end;

  if Focused then Canvas.DrawFocusRect(Canvas.ClipRect);
end;

procedure TSingleLinkLabel.Resize;
begin
  inherited;
  SetCaption(Caption);
  Paint;
end;

procedure TSingleLinkLabel.SetCaption(const Value: string);
begin
  FLines.Text := Value;

  Paint;
end;

end.
Gruß
blackdrake
Daniel Marschall
  Mit Zitat antworten Zitat
 


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 05:44 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 by Thomas Breitkreuz