Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Algorithmen, Datenstrukturen und Klassendesign (https://www.delphipraxis.net/78-algorithmen-datenstrukturen-und-klassendesign/)
-   -   Delphi Windoweinstellungen (vgl. GTR) werden falsch berrechnet (https://www.delphipraxis.net/157336-windoweinstellungen-vgl-gtr-werden-falsch-berrechnet.html)

MetalAddict 8. Jan 2011 13:19

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:
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.
Danke für Antworten im Voraus! :)
Grüße


Alle Zeitangaben in WEZ +1. Es ist jetzt 07:10 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz