Autor Beitrag
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: So 09.10.05 22:44 
Je nach Situation aktiviere/deaktiviere ich einige TSpeedButtons mittels der Enabled-Property. Irgendwie geht das recht gemütlich von statten, man kann bei nur 10 kleinen (8x8) Knöpfen schön mit zuschauen, wie die Leiste von links nach rechts verändert wird. Dabei sind flache Knöpfe noch langsamer. Es ist egal, ob ein Glyph zugewiesen ist oder ein Knopf ohne Caption total unsichtbar ist. TBitBtns sind auch schneller. Ist das normal?
cartridge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 209

Win XP
D4 Prof,D6 Prof
BeitragVerfasst: Mi 12.10.05 11:30 
Nö, ist eigentlich nicht normal. Poste mal Quelltext!

Gruß
Ingo
Spaceguide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Mi 12.10.05 12:25 
Also dass es total langsam war, lag am Parent-Panel, der war Doublebuffered, und das macht alles sehr langsam. Trotzdem sind SpeedButtons immer noch doppelt so langsam wie z.B. TBitBtn.

Hier mal ein schneller Test. Dauert bei mir etwa 200ms, um 400 Speedbuttons zu disablen und ich finde das langsam.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Controls, Forms, Dialogs, buttons, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    butts : array [0..19,0..19] of TSpeedButton;
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
 var b : TSpeedButton;
     x,y : integer;
begin
 for y:=0 to 19 do
 for x:=0 to 19 do
 begin
  b:=TSpeedButton.Create(self);
  b.Width:=16;
  b.Height:=16;
  b.Left:=x*16;
  b.Top:=y*16;
  b.Caption:='A';
  b.Flat:=true;
  b.Parent:=self;
  butts[x,y]:=b;
 end;
end;

procedure TForm1.Button1Click(Sender: TObject);
 var x,y : integer;
     st : integer;
begin
 st:=gettickcount;
 for y:=0 to 19 do
 for x:=0 to 19 do
  butts[x,y].enabled:=not butts[x,y].enabled;
 caption:=inttostr(gettickcount-st)+'ms';
end;

end.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 12.10.05 12:32 
speedbuttons sind eh ziemlich fehlerhaft, besonders der fehler im flat style stört mich, deshalb benutze ich sie auch nimmer :o
Spaceguide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Mi 12.10.05 13:32 
Ja, aber wenn man viele kleine Knöpfe macht, dann sind Knöpfe mit Rahmen einfach zu fett.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5285
Erhaltene Danke: 29

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 12.10.05 13:34 
dann mach das mit bildern, TImage nehmen und selbst machen, das geht glaube ich besser als mit speedbuttons 8)
Spaceguide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Mi 12.10.05 14:40 
Ja super, dann kann ich gleich für alles TImage nehmen.
cartridge
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 209

Win XP
D4 Prof,D6 Prof
BeitragVerfasst: Do 13.10.05 09:49 
Ich würde die Auführungsgeschwindigkeit (je nach Rechner: Prozessor, Takt,...) für normal empfinden. Wenn man so viele Buttons verwendet, ist es echt ratsam, andere Kompos zu verwenden. Image- Kompos verbrauchen idR zu viele Resourcen. Ich würde dann was selbstzeichnendes nehmen, wie z.B. Paintboxen oder besser zur Laufzeit erzeugte TWinControls oder aber Shapes mit zur Laufzeit erzeugten Canvases.

Gruß
Ingo
Spaceguide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Do 13.10.05 15:57 
TGraphicControl, von dem TSpeedButton abgeleitet ist, ist ja nicht unbedingt langsam. Ein TLabel, auch ein Abkömmling von TGraphicControl, ist rasend schnell beim aktivieren/deaktivieren. Herrgott, sogar ein TSpinEdit hat nicht diese Verzögerung und das besteht aus einem TEdit und zwei Knöpfen.
Spaceguide Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Fr 14.10.05 16:58 
Ich glaube ich hab den Schuldigen gefunden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TSpeedButton.CMEnabledChanged(var Message: TMessage);
const
  NewState: array[Boolean] of TButtonState = (bsDisabled, bsUp);
begin
  TButtonGlyph(FGlyph).CreateButtonGlyph(NewState[Enabled]);
  UpdateTracking;
  if FMouseInControl then Repaint else Paint; //war Repaint;
end;


Das Repaint ist sehr langsam, ein direktes Aufrufen der Paint Methode bringt den gleichen Effekt, ist aber wesentlich schneller. Jetzt bräuchte ich nur noch einen Tipp, wie ich die Methode in einer abgeleiteten Klasse von TSpeedButton einbaue, ich habe ja keinen Zugriff auf die privaten Member von TSpeedButton.