// Dieser Code
dient der Erstellung einer Label-Komponente mit zusätzlichen
{Erläuterung der neuen Eigenschaften siehe unten} unit NeuLabel; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type klickart = (AnyClick, WithDelay, OnlyDblClick); randart = (IfSelected, Always, Never); erlaubnis = (Both, Clicking, Externally, No); angefordert = (NotYet, ByClicking, FromProgram); TNeuLabel = class(TLabel) private ow: TNotifyEvent; genehmigt: erlaubnis; markiert: boolean; wer: angefordert; intern: byte; rand: randart; art: klickart; fontco, untco, auswfontco, auswuntco, rcolor: TColor; protected procedure Click; override; procedure DblClick; override; procedure setauswahlschrift(f: TColor); procedure setauswahlflaeche(f: TColor); procedure setrahmenfarbe(f: TColor); procedure setrand(r: randart); public constructor Create(Owner: TComponent); override; procedure paint; override; function wechsel: boolean; property Selected: boolean read markiert; property LastRequest: angefordert read wer; published property Reaction: klickart read art write art; property Background: TColor read auswuntco write setauswahlflaeche; property FontColor: TColor read auswfontco write setauswahlschrift; property BorderColor: TColor read rcolor write setrahmenfarbe; property Border: randart read rand write setrand; property Permission: erlaubnis read genehmigt write genehmigt; property OnModification: TNotifyEvent read ow write ow; end; procedure Register; implementation constructor TNeuLabel.Create(Owner: TComponent); begin inherited Create(Owner); alignment := tacenter; layout := tlcenter; autosize := false; auswfontco := clyellow; auswuntco := clblack; rcolor := claqua; end; procedure TNeuLabel.setauswahlflaeche(f: tcolor); begin if f = auswuntco then exit; auswuntco := f; if markiert then color := auswuntco; end; procedure TNeuLabel.setauswahlschrift(f: tcolor); begin if f = auswfontco then exit; auswfontco := f; if markiert then font.color := auswfontco; end; procedure TNeuLabel.setrahmenfarbe(f: tcolor); begin if f = rcolor then exit; rcolor := f; if markiert then repaint; end; procedure TNeuLabel.setrand(r: randart); begin if r = rand then exit; rand := r; repaint; end; function TNeuLabel.wechsel: boolean; begin result := false; if intern = 1 then begin wer := byclicking; intern := 2; end else wer := fromprogram; if (genehmigt = externally) and (intern = 2) then begin intern := 0; exit; end; if (genehmigt = no) or (genehmigt = clicking) and (intern <> 2) then exit; intern := 0; if markiert then begin markiert := false; font.color := fontco; color := untco; end else begin markiert := true; untco := color; fontco := font.color; font.color := auswfontco; color := auswuntco; end; result := true; if assigned(onmodification) then onmodification(self); end; procedure TNeuLabel.click; begin inherited; if (art = onlydblclick) then exit; intern := 1; wechsel; end; procedure TNeuLabel.dblclick; begin inherited; if (art = withdelay) then exit; intern := 1; wechsel; end; procedure TNeuLabel.paint; begin inherited; if (rand = never) or (rand = ifselected) and (not markiert) then exit; if enabled then begin if markiert then canvas.pen.color := rcolor else canvas.pen.color := font.color; end else canvas.pen.color := clbtnshadow; canvas.rectangle(0, 0, width, height); end; procedure Register; begin RegisterComponents('DBR', [TNeuLabel]); end; end.
FontColor (TColor) Background (TColor) BorderColor (TColor) Border (IfSelected,Always,Never) Permisson (Both,Clicking,Externally,No) OnModification (TNotifyEvent) [Nur zur Laufzeit] Selected (Boolean) [Nur zur Laufzeit,
nur Lesen] LastRequest (NotYet,ByClicking,FromProgram) [Nur zur Laufzeit, nur
Lesen] Wechsel (Function:Boolean) [Nur zur Laufzeit] |