AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Paintbox - Koordinatenkreuz

Ein Thema von andiak · begonnen am 14. Jan 2008 · letzter Beitrag vom 14. Jan 2008
Antwort Antwort
andiak

Registriert seit: 1. Nov 2007
89 Beiträge
 
#1

Paintbox - Koordinatenkreuz

  Alt 14. Jan 2008, 13:12
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ß
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.545 Beiträge
 
Delphi 11 Alexandria
 
#2

Re: Paintbox - Koordinatenkreuz

  Alt 14. Jan 2008, 13:15
Der Mittelpunkt des Kreuzes muss demnach auf PaintBox.Width div 2, PaintBox.Height div 2 leigen.
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
andiak

Registriert seit: 1. Nov 2007
89 Beiträge
 
#3

Re: Paintbox - Koordinatenkreuz

  Alt 14. Jan 2008, 13:28
Ok PaintBox.Width div 2, PaintBox.Height div 2 und wie mit center deklarieren?
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#4

Re: Paintbox - Koordinatenkreuz

  Alt 14. Jan 2008, 13:34
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.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
Scorp

Registriert seit: 13. Jan 2008
5 Beiträge
 
#5

Re: Paintbox - Koordinatenkreuz

  Alt 14. Jan 2008, 13:44
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
  Mit Zitat antworten Zitat
Benutzerbild von Luckie
Luckie

Registriert seit: 29. Mai 2002
37.621 Beiträge
 
Delphi 2006 Professional
 
#6

Re: Paintbox - Koordinatenkreuz

  Alt 14. Jan 2008, 13:51
Und warum sagst du das nicht? Mit MSDN-Library durchsuchenSetMapMode kannst du das Koordinatensystem anpassen.
Michael
Ein Teil meines Codes würde euch verunsichern.
  Mit Zitat antworten Zitat
andiak

Registriert seit: 1. Nov 2007
89 Beiträge
 
#7

Re: Paintbox - Koordinatenkreuz

  Alt 14. Jan 2008, 13:56
ä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
  Mit Zitat antworten Zitat
Benutzerbild von Aurelius
Aurelius

Registriert seit: 29. Jan 2007
Ort: Erfurt
753 Beiträge
 
Delphi 7 Personal
 
#8

Re: Paintbox - Koordinatenkreuz

  Alt 14. Jan 2008, 13:59
Doch das hilft dir, da es dieselben funktionen/proceduren auch in Delphi gibt (kommen ja alle von Microsoft).
Jonas
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.545 Beiträge
 
Delphi 11 Alexandria
 
#9

Re: Paintbox - Koordinatenkreuz

  Alt 14. Jan 2008, 14:00
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.
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:57 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