Autor Beitrag
moloch
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Fr 05.03.04 11:06 
Hallo Leute,

ich suche eine Komponente für delphi 5 wo ich sowas wie einen kleinen Knopf oder so habe,der das objekt dann vergrößert oder verkleinert.

Sprich wie ein Panel nur mit meiner gewünschten funktion

MFG

Moloch
Loryn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34

Win 98, ME
D4 Stand.
BeitragVerfasst: Fr 05.03.04 13:29 
Hallo,

ich kenne eine solche Komponente nicht, aber sie wäre leicht selbst zu schreiben.

Leite eine neue Klasse von TButton ab. Füge zwei Eigenschaften hinzu: Eine, die die Größenänderung vorgibt und eine die auf das in der Größe zu ändernde Control (TControl hat die Eigenschaften Width, Height) zeigt. Dann überschreibst Du die Methode Click, in der du die Größenänderung vornimt.

Also z.B. so:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
type
  TSizeButton = class(TButton)
  private
    FControlLink: TControl;
    FDelta: Integer;
  public
    constructor Create(aOnwer: TComponent); override;
    procedure Click; override;
  published
    property ControlLink: TControl read FControlLink write FControlLink;
    property Delta: Integer read FDelta write SetDelta;
  end;



ausblenden 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:
{ TSizeButton }

constructor TSizeButton.Create(aOnwer: TComponent);
begin
  inherited Create(aOwner);
  Delta := 16// Voreinstellung: um 16 Pixel vergrößern
  Width := 25;
  Height := 25;
end;

procedure TSizeButton.Click;
begin
  if FContolLink <> nil
  then with FControlLink do begin
    Width := Width+Delta;
    Height := Heigth+Delta;
  end;
  inherited Click;
end;

procedure TSizeButton.SetDelta(Value: Integer);
//        setzt Property Delta
begin
 FDelta := Value;
 if FDelta > 0
 then Caption := '>'
 else Caption := '<';
end;



Soweit mein "Schnellschuß". Man könnte auch zwei Delta-Eigenschaften definieren, eine für Width und eine für Height.

Gruß Loryn
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Mi 10.03.04 10:07 
hey,

danke erstmal für deine Mühe.Ich werde das mal ausprobieren.

moloch
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Mi 10.03.04 10:16 
hey,

also so gut konnte ich deine methode noch nicht interpretieren, da ich noch einen Fehler habe und nicht weiterkomme.Also ich habe erstmal einen button ins projekt geholt und dann deinen Quellcode reingeholt.

Der Compiler bleibt in der Zeile "property Delta: Integer read FDelta write SetDelta;" stehen und sagt: Feld oder Methodenbezeichner erwartet.

Kannst Du mir nochmal auf die Sprünge helfen. Ich habe noch nie eine Komponente irgendwie selber geschrieben oder verändert.

moloch
Loryn
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 34

Win 98, ME
D4 Stand.
BeitragVerfasst: Mi 10.03.04 11:54 
Hallo,

ich habe eine Zeile vergessen:

Im private-Abschnitt der type-Anweisung für TSizeButton fehlt:

procedure SetDelta(Value: Integer);

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
type 
  TSizeButton = class(TButton) 
  private 
    FControlLink: TControl; 
    FDelta: Integer; 
    procedure SetDelta(Value: Integer);  // DIESE ZEILE FEHLT!!!
  public 
    constructor Create(aOnwer: TComponent); override
    procedure Click; override
  published 
    property ControlLink: TControl read FControlLink write FControlLink; 
    property Delta: Integer read FDelta write SetDelta; 
  end;



Gruß Loryn
moloch Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 451

Win 2000
D5 Prof
BeitragVerfasst: Do 11.03.04 09:56 
hey,

ich werde das ausprobieren und dir bescheid sagen.
danke erstmal

moloch