AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi Komponente (TImage & TLabel) -> Image wird nicht angezeigt
Thema durchsuchen
Ansicht
Themen-Optionen

Komponente (TImage & TLabel) -> Image wird nicht angezeigt

Ein Thema von NoGAD · begonnen am 8. Apr 2024 · letzter Beitrag vom 18. Mai 2024
 
Benutzerbild von NoGAD
NoGAD

Registriert seit: 31. Jan 2006
Ort: Weimar
344 Beiträge
 
Delphi 10.4 Sydney
 
#1

Komponente (TImage & TLabel) -> Image wird nicht angezeigt

  Alt 8. Apr 2024, 08:09
Hallo,

Folgende Unit soll eigentlich ein TImage und ein TLabel kombiniert anzeigen. Leider wird zur Laufzeit das TPicture wieder gelöscht. In der Designansicht ist das TPicture dagegen komplett sichtbar - egal, welcher Typ (Gif/png/jpg/bmp) als Bild ausgewählt wurde.

Habe ich eine Property falsch gesetzt?

Delphi-Quellcode:
unit TRM_ImageLabel;

interface

uses
  System.SysUtils, System.Classes, Vcl.Controls, Vcl.ExtCtrls, Vcl.StdCtrls,
  Vcl.Imaging.GIFConsts,
  Vcl.Imaging.GIFImg,
  Vcl.Imaging.JConsts,
  Vcl.Imaging.jpeg,
  Vcl.Imaging.pngimage,
  Vcl.Imaging.pnglang;

type
  TLabelPosition = (lpTop, lpBottom, lpLeft, lpRight);

  TTRM_ImageLabel = class(TCustomPanel)
  private
    FSubImageComponent: TImage;
    FSubLabelComponent: TLabel;
    FLabelPosition: TLabelPosition;
    procedure SetLabelPosition(const Value: TLabelPosition);
  protected
    procedure Resize; override;
  public
    constructor Create(AOwner: TComponent); override;
  published
    property SubImageComponent: TImage read FSubImageComponent;
    property SubLabelComponent: TLabel read FSubLabelComponent;
    property Align;
    property Anchors;
    property OnClick;
    property OnDblClick;
    property OnMouseEnter;
    property OnMouseLeave;
    property LabelPosition: TLabelPosition read FLabelPosition write SetLabelPosition;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('TRM', [TTRM_ImageLabel]);
end;

{ TTRM_ImageLabel }

constructor TTRM_ImageLabel.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  (* Für meine eigenen Bedürfnisse *)
  Self.Width := 64;
  Self.Height := 97;

  FSubImageComponent := TImage.Create(Self);
  FSubImageComponent.Parent := Self;
  FSubImageComponent.Align := alClient;

  FSubLabelComponent := TLabel.Create(Self);
  FSubLabelComponent.Parent := Self;
  FSubLabelComponent.Height := 25;
  FSubLabelComponent.AlignWithMargins := False;
  FSubLabelComponent.Margins.Left := 0;
  FSubLabelComponent.Margins.Right := 0;
  FSubLabelComponent.Margins.Top := 8;
  FSubLabelComponent.Margins.Bottom := 0;
  FSubLabelComponent.Caption := 'TEST';
  SubLabelComponent.Font.Size := 14;

  FLabelPosition := lpBottom;

  Resize;
end;

procedure TTRM_ImageLabel.Resize;
begin
  inherited;
  case FLabelPosition of
    lpTop:
      begin
        FSubLabelComponent.Align := alTop;
        FSubLabelComponent.Alignment := taCenter;
      end;
    lpBottom:
      begin
        FSubLabelComponent.Align := alBottom;
        FSubLabelComponent.Alignment := taCenter;
      end;
    lpLeft:
      begin
        FSubLabelComponent.Align := alLeft;
        FSubLabelComponent.Alignment := taCenter;
      end;
    lpRight:
      begin
        FSubLabelComponent.Align := alRight;
        FSubLabelComponent.Alignment := taCenter;
      end;
  end;
end;

procedure TTRM_ImageLabel.SetLabelPosition(const Value: TLabelPosition);
begin
  if FLabelPosition <> Value then
  begin
    FLabelPosition := Value;
    Resize;
  end;
end;

end.
Mathias
Ich vergesse einfach zu viel.
  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:25 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