AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein GUI-Design mit VCL / FireMonkey / Common Controls Delphi Komponenteneigenschaften ändern -> Invalidate ausführen
Thema durchsuchen
Ansicht
Themen-Optionen

Komponenteneigenschaften ändern -> Invalidate ausführen

Ein Thema von Alex_ITA01 · begonnen am 5. Jan 2005 · letzter Beitrag vom 5. Jan 2005
Antwort Antwort
Alex_ITA01

Registriert seit: 22. Sep 2003
1.115 Beiträge
 
Delphi 12 Athens
 
#1

Komponenteneigenschaften ändern -> Invalidate ausführen

  Alt 5. Jan 2005, 15:02
Also ich habe folgendes Gerüst:
Ich möchte wenn ich im Objektinspektor die Eigenschaft "HeaderCount" ändere ein Update,Invalidate oder wie auch immer der ListBox aufrufen.Es würde ja reichen wenn ich den ersten Source aufrufen kann aber wie kann ich von SETTINGS auf meine Kompo zugreifen damit ich im Objektinspektor die Änderungen auch sofort sehe?
MFG Alex

Delphi-Quellcode:
  if Assigned(Settings) then
  begin
    for i := 0 to Settings.HeaderCount do
    begin
      with FHeaderControl do
      begin
        HS := Sections.Add;
        HS.Text := 'Item' + IntToStr(i);
        HS.Width := Width div Settings.HeaderCount;
      end;
    end;
    FHeaderControl.Invalidate;
  end;
Komponente:
Delphi-Quellcode:
unit HeaderListBox;

interface

uses
  SysUtils, Classes, Controls, StdCtrls, Types, Windows, Graphics, ComCtrls;

type
  TSettings = class(TPersistent)
  private
    { Private-Deklarationen }
    FHeaderCount: Byte;
    FTextColor : TColor;
    FFrameColor : TColor;
    procedure SetHeaderCount(Value : Byte);
    procedure SetTextColor (Value : TColor);
    procedure SetFrameColor (Value : TColor);
  protected
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }
    Constructor create;
  published
    { Published-Deklarationen }
    property HeaderCount : Byte read FHeaderCount write SetHeaderCount default 2;
    property TextColor : TColor read FTextColor write SetTextColor default clBlack;
    property FrameColor : TColor read FFrameColor write SetFrameColor default clWhite;
  end;

  THeaderListBox = class(TListBox)
  private
    { Private-Deklarationen }
    FSettings : TSettings;
    FHeaderControl : THeaderControl;
  protected
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }
    constructor Create(AOwner:TComponent); override;
    destructor Destroy; override;
    procedure Loaded; override;
    procedure CreateWnd; override;
  published
    { Published-Deklarationen }
    property Settings : TSettings read FSettings write FSettings;
  end;
{ ---------------------------------------------------------------------------- }
procedure Register;
{ ---------------------------------------------------------------------------- }
implementation
{ ---------------------------------------------------------------------------- }
procedure Register;
begin
  RegisterComponents('Test', [THeaderListBox]);
end;
{ ---------------------------------------------------------------------------- }
{ THeaderListBox }
{ ---------------------------------------------------------------------------- }
constructor THeaderListBox.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Self.Left := 248;
  Self.Width := 249;
  Self.Height := 185;
  Self.Top := 100;
  Self.Style := lbOwnerDrawFixed;
  Self.OnDrawItem := DrawAllItem;

  FSettings := TSettings.Create;
  
  if ComponentState = [csDesigning] then Exit;
end;
{ ---------------------------------------------------------------------------- }
procedure THeaderListBox.CreateWnd;
var
  i : Integer;
  HS: THeaderSection;
begin
  inherited;
  FHeaderControl := THeaderControl.Create(Self);
  FHeaderControl.Parent := Self.Parent;
  FHeaderControl.Align := alCustom;
  FHeaderControl.Left := 248;
  FHeaderControl.Width := 249;
  FHeaderControl.Height := 20;
  FHeaderControl.Top := 81;
  FHeaderControl.Style := hsButtons;
  FHeaderControl.Show;
  FHeaderControl.OnSectionResize := SectionResize;

  if Assigned(Settings) then
  begin
    for i := 0 to Settings.HeaderCount do
    begin
      with FHeaderControl do
      begin
        HS := Sections.Add;
        HS.Text := 'Item' + IntToStr(i);
        HS.Width := Width div Settings.HeaderCount;
      end;
    end;
    FHeaderControl.Invalidate;
  end;
end;
{ ---------------------------------------------------------------------------- }
destructor THeaderListBox.Destroy;
begin
  if Assigned(FSettings) then
    FSettings.Free;
  inherited;
end;
{ ---------------------------------------------------------------------------- }
procedure THeaderListBox.Loaded;
begin
  inherited Loaded;
  if ComponentState = [csDesigning] then Exit;
end;
{ ---------------------------------------------------------------------------- }
{ TSettings }
{ ---------------------------------------------------------------------------- }
constructor TSettings.create;
begin
  inherited Create;
  TextColor := clBlack;
  FrameColor := clWhite;
  FHeaderCount := 2;
end;
{ ---------------------------------------------------------------------------- }
procedure TSettings.SetHeaderCount(Value: Byte);
begin
  if Value <> FHeaderCount then
  begin
    FHeaderCount := Value;
    //Invalidate; <--- Aktualisieren der ListBox!!!
  end;
end;
{ ---------------------------------------------------------------------------- }
procedure TSettings.SetFrameColor(Value: TColor);
begin
  if Value <> FFrameColor then
  begin
    FFrameColor := Value;
    //Invalidate;
  end;
end;
{ ---------------------------------------------------------------------------- }
procedure TSettings.SetTextColor(Value: TColor);
begin
  if Value <> FTextColor then
  begin
    FTextColor := Value;
    //Invalidate;
  end;
end;
{ ---------------------------------------------------------------------------- }
end.
Let's fetz sprach der Frosch und sprang in den Mixer
  Mit Zitat antworten Zitat
Alex_ITA01

Registriert seit: 22. Sep 2003
1.115 Beiträge
 
Delphi 12 Athens
 
#2

Re: Komponenteneigenschaften ändern -> Invalidate ausführ

  Alt 5. Jan 2005, 15:29
Habs gelöst!!!
Lösung hier:

Delphi-Quellcode:
unit HeaderListBox;

interface

uses
  SysUtils, Classes, Controls, StdCtrls, Types, Windows, Graphics, ComCtrls;

type
  TSettings = class(TPersistent)
  private
    { Private-Deklarationen }
    FHeaderCount: Byte;
    FTextColor : TColor;
    FFrameColor : TColor;
    FOnEffectChange: TNotifyEvent;
    procedure SetHeaderCount(Value : Byte);
    procedure SetTextColor (Value : TColor);
    procedure SetFrameColor (Value : TColor);
    procedure DoChanges;
  protected
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }
    Constructor create;
  published
    { Published-Deklarationen }
    property HeaderCount : Byte read FHeaderCount write SetHeaderCount default 2;
    property TextColor : TColor read FTextColor write SetTextColor default clBlack;
    property FrameColor : TColor read FFrameColor write SetFrameColor default clWhite;
    property OnEffectChange: TNotifyEvent read FOnEffectChange write FOnEffectChange;
  end;

  THeaderListBox = class(TListBox)
  private
    { Private-Deklarationen }
    FSettings : TSettings;
    FHeaderControl : THeaderControl;
    procedure UpdateChanges(Sender: TObject);
  protected
    { Protected-Deklarationen }
  public
    { Public-Deklarationen }
    constructor Create(AOwner:TComponent); override;
    destructor Destroy; override;
    procedure Loaded; override;
    procedure CreateWnd; override;
  published
    { Published-Deklarationen }
    property Settings : TSettings read FSettings write FSettings;
  end;
{ ---------------------------------------------------------------------------- }
procedure Register;
{ ---------------------------------------------------------------------------- }
implementation
{ ---------------------------------------------------------------------------- }
procedure Register;
begin
  RegisterComponents('Jung', [THeaderListBox]);
end;
{ ---------------------------------------------------------------------------- }
{ THeaderListBox }
{ ---------------------------------------------------------------------------- }
constructor THeaderListBox.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  Self.Left := 248;
  Self.Width := 249;
  Self.Height := 185;
  Self.Top := 100;
  Self.Style := lbOwnerDrawFixed;

  FSettings := TSettings.Create;
  FSettings.OnEffectChange := UpdateChanges;

  if ComponentState = [csDesigning] then Exit;
end;
{ ---------------------------------------------------------------------------- }
procedure THeaderListBox.CreateWnd;
begin
  inherited CreateWnd;
  FHeaderControl := THeaderControl.Create(Self);
  FHeaderControl.Parent := Self.Parent;
  FHeaderControl.Align := alCustom;
  FHeaderControl.Left := 248;
  FHeaderControl.Width := 249;
  FHeaderControl.Height := 20;
  FHeaderControl.Top := 81;
  FHeaderControl.Style := hsButtons;
  FHeaderControl.Show;

  UpdateChanges(Self);
end;
{ ---------------------------------------------------------------------------- }
destructor THeaderListBox.Destroy;
begin
  if Assigned(FSettings) then
    FSettings.Free;
  inherited;
end;
{ ---------------------------------------------------------------------------- }
procedure THeaderListBox.UpdateChanges(Sender: TObject);
var
  i : Integer;
  HS: THeaderSection;
begin
  if Assigned(Settings) and Assigned(FHeaderControl) then
  begin
    FHeaderControl.Sections.Clear;
    for i := 0 to Settings.HeaderCount-1 do
    begin
      with FHeaderControl do
      begin
        HS := Sections.Add;
        HS.Text := 'Item' + IntToStr(i);
        HS.Width := Width div Settings.HeaderCount;
      end;
    end;
    FHeaderControl.Invalidate;
  end;
end;
{ ---------------------------------------------------------------------------- }
procedure THeaderListBox.Loaded;
begin
  inherited Loaded;
  if ComponentState = [csDesigning] then Exit;
end;
{ ---------------------------------------------------------------------------- }
{ TSettings }
{ ---------------------------------------------------------------------------- }
constructor TSettings.create;
begin
  inherited Create;
  TextColor := clBlack;
  FrameColor := clWhite;
  FHeaderCount := 2;
end;
{ ---------------------------------------------------------------------------- }
procedure TSettings.SetHeaderCount(Value: Byte);
begin
  if Value <> FHeaderCount then
  begin
    FHeaderCount := Value;
    DoChanges;
  end;
end;
{ ---------------------------------------------------------------------------- }
procedure TSettings.SetFrameColor(Value: TColor);
begin
  if Value <> FFrameColor then
  begin
    FFrameColor := Value;
    DoChanges;
  end;
end;
{ ---------------------------------------------------------------------------- }
procedure TSettings.SetTextColor(Value: TColor);
begin
  if Value <> FTextColor then
  begin
    FTextColor := Value;
    DoChanges;
  end;
end;
{ ---------------------------------------------------------------------------- }
procedure TSettings.DoChanges;
begin
  if Assigned(FOnEffectChange) then FOnEffectChange(Self);
end;
{ ---------------------------------------------------------------------------- }
end.
MFG Alex
Let's fetz sprach der Frosch und sprang in den Mixer
  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 12:44 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