Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi komponente erstellen (https://www.delphipraxis.net/58018-komponente-erstellen.html)

milanlu 30. Nov 2005 02:37


komponente erstellen
 
Hallo,
ich kenne mich zimlich schlecht mit komponenten erstellen. :oops:
Ich brauche eine komponente mit:


--TPanel
-->TButton (auf dem Panel)
-->TLabel (auf dem Panel)
Für button eigebe caption
für label eigene caption

und für label positions einstelung (top, left)

Ich würde mich sehr freuen, wenn mir jemand helfen würde!!! :dancer2:

Danke im Voraus! :cheers:
MFG :hi:

milanlu 30. Nov 2005 02:45

Re: komponente erstellen
 
Liste der Anhänge anzeigen (Anzahl: 1)
also ich habe soviel geschaft
Delphi-Quellcode:
unit Switch;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls;

type
  TSwitch = class(TPanel)
  private
    bDown : boolean;
    bHeight : Integer;
    bhohe: Integer;
    procedure Click;
    procedure SetState(bValue: boolean);
  protected

    { Protected-Deklarationen}
  public
    { Public-Deklarationen}
  published
    property Down : Boolean read bDown write SetState;
    property Höhe1: Integer read bHeight write bHeight;
    property Höhe1: Integer read bhohe write bhohe;

  end;

procedure Register;

implementation

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


procedure TSwitch.Click;
begin
     if bHeight = Height then
     begin
          Height := bhohe;
          bDown := true
     end
     else
     begin
          Height := bHeight;
          bDown := false
     end;
end;

procedure TSwitch.SetState(bValue: boolean);
begin
     if bValue = true then
     begin
          bDown := true;
          Height := Height;
     end
     else
     begin
          bDown := false;
          Height := bHeight;
     end
end;

end.
Das bild das ich im attachment hinzugefügt habe, zeigt wie es am ende aussehen soll.

MarcoWarm 30. Nov 2005 05:42

Re: komponente erstellen
 
Nun, Komponentenentwicklung ist recht umfangreich. Und ohne konkrete Frage (d.h. "wie mach ich ... genau?") kann man schlecht was sagen. Vielleicht hilft dir das weiter:

http://www.dsdt.info/tutorials/kompentwickeln/?page=1

DP-Maintenance 30. Nov 2005 06:37

DP-Maintenance
 
Dieses Thema wurde von "Sharky" von "Tutorials und Kurse" nach "VCL / WinForms / Controls" verschoben.
Könnte auch nach Sonstige Fragen zu Delphi.
Aber ein Tutorial ist es ja nicht ;-)

milanlu 30. Nov 2005 11:04

Re: komponente erstellen
 
das tutorial hat mir nicht weiter geholfen. (ich kenne es bereits)
ok direkte frage:
wie erstelle ich im TSwitch ein Tlabel?????
danke

MarcoWarm 30. Nov 2005 17:30

Re: komponente erstellen
 
du musst das TLabel im Konstructor deines TSwitch erstellen (und nicht vergessen,es im Destruktor wieder freizugeben)
im Konstuktor musst du ebenfalls alle wichtigen Werte des Labels initialisieren (z.B. Position, Font etc.) Das klingt nach viel Arbeit .... das ist es auch *lach*
Schau dir als Beispiel mal die Quellen von verschiedenen JEDI-Controls an, die etwas ähnliches machen.

milanlu 6. Dez 2005 17:42

Re: komponente erstellen
 
Liste der Anhänge anzeigen (Anzahl: 1)
Also ich habe es geknackt: :dancer2: :dancer:


:coder:
Delphi-Quellcode:
unit Switch;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls, StdCtrls;

type
  TSwitch = class(TPanel)
  constructor Create(AOwner: TComponent); override;
  private
    bDown : boolean;
    bHeight : Integer;
    bVisina : Integer;
    labeli : TLabel;
    procedure Click;
    procedure SetState(bValue: boolean);
  protected

    { Protected-Deklarationen}
  public
    { Public-Deklarationen}
  published
    property Down : Boolean read bDown write SetState;
    property Visina1: Integer read bHeight write bHeight;
    property Visina2: Integer read bVisina write bVisina;

  end;

procedure Register;

implementation



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

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

  labeli := TLabel.Create(Self);
  labeli.Parent := Self;
  labeli.Top := Self.Top;
  labeli.Left := Self.Left;
  labeli.Caption := 'test';
  labeli.Visible := true;
end;

procedure TSwitch.Click;
begin
     if bHeight = Height then
     begin
          Height := bVisina;
          bDown := true
     end
     else
     begin
          Height := bHeight;
          bDown := false
     end;
end;

procedure TSwitch.SetState(bValue: boolean);
begin
     if bValue = true then
     begin
          bDown := true;
          Height := bVisina;
     end
     else
     begin
          bDown := false;
          Height := bHeight;
     end
end;

end.

Danke
MarcoWarm für die Idee mit Constructor!!!! :cheers:


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:21 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz