Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Mausposition und Gitternetz

Empfohlene Antworten

Veröffentlicht

Hallo Delphianer,

Was für echte Programmierer :

Ich habe ein riesen Problem:

Ich habe eine TPaintBox in der ich rechteckige Quadrate als Netz zeichne

Dimension: 25x25 Pixel in der Ausdehnung

25 Felder in X und

15 Felder in Y Richtung

Der Rahmen hat 1 Pixel

Die PaintBox hat also eine Dimension von 625x375 Pixeln unterteilt in 375 Feldern

(Änlich einem Array)

Wie ist es aber nun möglich zu Sagen, wenn ich auf Koordinate XY stehe, das ist

Feld 1x2 oder Feld 2x3 ?

Danke für Codebeispiele und Hilfe im Vorraus

Paul

Probier es mal, indem du den jeweiligen Wert, also X-Wert bzw. Y-Wert durch 25 teilst, das Ergebnis (ganzzahlig) ist dann die Position in Quadraten, beginnend bei Quadrat 0. Also 25 Quadrate links nach rechts 0 - 24. Dasselbe für die Y-Richtung...

Codebeispiel erübrigt sich, denk ich ;)

nur mal so am rande.. hast schon mal nicht rechteckige quadrate gesehen?? *ggg*

gruß Taz

Hallo leutchen,

kleiner schreibselfehler :-)

naja Spass muss sein sprach Wallenstein .... :-)

ging ganz easy, hier wem interessiert der Code:


procedure TInitForm2.PaintBox1MouseMove(Sender: TObject;

  Shift: TShiftState; X, Y: Integer);

var

ax,ay, bx,by, cx,cy, xpos: Integer;

begin

  bx := 0;

  by := 0;

  for ax := 0 to 25 do

  begin

    inc(bx,25);

    if (X >= bx-25) and (X <= bx) then

    begin

      cx := bx div 25;

      for ay := 0 to 15 do

      begin

        inc(by,25);

        if (Y >= by-25) and (Y <= by) then

        begin

          cy := by div 25;

          Label5.Caption := 'Feld ' + IntToStr(cx) + ' x ' + IntToStr(cy);

          break;

        end;

      end;

      break;

    end

    else Label5.Caption := 'Feld X';

  end;

  Label4.Caption := 'Xpos: ' + IntToStr(X) + ',  Ypos: ' + IntToStr(Y);

end;

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.