Einzelnen Beitrag anzeigen

blackdrake

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

Re: Selbsterstelltes property TabStop darf nicht kopiert wer

  Alt 14. Okt 2008, 20:52
Hat denn keiner eine Idee? Ich stell mal einen Quelltextauszug rein, da die PAS nur 2 Mal (und das von mir!) heruntergeladen wurde

Delphi-Quellcode:
  TFocusLabel = class(TLabel, IFocusEvents)
  private
    FFocusControl: TFocusHandler;
    function GetTabOrder: TTabOrder;
    procedure SetTabOrder(const Value: TTabOrder);
    function GetTabStop: Boolean;
    procedure SetTabStop(const Value: Boolean);
    function GetFocused: Boolean;
    function GetCanFocus: Boolean;
  public
    procedure SetFocus;
    property CanFocus: Boolean read GetCanFocus;
    property Focused: Boolean read GetFocused;
  published
    property TabStop: Boolean read GetTabStop write SetTabStop default False;
    property TabOrder: TTabOrder read GetTabOrder write SetTabOrder default -1;
  end;

function TFocusLabel.GetCanFocus: Boolean;
begin
  if Assigned(FFocusControl) then
    result := FFocusControl.CanFocus
  else
    result := False;
end;

function TFocusLabel.GetFocused: Boolean;
begin
  if Assigned(FFocusControl) then
    result := FFocusControl.Focused
  else
    result := False;
end;

function TFocusLabel.GetTabOrder: TTabOrder;
begin
  if Assigned(FFocusControl) then
    result := FFocusControl.TabOrder
  else
    result := -1;
end;

function TFocusLabel.GetTabStop: Boolean;
begin
  if Assigned(FFocusControl) then
    result := FFocusControl.TabStop
  else
    result := False;
end;

procedure TFocusLabel.SetFocus;
begin
  if Assigned(FFocusControl) then
     if FFocusControl.CanFocus then
        FFocusControl.SetFocus;
end;

procedure TFocusLabel.SetTabOrder(const Value: TTabOrder);
begin
  if Assigned(FFocusControl) then
    FFocusControl.TabOrder := Value;
end;

procedure TFocusLabel.SetTabStop(const Value: Boolean);
begin
  if Assigned(FFocusControl) then
    FFocusControl.TabStop := Value;
end;
TabStop wird neu eingeführt und die Werte werden einfach vom internen FFocusControl (ist ein TWinControl, das mit Create erzeugt wird) gelesen und geschrieben werden. Wie gesagt funktioniert das Setzen gut, das Kopieren schlägt absolut fehl.

Gruß
blackdrake
Daniel Marschall
  Mit Zitat antworten Zitat