![]() |
Windoweinstellungen (vgl. GTR) werden falsch berrechnet
erledigt, kann gelöscht werden
Hallo, ich bin gerade dabei, einen GTR so gut es geht nachzuschreiben, und hänge bei den Windoweinstellungen: Wenn die Y-Achse von -10 bis 10 gehen soll, dann berechnet mir Delphi eine Differenz von 24, was dann zu einer falschen Berrechnung der Längeneinheiten führt. Aber wo bitte liegt mein Fehler? Mit der X-Achse klappt es problemlos und die Paint Box ist quadratisch, was mache ich also falsch?
Code:
Danke für Antworten im Voraus! :)
unit Unit1;
interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, NumEdit, ExtCtrls; type TForm1 = class(TForm) PaintBox1: TPaintBox; IntEdit1: TIntEdit; IntEdit2: TIntEdit; IntEdit3: TIntEdit; IntEdit4: TIntEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Button1: TButton; IntEdit5: TIntEdit; IntEdit6: TIntEdit; IntEdit7: TIntEdit; IntEdit8: TIntEdit; Label5: TLabel; Label6: TLabel; procedure Button1Click(Sender: TObject); private { Private-Deklarationen } public { Public-Deklarationen } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var xmin, xmax, ymin, ymax, deltax, deltay, einheitx, einheity: integer; begin xmin:=IntEdit1.Value; xmax:=IntEdit2.Value; ymin:=IntEdit3.Value; xmax:=IntEdit4.Value; deltax:=xmax-xmin; deltay:=ymax-ymin; einheitx:=PaintBox1.Width div deltax; einheity:=PaintBox1.Height div deltay; IntEdit5.Value:=deltax; IntEdit6.Value:=einheitx; IntEdit7.Value:=deltay; IntEdit8.Value:=einheity; PaintBox1.Canvas.MoveTo(0,round(einheity*ymax)); PaintBox1.Canvas.LineTo(Paintbox1.Width,round(einheity*ymax)); PaintBox1.Canvas.MoveTo(round(einheitx*xmax),0); PaintBox1.Canvas.LineTo(round(einheitx*xmax),Paintbox1.Height); end; end. Grüße |
Alle Zeitangaben in WEZ +1. Es ist jetzt 04:16 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