Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Prism Paintbox - Koordinatenkreuz (https://www.delphipraxis.net/106643-paintbox-koordinatenkreuz.html)

andiak 14. Jan 2008 13:12


Paintbox - Koordinatenkreuz
 
Ich habe hier in einer Paintbox ein koordinaten kreuz

Delphi-Quellcode:
procedure TForm1.DrawCoords;
var
  i,h: Integer;
begin
  with PaintBox1.Canvas do
    begin
    Pen.Color:=clBlack;
    //Ordinate & Abszisse
    MoveTo(0, PaintBox1.Height div 2);
    LineTo(PaintBox1.Width, PaintBox1.Height div 2);
    MoveTo(PaintBox1.Width div 2, 0);
    LineTo(PaintBox1.Width div 2, PaintBox1.Height);
    //Skalierung
    for i := 1 to 20 do
      begin
      h := i * (PaintBox1.Width div 20);
      MoveTo(h, (PaintBox1.Height div 2) - 3);
      LineTo(h, (PaintBox1.Height div 2) + 3);
      MoveTo((PaintBox1.Width div 2) - 3, h);
      LineTo((PaintBox1.Width div 2) + 3, h);
      end;
    //Beschriftung
    TextOut((PaintBox1.Width div 2) + 3,(PaintBox1.Height div 2) + 1, '0');
    TextOut((PaintBox1.Width div 2) + 48, (PaintBox1.Height div 2) + 6,'1');
     TextOut((PaintBox1.Width div 2) - 55, (PaintBox1.Height div 2) + 6,'-1');
    TextOut((PaintBox1.Width div 2) + 6,(PaintBox1.Height div 2) - 37,'1');
    //Spitzen
    MoveTo(PaintBox1.Width - 5, (PaintBox1.Height div 2) - 5);
    LineTo(PaintBox1.Width, (PaintBox1.Height div 2));
    LineTo(PaintBox1.Width - 5, (PaintBox1.Height div 2) + 5);
    MoveTo((PaintBox1.Width div 2) - 5, 5);
    LineTo((PaintBox1.Width div 2), 0);
    LineTo((PaintBox1.Width div 2) + 5, 5);
  end;
end;
Jetzt gehts um die Punkte auf dem Koordinatenkreuz.
Der Punkt 0/0 liegt ja in der mitte der paintbox
aber 0/0 auf der paintbox ist ja ganz oben links in der ecke

Wie kann ich dies richtig machen?
Die paintbox ist 500x500 pixel groß

DeddyH 14. Jan 2008 13:15

Re: Paintbox - Koordinatenkreuz
 
Der Mittelpunkt des Kreuzes muss demnach auf PaintBox.Width div 2, PaintBox.Height div 2 leigen.

andiak 14. Jan 2008 13:28

Re: Paintbox - Koordinatenkreuz
 
Ok PaintBox.Width div 2, PaintBox.Height div 2 und wie mit center deklarieren?

Luckie 14. Jan 2008 13:34

Re: Paintbox - Koordinatenkreuz
 
Zitat:

Zitat von andiak
Ok PaintBox.Width div 2, PaintBox.Height div 2 und wie mit center deklarieren?

Hä? Du darfst auch mehr als drei Worte schreiben, um uns dein Problem zu schildern.

Scorp 14. Jan 2008 13:44

Re: Paintbox - Koordinatenkreuz
 
mein Problem habe ich ja oben schon geschildert.... ich möchte meine Paintbox so einstellen das der mittelpunkt meiner Paintbox 0/0 ist und nicht 250x250

(sorry mit anderen account eingelogt vom freund) Er hat ein anderes problem

Luckie 14. Jan 2008 13:51

Re: Paintbox - Koordinatenkreuz
 
Und warum sagst du das nicht? Mit MSDN-Library durchsuchenSetMapMode kannst du das Koordinatensystem anpassen.

andiak 14. Jan 2008 13:56

Re: Paintbox - Koordinatenkreuz
 
ähh SetMapMode ich klick drauf komm auf einer Englischen seite mit VIsual basic wenn ich das richtig seh o_O
ich glaube nicht das mit das hilft

Aurelius 14. Jan 2008 13:59

Re: Paintbox - Koordinatenkreuz
 
Doch das hilft dir, da es dieselben funktionen/proceduren auch in Delphi gibt (kommen ja alle von Microsoft). ;)

DeddyH 14. Jan 2008 14:00

Re: Paintbox - Koordinatenkreuz
 
Zitat:

Zitat von Win32 SDK
The SetMapMode function sets the mapping mode of the specified device context. The mapping mode defines the unit of measure used to transform page-space units into device-space units, and also defines the orientation of the device's x and y axes.

int SetMapMode(

HDC hdc, // handle of device context
int fnMapMode // new mapping mode
);


Parameters

hdc

Identifies the device context.

fnMapMode

Specifies the new mapping mode. It can be any one of the following values:

Value Description
MM_ANISOTROPIC Logical units are mapped to arbitrary units with arbitrarily scaled axes. Use the SetWindowExtEx and SetViewportExtEx functions to specify the units, orientation, and scaling that you want.
MM_HIENGLISH Each logical unit is mapped to 0.001 inch. Positive x is to the right; positive y is up.
MM_HIMETRIC Each logical unit is mapped to 0.01 millimeter. Positive x is to the right; positive y is up.
MM_ISOTROPIC Logical units are mapped to arbitrary units with equally scaled axes; that is, one unit along the x-axis is equal to one unit along the y-axis. Use the SetWindowExtEx and SetViewportExtEx functions to specify the units and the orientation of the axes that you want. Graphics device interface (GDI) makes adjustments as necessary to ensure the x and y units remain the same size (for example, if you set the window extent, the viewport will be adjusted to keep the units isotropic).
MM_LOENGLISH Each logical unit is mapped to 0.01 inch. Positive x is to the right; positive y is up.
MM_LOMETRIC Each logical unit is mapped to 0.1 millimeter. Positive x is to the right; positive y is up.
MM_TEXT Each logical unit is mapped to one device pixel. Positive x is to the right; positive y is down.
MM_TWIPS Each logical unit is mapped to one twentieth of a printer's point (1/1440 inch, also called a "twip"). Positive x is to the right; positive y is up.


Return Values

If the function succeeds, the return value identifies the previous mapping mode.
If the function fails, the return value is zero.

Remarks

The MM_TEXT mode allows applications to work in device pixels, whose size varies from device to device.
The MM_HIENGLISH, MM_HIMETRIC, MM_LOENGLISH, MM_LOMETRIC, and MM_TWIPS modes are useful for applications drawing in physically meaningful units (such as inches or millimeters).
The MM_ISOTROPIC mode ensures a 1:1 aspect ratio.
The MM_ANISOTROPIC mode allows the x-coordinates and y-coordinates to be adjusted independently.



Alle Zeitangaben in WEZ +1. Es ist jetzt 23:54 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