Autor Beitrag
Slice
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: Do 06.11.08 15:29 
Also ich habe folgendes Problem:

Ich soll ein koordinatensytem in eine Paintbox machen. Das System soll allerdings schon beim Start des Programms in der Paintbox sein und nicht erst durch nen Buttonklick oder ähnliches erscheinen. Wie ich die Linien mache ist mir schon klar, aber ich weiß leideer nicht, wo ich die befehle im Quelltext hinschreiben soll.

gruß Slice
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 06.11.08 15:56 
Hi,

Das machst du dann im FormCreate-Event. Eventuell gibt es dafür auch die Komponente TChart. Kenne ich aber selbst nicht, da die bei Turbo Delphi 06 nicht dabei ist.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Slice Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: Do 06.11.08 17:46 
also bei FormCreate hab ich es schon probiert aber es wird nix in der Paintbox angezeigt. TChart muss ich mal noch ausprobieren
Jerk
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 251

Vista Ultimate, Ubuntu
Turbo Delphi 2006
BeitragVerfasst: Do 06.11.08 17:48 
Im onFormCreate ist richtig, das wird dann wohl an deiner Implementierung liegen das das icht geht, poste doch mal den Teil zum Zeichnen.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 06.11.08 17:50 
Nein, FormCreate ist falsch, da das Fenster danach neu gezeichnet wird und somit der Paintboxinhalt wieder geleert wird. Ich würde es erstmal ins OnPaint-Event der Paintbox setzen.

_________________
We are, we were and will not be.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Do 06.11.08 18:24 
user profile iconGausi hat folgendes geschrieben Zum zitierten Posting springen:
Nein, FormCreate ist falsch, da das Fenster danach neu gezeichnet wird und somit der Paintboxinhalt wieder geleert wird. Ich würde es erstmal ins OnPaint-Event der Paintbox setzen.
Da hatte ich wohl ein Brett vorm Kopf :autsch:

@Threadsteller: Eine Paintbox wird grundsätzlich nur im OnPaint-Ereignis bemalt.

Jetzt wird eine Paintbox aber bei jedem OnPaint wieder gelöscht. Um nicht jedes mal mit dem Canvas herumhantieren zu müssen, legst du am besten eine neue Variable im Private-Teil der Form an.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
type
  TForm1 = class (TForm)
    {..}
  private
    { private-declarations }
    FHintergrund: TBitmap;
  end;


Jetzt im FormCreate die Bitmap erzeugen(FHintergrund := TBitmap.Create; FHintergrund.SetSize()..) und eine Prozedur aufrufen, mit der du das Koordinatensystem malst(da schriebst du dir am besten eine weitere Prozedur, die du da aufrufst. Sonst wird das zu unübersichtlich).

Im Formdestroy nun noch die Bitmap wieder freigeben.

Im OnPaint der Bitmap malst du jetzt mit StretchDraw FHintergrund auf die Paintbox. Nachdem du den Hintergrund gezeichnet hast, noch die Graphen, etc., drüberzeichnen.

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
Slice Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 28



BeitragVerfasst: Do 06.11.08 18:37 
ok werd ich morgen mal probieren^^ danke leute
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 06.11.08 18:41 
Zitat:
Eine Paintbox wird grundsätzlich nur im OnPaint-Ereignis bemalt.

Nö, geht auch z.B. auf ButtonClick() ;)
nagel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 708

Win7, Ubuntu 10.10

BeitragVerfasst: Do 06.11.08 20:29 
user profile iconDeddyH hat folgendes geschrieben Zum zitierten Posting springen:
Zitat:
Eine Paintbox wird grundsätzlich nur im OnPaint-Ereignis bemalt.

Nö, geht auch z.B. auf ButtonClick() ;)

Ist aber nicht Sinn der Sache. ;)
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Do 06.11.08 20:33 
user profile iconDeddyH hat folgendes geschrieben Zum zitierten Posting springen:
Zitat:
Eine Paintbox wird grundsätzlich nur im OnPaint-Ereignis bemalt.

Nö, geht auch z.B. auf ButtonClick() ;)

Es geht schon, aber es macht keinen Sinn: wenn das Fenster neu gezeichnet werden muss, ist der Inhalt des Canvas' wieder weg. ;)
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 07.11.08 09:07 
Das hab ich ja auch nicht bestritten, aber für mich klang das so, als sei eine Zeichenausgabe nur im OnPaint möglich, und das stimmt ja so nicht.
Hidden
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2242
Erhaltene Danke: 55

Win10
VS Code, Delphi 2010 Prof.
BeitragVerfasst: Fr 07.11.08 17:23 
So war es selbstverständlich nicht gemeint :) Aber um das nochmal eindeutig festzustellen: Es ist völliger Quatsch, eine Paintbox außerhalb des OnPaints zu bemalen(esseidenn natürlich man will, dass es sofort wieder weg ist^^).

mfG,

_________________
Centaur spears can block many spells, but no one tries to block if they see that the spell is a certain shade of green. For this purpose it is useful to know some green stunning hexes. (HPMoR)
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 07.11.08 17:44 
Das gilt aber für alle TCustom-/TGraphicControls.