Autor Beitrag
r_le
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Sa 13.03.04 00:51 
Hi,
ich habe folgendes Problem: ich erzeuge eine Instanz der Klasse TPoly, und dabei soll eine PolyLine-Figur in ScrollBox1 gezeichnet werden. Funktioniert auch soweit, nur irgendwie wird die Figur rechts abgeschnitten. Wenn ich die Figur ein bißchen kleiner mache paßt es. Aber woran liegt es denn, daß es in dieser Größe nicht geht??


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:
unit Poly_s;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Menus, ExtCtrls, StdCtrls;

type
  TForm1 = class(TForm)
    ScrollBox1: TScrollBox;
    procedure FormPaint(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

  TPoly=class(TShape)
  protected
    procedure paint; override;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TPoly.Paint;
begin
  Canvas.Polyline([Point(4010), Point(2060), Point(7030),
    Point(1030), Point(6060), Point(4010)]);
end;

procedure TForm1.FormPaint(Sender: TObject);
var Poly:TPoly;
begin
  Poly:=TPoly.Create(self);
  Poly.Parent:=ScrollBox1;
  Poly.Left:=50;
  Poly.Top:=50;
end;

end.
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mo 15.03.04 20:35 
Hallo,

wie zeichnest du denn da rein? In eine TPaintBox, ein TImage, oder wie? Wenn es ein TImage ist, stimmt die Größe der Kompo oder des Pictures im Image nicht. Wenn es ein TPaintBox ist, musst du bei jedem OnPaint-Ereignis neu zeichnen - ganz wichtig!

_________________
Life is a bad adventure, but the graphic is really good!
r_le Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Mo 15.03.04 21:00 
Hallo!

Also ich würde mal denken, daß ich auf den Canvas von Form1 zeichne, und durch die Zuweisung "Poly.Parent:=ScrollBox1;" erscheint es dann auf der ScrollBox. Soviel zu meiner Schätzung, allzu viel Ahnung hab ich davon nämlich nicht. ;-)

Ich versuche gerade einen größeren Delphi-Quellcode zu verstehen, und dort war der Autor der Ansicht, daß man das ganze eben nicht so machen kann, sondern es zuerst in eine PaintBox zeichnen und dann der ScrollBox zuweisen müsse. Und da ich nicht verstehe, warum das so sein soll, hab ich es eben hier mal ohne PaintBox probiert. Nur offensichtlich gibt es ja tatsächlich Probleme.
Zeichne ich aber z.B. statt der Polyline ne Ellipse, dann funktioniert alles wunderbar!?!?!?
Andreas Pfau
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 997



BeitragVerfasst: Mo 15.03.04 22:09 
Hallo,

:oops: habe ich wohl doch etwas ZU flüchtig gelesen....

also, es schein als ob du dem Objekt gar keine Größe zugewiesen hast! Du musst natürlich eine angemessen Größe angeben, abgesichts der Abmessungen des Polygons mindestens 70x60. tust du das nicht, wird die Standardgröße genommen, definiert von TShape. Du kannst da auch ein "override" einbauen, ganz einfach indem du die Abmessungen (Height und Width) der Klasse in "constructor Create" änderst.

_________________
Life is a bad adventure, but the graphic is really good!
r_le Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Mo 15.03.04 22:38 
Ah ja, das funktionert. Danke! :D