Autor Beitrag
Delphi~Anfänger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Do 03.06.04 17:42 
Ich möchte gern die aktuelle Cursur Position ermitteln den Code hab ich schon gemacht aber wie kann man ständig aktualisieren (das wie bei Zeichenprogrammen die ganze Zeit [wenn man den cursur bewegt] aktualisiert wird).
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);
var
  CursorPos: TPoint;
begin
  GetCursorPos(CursorPos);
  Caption := Format('The cursor is at (%d, %d)', [CursorPos.X, CursorPos.Y]);
end;
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 03.06.04 17:46 
Hallo!

Packe das Ganze ins OnMouseMove-Event der Form.

MfG
Peter

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Delphi~Anfänger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Do 03.06.04 17:52 
Häh wie meinste das (irgend wie funktioniert das nicht der dagt immer das es ein ungültiger bezeichner ist !!!)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 03.06.04 17:58 
Bei dem Fehlerbericht müsste ich mir von Luckie erst einmal die Kristallkugel leihen ... ;-)

Aber so sieht das dann bei mir aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var
  CursorPos: TPoint;
begin
  GetCursorPos(CursorPos);
  Caption := Format('The cursor is at (%d, %d)', [CursorPos.X, CursorPos.Y);
end;

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Delphi~Anfänger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Do 03.06.04 18:04 
Jaja aber das is echt seltsam könntest du bitte den ganzen Quelltext posten

(ich weiß das meine Fehlerangabe nicht gut ist aber das funktioniert einfach nicht)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 03.06.04 18:06 
Das ist der ganze Quelltext. :-)

Ich habe ein neues Projekt aufgemacht, habe im Objektinspektor doppelt auf das OnMouseMove-Ereignis der Form geklickt und in der dann erscheinenden Prozedur (jene, die sich da oben räkelt) den Code eingetragen. Feddisch. :-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.06.04 18:35 
Das ist der ganze Quelltext? Und er funktioniert? Dann ist dein Delphi kaputt. ;)
Die schließende eckige Klammer von "Format" fehlt.
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 03.06.04 18:41 
Du Korinthenkacker! ;-)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Delphi~Anfänger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Do 03.06.04 18:50 
Fehler :
'produce TForm1.FormMouseMove(Sender:TObjekt;Shift:TShiftST'ist kein gültiger Bezeichner
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 03.06.04 18:54 
Hast Du die Prozedur so erstellt, wie ich es oben gesagt habe? Mit Doppelklick auf das entsprechende Ereignis im Objektinspektor? Wenn nicht, dann vervollständige mal den interface-Teil Deiner Form.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Delphi~Anfänger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Do 03.06.04 18:58 
er sagt in zeile " Caption := Format('The cursor is at (%d, %d)', [CursorPos.X, CursorPos.Y); " ')' erwartet aber ';' gefunden !
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Do 03.06.04 18:59 
Das ist das, was Mathias oben geschrieben hat. (Und außerdem solltest Du die Zeile aus Deinem Code kennen ... :roll:)

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Delphi~Anfänger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 97



BeitragVerfasst: Do 03.06.04 19:01 
Oh ja stimmt danke :D
einfach112
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

xp
del7
BeitragVerfasst: So 29.08.04 14:29 
Titel: und wie wenn....
Hallo ! habe ein kleines Problem ! will nicht wissen wo der Cursor gerade auf der form ist sondern möchte gerne wissen wo er sich überhaupt befindet also global aufm desktop z.b. und mir dann diese werte in eine Variabele speichern !

leider wird mir nur angezeigt wo der cursor auf der form ist !
hilfe auch gerne über icq :
174086312
thx cu
einfach112

_________________
sorry bin noob !
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: So 29.08.04 14:34 
GetCursorPos und Timer

mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
einfach112
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 168

xp
del7
BeitragVerfasst: So 29.08.04 15:13 
Titel: ....
....
jo funtzt wunderbar ! thx !
für den fall das einer den quelltext haben will :

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Timer1: TTimer;
    Label2: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
var
  CursorPos: TPoint;
  var1: string ;
begin
  GetCursorPos(CursorPos);
  label1.Caption := Format('(%d, %d)', [CursorPos.X, CursorPos.Y]);
 var1 := label1.caption;

end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  cursorPos: Tpoint;
  var2: string;
begin
timer1.Enabled := false;
GetCursorPos(CursorPos);
  label2.Caption := Format('(%d, %d)', [CursorPos.X, CursorPos.Y]);
end;

end.


Moderiert von user profile iconMotzi: Code- durch Delphi-Tags ersetzt.

_________________
sorry bin noob !