AGB  ·  Datenschutz  ·  Impressum  







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

TPanel mit mehrzeiligem Text ?

Ein Thema von mschaefer · begonnen am 3. Mai 2004 · letzter Beitrag vom 3. Mai 2004
 
Benutzerbild von mschaefer
mschaefer

Registriert seit: 4. Feb 2003
Ort: Hannover
2.033 Beiträge
 
Delphi 12 Athens
 
#5

Re: TPanel mit mehrzeiligem Text ?

  Alt 3. Mai 2004, 14:09
Moin moin,

also das mehrzeilige Panel hat mich doch noch nicht losgelassen, zumal ich nur eine kommerzielle Komponente gefunden habe. Jetzt habe ich mal einen Rohbau der Komponente zusammengestrickt. Hakelt noch etwas und ich weiss leider nicht wie ich da Alignment reinbekomme...

Delphi-Quellcode:

Unit MyOanel
interface

uses Classes, SysUtils, dialogs,
      Windows, Forms, Messages;

{                                                                              }
{                                                                              }
type
{                                                                              }
{   TMyPanel                                                                   }

    procedure Register;


    TMyPanel = class(TPanel)
    private
        FCaption_List : TStrings;
        procedure DrawCaption
        ( Text : string);
    public
        constructor Create
        ( AOwner : TComponent ); override;
        destructor destroy;

        procedure SetCaption
        ( Text : String );
        function GetCaption : String;

        procedure SetCaption_List
        ( LCaption_List : TStrings );

    published
        property Caption_List : TStrings
                                              read FCaption_List
                                              write SetCaption_List;

        property Caption : String
                                              read GetCaption
                                              write SetCaption;

    end;

{                                                                              }
{                                                                              }
implementation
{                                                                              }
{                                                                              }

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

   {                                                                           }
   {  TMyPanel                                                                 }


          constructor TMyPanel.Create (AOwner:TComponent);
          begin
               inherited Create(AOwner);
               FCaption_List := TStringList.Create;
          end;

          destructor TMyPanel.destroy;
          begin
               FCaption_List.Destroy;
               inherited Destroy;
          end;

          procedure TMyPanel.DrawCaption
          ( Text : string);
          var
               Rect : TRect;
          begin
               Rect.Left := 5;
               Rect.Top := 5;
               Rect.Right := Width + Left;
               Rect.Bottom := Height + Top;
               DrawText( Canvas.Handle,
                         PChar ( Text ),
                         Length( Text ),
                         Rect, DT_RTLREADING); //DT_RIGHT
          end;

          function TMyPanel.GetCaption: String;
          begin
               DrawCaption( Text );
               Result := copy(
                                FCaption_List.Text
                             , 1
                             , length(FCaption_List.Text)-2
                             );
          end;

          procedure TMyPanel.SetCaption
          ( Text : String );
          begin
               FCaption_List.Text := Text;
               DrawCaption( Text );
          end;

          procedure TMyPanel.SetCaption_List
          ( LCaption_List : TStrings );
          begin
               SetCaption( LCaption_List.Text );
          end;

end.
Vielleicht hat jemand mal etwas Zeit und gibt mir einen Tip wie man da Alignment
noch einbauen kann. Zentrieren fehlt mir vor allem.

Grüße zur Teatime // Martin
Martin Schaefer
  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 00:12 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