AGB  ·  Datenschutz  ·  Impressum  







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

Repaint, Invalidate oder doch etwas anderes

Ein Thema von Alter Mann · begonnen am 30. Mär 2006 · letzter Beitrag vom 1. Apr 2006
 
Benutzerbild von ChrisE
ChrisE

Registriert seit: 15. Feb 2006
Ort: Hechingen
504 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#7

Re: Repaint, Invalidate oder doch etwas anderes

  Alt 31. Mär 2006, 09:01
Hallo,

es klappt zwar mit dem direkten Repaint aufruf, doch ich finde man sollte es eher so machen:

in der deklaration der Klasse
Delphi-Quellcode:
protected
  ...
  procedure Paint;override;
  ...
dann noch folgende Anpassungen:
Delphi-Quellcode:
procedure TComboBoxPanel.DragDrop(Source: TObject; X, Y: Integer);
begin
  if (Source is TCustomComboBox) then
  begin
    Canvas.Brush.Color := Color;
    Canvas.FillRect(ClientRect);
    if FItemHeight < (Source as TCustomComboBox).Height then FItemHeight := (Source as TCustomComboBox).Height;
    if FItemList.IndexOf(Source) = -1 then begin // noch nicht in der Liste
      FItemList.Add(Source);
      TCustomComboBox(Source).Parent := Self;
    end;
    Repaint;
  end;
end;
Delphi-Quellcode:
procedure TComboBoxPanel.DrawItems;
var
  I, J, NL, NT : Integer;
  LineRect : TRect;
begin
  //for I := ControlCount -1 downto 0 do RemoveControl(Controls[I]);
  J := 0;
  for I := 0 to FItemList.Count -1 do
  begin
    // Position TCustomComboBox
    NL := FOffset * (i+1) + i * TCustomComboBox(FItemList[i]).Width;
    NT := FOffset * (i+1) + i * TCustomComboBox(FItemList[i]).Height;

    // Draw TCustomComboBox
    with TCustomComboBox(FItemList.Items[I]) do
    begin
      //Parent := Self;
      Left := NL;
      Top := NT;
    end;
    // Draw Link-Lines
    if J = 0 then
    begin
      LineRect.Left := (NL + TCustomComboBox(FItemList.Items[I]).Width) - (FOffset * 2);
      LineRect.Top := (NT + TCustomComboBox(FItemList.Items[I]).Height) + 2;
      Inc(J);
    end
    else
    begin
      LineRect.Right := NL;
      LineRect.Bottom := NT + (TCustomComboBox(FItemList.Items[I]).Height div 2);
      DrawLine(LineRect);
      LineRect.Left := (LineRect.Right + TCustomComboBox(FItemList.Items[I]).Width) - (FOffset * 2);
      LineRect.Top := LineRect.Bottom + FOffset + 3;
    end;
  end;
end;
Delphi-Quellcode:
procedure TComboBoxPanel.Paint;
begin
  inherited;
EDIT:
// if FAutoSize then Height := GetNewHeight;
// Das gehört hier sicher nicht rein
EDIT ENDE
  if FShowGrid then DrawGrid;
  DrawItems;
end;

procedure TComboBoxPanel.RePaint;
begin
  inherited Repaint;
  if FAutoSize then Height := GetNewHeight;
end;
Das ist zwar etwas komplizierter als die Lösung von marabu, aber wer denkt bei der nutzung einer Komponente schon daran diese Per Repaint neu zu zeichnen. Somit sollte sie sich - so finde ich zumindest - selber neu zeichnen.

Gruß, Chris
Christian E.
Es gibt 10 Arten von Menschen, die die Binär lesen können und die die es nicht können

Delphi programming rules
  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 17:47 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