AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi Events einer Komponenete in einer NEUEN ererbten Komponente
Thema durchsuchen
Ansicht
Themen-Optionen

Events einer Komponenete in einer NEUEN ererbten Komponente

Ein Thema von SoGraDEs · begonnen am 10. Mai 2007 · letzter Beitrag vom 11. Mai 2007
 
SoGraDEs

Registriert seit: 12. Mär 2005
Ort: Bremen
28 Beiträge
 
Delphi XE7 Professional
 
#1

Events einer Komponenete in einer NEUEN ererbten Komponente

  Alt 10. Mai 2007, 11:00
Ich habe eine Komponente TMyPanel = class(TPanel) geschrieben.
Der Constructor (override) erweiter um
L1 := TLabel.Create(self) ein Label auf dem Panel zu erzeugen.
Geht auch. Kann auch die von mir gewünschten Eigenschaften von L1
im Objektinspector von TMyPanel ändern.
Soweit so gut.
Aber ich möchte nicht nur die EVENTs (z.B OnClick) vom Panel verwenden,
sondern ich möchte auch das OnClick Ereignis von dem Label, das
auf dem Panel liegt, auswerten, weil wenn man auf das Label clickt, dann
gibt es von dem daruter liegendem Panel kein OnClick Ereignis .
Alle Foren-Tutoriels durchkemmt, aber keine Antwort auf mein Problem
gefunden.
Jetzt brauche ich einen guten Tip

Delphi-Quellcode:
unit Switch;

interface

uses
  SysUtils , Classes, Controls, ExtCtrls,
  StdCtrls ,
  Dialogs ,
  Graphics ;
   {
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, Switch
   }

type
  TMyPanel = class(TPanel)
  private { Private-Deklarationen }
   bDown : boolean ;
   L1 : TLabel ;
   L2 : TLabel ;
   L3 : TLabel ;

   xL1_Top : integer ;
   xL1_Left : integer ;
   xL1_Width : integer ;
   xL1_Height : integer ;
   xL1_Color : TColor ;
   xL1_FontName : TFontName ;
   xL1_FontColor : TColor ;
   xL1_FontSize : integer ;
   xL1_Caption : TCaption ;

   constructor Create(AOwner: TComponent) ; override ;
   destructor Destroy ; override ;

   procedure Click ; override ;
   procedure SetState(bValue : boolean );
   procedure Set_L1_Color(yL1_Color : TColor );
   procedure Set_L1_FontColor(yL1_FontColor : TColor );


  protected { Protected-Deklarationen }

  public { Public-Deklarationen }


  published { Published-Deklarationen }
  property L1_Top : integer read xL1_Top write xL1_Top ;
  property L1_Left : integer read xL1_Left write xL1_Left ;
  property L1_Width : integer read xL1_Width write xL1_Width ;
  property L1_Height : integer read xL1_Height write xL1_Height ;
  property L1_Color : TColor read xL1_Color write Set_L1_Color ; //xL1_Color ;
  property L1_FontName : TFontName read xL1_FontName write xL1_FontName ;
  property L1_FontColor : TColor read xL1_FontColor write Set_L1_FontColor ; //xL1_FontColor ;
  property L1_FontSize : integer read xL1_FontSize write xL1_FontSize ;
  property L1_Caption : TCaption read xL1_Caption write xL1_Caption ;

  property Down : boolean read bDown write SetState ;

  end;

procedure Register;


implementation

procedure Register;
begin
  RegisterComponents('Dirk', [TMyPanel]);
end;

constructor TMyPanel.Create(AOwner: TComponent);
begin
 inherited create(AOwner) ;

 L1 := TLabel.Create(self);
 L1.Parent := self ;
 L1.Visible := TRUE ;



 xL1_Left := 25 ;
 xL1_Top := 5 ;
 xL1_Height := 17 ;
 xL1_Width := 75 ;
 xL1_Color := clWhite ;
 xL1_FontName := 'Arial'       ;
 xL1_FontColor := clRed ;
 xL1_FontSize := 8 ;
 xL1_Caption := 'L1 = Label1' ;

 L1.AutoSize := FALSE ; // Festgeschrieben nicht änderbar !!

 L1.Left := xL1_Left ;
 L1.Top := xL1_Top ;
 L1.Height := xL1_Height ;
 L1.Width := xL1_Width ;
 L1.Color := xL1_Color ;
 L1.Font.Name := xL1_FontName ;
 L1.Font.Color := xL1_FontColor ;
 L1.Font.Size := xL1_FontSize ;
 L1.Caption := xL1_Caption ;

 //==================================
 L2 := TLabel.Create(self);
 L2.Parent := self ;
 L2.Visible := TRUE ;

 L2.Left := 30 ;
 L2.Top := 30 ;
 L2.Height := 10 ;
 L2.Width := 10 ;
 L2.Caption := 'y2'  ;

end;


destructor TMyPanel.Destroy ;
begin
  if L1 <> nIl then L1.Free ;
  if L2 <> nIl then L2.Free ;
  if L3 <> nIl then L3.Free ;

  inherited destroy ;
end;



procedure TMyPanel.Set_L1_Color(yL1_Color : TColor );
begin
  xL1_Color := yL1_Color ; L1.Color := xL1_Color ;
end;
procedure TMyPanel.Set_L1_FontColor(yL1_FontColor : TColor );
begin
  xL1_FontColor := yL1_FontColor ; L1.Font.Color := xL1_FontColor ;
end;


procedure TMyPanel.Click ;
begin
  if BevelOuter = bvRaised then
    begin
    BevelOuter := bvLowered ;
    bDown := TRUE ;
    end
  else
    begin
    BevelOuter := bvRaised ;
    bDown := FALSE ;
    end;

  inherited Click ;
end;

procedure TMyPanel.SetState(bValue: Boolean);
begin
  if bValue = TRUE then
    begin
    bDown := TRUE ;
    BevelOuter := bvLowered ;
    end
    else
    begin
    bDown := FALSE ;
    BevelOuter := bvRaised ;
    end;
end;

end.
Viele Grüße aus Bremen
  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 20:29 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