![]() |
Cursorposition im Integerwert speichern
Ich möchte die Position des Cursors in einem Integerwert speichern.
Da hab ich an folgenden Code gedacht:
Delphi-Quellcode:
Doch da kommt dann immer die Fehlermeldung "inkompatible Typen: 'String' und 'Integer' :gruebel:
var
Position: integer; ... procedure TForm1.MausTimeTimer(Sender: TObject); var Posi: TPoint; begin Posi := Mouse.CursorPos; Position := IntToStr(StrToInt(Posi.X)); end; hat jemand vielleicht 'ne andere Idee, wie ich die Cursorposition in einem Integerwert speichern kann? |
Re: Cursorposition im Integerwert speichern
Position := Posi.X;
mfg freak |
Re: Cursorposition im Integerwert speichern
Zitat:
|
Re: Cursorposition im Integerwert speichern
Moin malo,
Posi.x ist ja bereits eine Zahl, was willst Du da konvertieren? Du müsstest nur ein wenig "schieben", damit Du beide Werte (x und y) in einer Variablen unterbringen kannst.
Delphi-Quellcode:
Hierdurch wird der horizontale Wert in den oberen 16 Bit von Position gespeichert, die vertikale in den unteren.
Position := (posi.x shl 16) or (posi.y);
|
Re: Cursorposition im Integerwert speichern
@Chris: Ich will aber halt nur den X-Wert speichern, den Y-Wert brauch ich nicht ;)
Das Problem dabei ist aber ein Post weiter oben ;) |
Re: Cursorposition im Integerwert speichern
Moin malo,
Zitat:
Nenn es doch iPosition. [EDIT] Oder besser: Pack es als Eigenschaft in das Formular
Delphi-Quellcode:
TForm1 = class(TForm)
//... private FiPosition : integer; public property MyPosition : integer read FiPosition write FiPosition; end; //... MyPosition := Posi.x; //... |
Re: Cursorposition im Integerwert speichern
Wieso denn TPosition es gibt doch nur TPoint und Integer?! :gruebel:
mfg freak |
Re: Cursorposition im Integerwert speichern
Zitat:
|
Re: Cursorposition im Integerwert speichern
Moin Christian,
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:57 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