AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi OOP-TRealEdit von TEdit abgeleitet und Fähigkeiten erweitert
Thema durchsuchen
Ansicht
Themen-Optionen

OOP-TRealEdit von TEdit abgeleitet und Fähigkeiten erweitert

Ein Thema von Hansa · begonnen am 9. Apr 2003 · letzter Beitrag vom 14. Aug 2003
Antwort Antwort
Hansa

Registriert seit: 9. Jun 2002
Ort: Saarland
7.554 Beiträge
 
Delphi 8 Professional
 
#1
  Alt 29. Apr 2003, 20:50
Hi,

das Thema geht noch weiter, auch wenn es nur wenige interessiert. Ich habe hier einen Code, den ich aus weltweiten Bestandteilen zusammengestückelt habe. Ich finde, der Code ist sehr einfach, aber effizient.

Dabei geht es allerdings um eine ListBox mit Label:

Delphi-Quellcode:
unit labeledlistbox;

interface

uses Controls, stdctrls, ExtCtrls, Classes;

procedure Register;

implementation

type

  TMyListBox = Class( TCustomPanel )
  private
    FLabel: TLabel;
    FListBox: TListBox;
    procedure SetLabelCaption(const Value: String);
    function GetLabelCaption: String;
    function GetListBoxItems: TStrings;
    function GetListBoxItemIndex: Integer;
    function GetListBoxOnClick: TNotifyEvent;
    procedure SetListBoxItemIndex(const Value: Integer);
    procedure SetListBoxOnCLick(const Value: TNotifyEvent);
  public
    constructor Create( AOwner: TComponent ); override;
    destructor Destroy; override;
  published
    property Font;
    property LabelCaption: String read GetLabelCaption write SetLabelCaption;
    property ListBoxItems: TStrings read GetListBoxItems;
    property ListBoxItemIndex: Integer read GetListBoxItemIndex write SetListBoxItemIndex;
    property ListBoxOnClick: TNotifyEvent read GetListBoxOnClick write SetListBoxOnCLick;
  end;

  constructor TMyListBox.Create(AOwner: TComponent);
  begin
    inherited Create( AOwner );

    FLabel := TLabel.Create( Self );
    FLabel.Parent := Self;
    FLabel.Align := alTop;
    FLabel.Caption := 'LABEL_CAPTION';

    FListBox := TListBox.Create( Self );
    FListBox.PArent := Self;
    FListBox.Align := alClient;
  end;

  destructor TMyListBox.Destroy;
  begin
    FLabel.Free;
    FListBox.Free;

    inherited Destroy;
  end;

  function TMyListBox.GetLabelCaption: String;
  begin
    Result := FLabel.Caption;
  end;

  function TMyListBox.GetListBoxItemIndex: Integer;
  begin
    Result := FListBox.ItemIndex;
  end;

  function TMyListBox.GetListBoxItems: TStrings;
  begin
    Result := FListBox.Items;
  end;

  function TMyListBox.GetListBoxOnClick: TNotifyEvent;
  begin
    Result := FListBox.OnClick;
  end;

  procedure TMyListBox.SetLabelCaption(const Value: String);
  begin
    if FLabel.Caption <> Value then
    begin
      FLabel.Caption := Value;
      Invalidate;
    end;
  end;

  procedure TMyListBox.SetListBoxItemIndex(const Value: Integer);
  begin
    if FListBox.ItemIndex <> Value then
    begin
      FListBox.ItemIndex := Value;
      Invalidate;
    end;
  end;

  procedure TMyListBox.SetListBoxOnCLick(const Value: TNotifyEvent);
  begin
    FListBox.OnClick := Value;
  end;

procedure Register;
begin
  RegisterComponents('Additional', [TMyListBox]);
end;

end.
[edit=Daniel B]Delphi-Tags ergänzt. MfG Daniel B.[/edit]
Gruß
Hansa
  Mit Zitat antworten Zitat
Antwort Antwort


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 10:10 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