Autor Beitrag
rizor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Mi 07.03.07 15:40 
Hi,

ich möchte eine Unit schreiben, die beim Mausklick auf ein Image die Mouspostion festlegt.
Das Problem ist, dass das rogramm in einer Art Endlosschleife ist.
Ich hatte die Idee am Ende der Schleife eine Abfrage zu machen, ob die maustaste geklickt wird.
Dann soll die Unit Image1Click geöffnet werden und der Klick soll überprüft werden.

Wie kann man da machen?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mi 07.03.07 15:47 
Du kannst die Eventproperty auf eine Methode in dieser Unit setzen.

_________________
Markus Kinzler.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Mi 07.03.07 15:54 
Wie meinst du das?
Damit kann ihc nichts anfangen.
bs-Hobbit
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46

Windows Xp (Home/Prof.), Windows Server 2003, Linux
D7,D2005
BeitragVerfasst: Mi 07.03.07 15:56 
Bin mir nicht sicher, ob ich 100% verstanden habe, was genau du machen willst, aber vllt hilft dir das hier weiter:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
// Get mouse positon

procedure TForm1.Button1Click(Sender: TObject);
var
  MausPos: TPoint;
begin
  GetCursorPos(MausPos);
  label1.Caption := IntToStr(MausPos.x);
  label2.Caption := IntToStr(MausPos.y);
end;

// Set mouse position to (x,y)

procedure TForm1.Button2Click(Sender: TObject);
begin
  SetCursorPos(600600);
end;

// Simulate a double click on a panel
// Einen Doppelklick auf einen Panel simulieren
SendMessage(Panel1.Handle, WM_LBUTTONDBLCLK, 1010)
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Mi 07.03.07 16:07 
Nee,
das meine ich nicht.
Es soll die Endlosschleife beendet werden wenn auf einen Bereich des Images geklickt wird.
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: Mi 07.03.07 16:25 
Also die Endlosschleife machst du dann mit

Repeat Until klick=True;

Die Boolsche Variable klick steht im public bereich.
Beim OnClick Ereignis des Image schreibst du rein Klick:=True;

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: Mi 07.03.07 16:33 
Funktioniert die OnClick sache?
Wenn das Programm in einer endlosschleife ist, dann reagiert es doch auf nichts.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mi 07.03.07 16:38 
Beschreib mal bitte näher, was du machen willst. Besonders diesen Satz...
user profile iconrizor hat folgendes geschrieben:
Ich hatte die Idee am Ende der Schleife eine Abfrage zu machen, ob die maustaste geklickt wird.
Dann soll die Unit Image1Click geöffnet werden und der Klick soll überprüft werden.
...verstehe ich überhaupt nicht. Wenn das Programm läuft, soll die Unit geöffnet werden und darin der Klick überprüft werden? :gruebel:

Ich würde im OnClick des Images sowas machen
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Image1Click(Sender: TObject);
begin
  TuwasTollesausUnit2;
end;
, wobei TuwasTollesausUnit2 eine Funktion ist, die in Unit2 deklariert und implementiert ist.

_________________
We are, we were and will not be.