AGB  ·  Datenschutz  ·  Impressum  







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

Neue Komponente / Properties speichern ?

Ein Thema von Gruber_Hans_12345 · begonnen am 23. Sep 2004 · letzter Beitrag vom 24. Sep 2004
 
Benutzerbild von Stevie
Stevie

Registriert seit: 12. Aug 2003
Ort: Soest
4.052 Beiträge
 
Delphi 10.1 Berlin Enterprise
 
#13

Re: Neue Komponente / Properties speichern ?

  Alt 24. Sep 2004, 09:41
Weil mich die Sache interessiert hat, hab ich mal ein bisschen rumprobiert. Hier das Ergebnis:
Delphi-Quellcode:
unit EditEx;

interface

uses
  Windows, Messages, SysUtils, Classes, Controls, StdCtrls, Graphics;

type
  TEditEx = class(TEdit)
  private
    FColor: TColor;
    FCursor: TCursor;
    FOnlyShow: Boolean;
    function GetColor: TColor;
    function GetCursor: TCursor;
    function IsColorStored: Boolean;
    function IsCursorStored: Boolean;
    procedure SetColor(const Value: TColor);
    procedure SetCursor(const Value: TCursor);
    procedure SetOnlyShow(const Value: Boolean);
  published
    property Color: TColor read GetColor write SetColor stored IsColorStored default clWindow;
    property Cursor: TCursor read GetCursor write SetCursor stored IsCursorStored default crDefault;
    property OnlyShow: Boolean read FOnlyShow write SetOnlyShow;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Beispiele', [TEditEx]);
end;

{ TEditEx }

function TEditEx.GetColor: TColor;
begin
  Result := inherited Color;
end;

function TEditEx.GetCursor: TCursor;
begin
  Result := inherited Cursor;
end;

function TEditEx.IsColorStored: Boolean;
begin
  Result := not ParentColor and not OnlyShow;
end;

function TEditEx.IsCursorStored: Boolean;
begin
  Result := not OnlyShow;
end;

procedure TEditEx.SetColor(const Value: TColor);
begin
  if not OnlyShow then
    inherited Color := Value;
end;

procedure TEditEx.SetCursor(const Value: TCursor);
begin
  if not OnlyShow then
    inherited Cursor := Value;
end;

procedure TEditEx.SetOnlyShow(const Value: Boolean);
begin
  if FOnlyShow <> Value then
  begin
    FOnlyShow := Value;
    if OnlyShow then
    begin
      FColor := inherited Color;
      FCursor := inherited Cursor;
      inherited Color := clBtnFace;
      inherited Cursor := crArrow;
    end
    else
    begin
      inherited Color := FColor;
      inherited Cursor := FCursor;
    end;
  end;
end;

end.
Stefan
“Simplicity, carried to the extreme, becomes elegance.” Jon Franklin

Delphi Sorcery - DSharp - Spring4D - TestInsight
  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 04:40 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