AGB  ·  Datenschutz  ·  Impressum  







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

Fehler beim Parent setzen eines Labels

Ein Thema von CreativeMD · begonnen am 27. Jun 2012 · letzter Beitrag vom 9. Jul 2012
Antwort Antwort
Benutzerbild von CreativeMD
CreativeMD

Registriert seit: 11. Okt 2011
127 Beiträge
 
Delphi XE2 Architect
 
#1

AW: Fehler beim Parent setzen eines Labels

  Alt 9. Jul 2012, 21:00
ok
Ich hab mir eine eigene Komponente geschriebn, doch
kann ich in der Komponente eine Scrollbar benutzten, auf jedenfall
wird sie irgendwie nicht angezeigt.

Delphi-Quellcode:
unit ChatEdit;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
  System.Classes, Vcl.Graphics, Vcl.StdCtrls, Winapi.CommCtrl ,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Contnrs, Vcl.Themes;

type
  TChatEdit = class(TCustomControl)
  private
    FFont: TFont;
    FLines: TStringList;
    Special_Objects: TObjectList;
    FScrollbar : TScrollBar;

    procedure setLines(Value: TStringList);
    procedure setFont(Value: TFont);
    procedure setScrollbar(Value : TScrollBar);
    procedure onScrollbarChange(Sender: TObject);
    { Private-Deklarationen }
  protected

    procedure Paint; override;
    { Protected-Deklarationen }
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    procedure Clear;
    procedure AddLine(Text: String);
    function Count: Integer;


    { Public-Deklarationen }
  published
    property OnClick;
    property OnMouseMove;

    property Font: TFont read FFont write setFont;
    property Lines: TStringList read FLines write setLines;
    property Scrollbar : TScrollBar read FScrollbar write setScrollbar;
    { Published-Deklarationen }
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Chat', [TChatEdit]);
end;

constructor TChatEdit.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FLines := TStringList.Create;
  FFont := TFont.Create;
  Special_Objects := TObjectList.Create;

  FScrollbar := TScrollBar.Create(self);
  FScrollbar.Kind := sbVertical;

  FScrollbar.OnChange := onScrollbarChange;


  FScrollbar.Top := 0;

  FScrollbar.Width := 20;

  

  FLines.Add(Self.GetNamePath);
end;

destructor TChatEdit.Destroy;
begin
  FFont.Destroy;
  Special_Objects.Free;
  FLines.Free;
  inherited Destroy;
end;

procedure TChatEdit.setFont(Value : TFont);
begin
FFont.Assign(Value);
Canvas.Font.Assign(FFont);
Paint;
end;

procedure TChatEdit.setLines(Value: TStringList);
begin
FLines.Assign(Value);
  Paint;
end;

procedure TChatEdit.setScrollbar(Value: TScrollBar);
begin
FScrollbar.Assign(Value);
Paint;
end;

procedure TChatEdit.Paint;
var
  zahl, height: Integer;
begin

  inherited;

  height := Canvas.TextHeight('h');
  for zahl := 0 to FLines.Count - 1 do
  begin
      Canvas.TextOut(0, zahl * height - FScrollbar.Position, FLines[zahl]);
  end;

  if zahl * height > Self.Height then
  begin

    FScrollbar.Max := zahl * height;
    FScrollbar.PageSize := zahl * height;


    FScrollbar.Enabled := true;
  end
  else
  begin
    FScrollbar.Enabled := false;
  end;

  FScrollbar.Left := Self.Width - FScrollbar.Width;
  FScrollbar.Height := Self.Height;
end;

procedure TChatEdit.onScrollbarChange(Sender: TObject);
begin
  Paint;
end;

function TChatEdit.Count: Integer;
begin
  Result := FLines.Count;
end;



procedure TChatEdit.Clear;
begin
  FLines.Clear;
end;

procedure TChatEdit.AddLine(Text: string);
begin
  FLines.Add(Text);
end;

end.
  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 05:36 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