Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 25.10.06 18:41 
Hi, Delpher,

(wie) ist es möglich, den Mauszeiger, zum Beispiel nach einer Verarbeitungsaktion, auf den Button zu setzen, der als nächstes zu betätigen ist - so dass man also nicht extra dort hingehen muss? Natürlich kann ich setfocus auf den Button machen, aber ...

Wer hat eine Idee?

Danke für Hilfe,

Detlef Annies
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: Mi 25.10.06 18:47 
mit folgenden codes sollte es klappen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
var
 P: TPoint;
begin
 P.X := Button.Width div 2;
 P.Y := Button.Height - 7;
 P := Button.ClientToScreen(P);
 SetCursorPos(P.X, P.Y);
end;
grüße,
Marc
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mi 25.10.06 19:28 
Hi, Marc,

das "Drumherum" ist mir noch nicht klar - und - für button7 muss ich button durch button7 ersetzen?

Danke, Detlef
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 29.10.06 14:49 
Hi Mark II,

so, den Prozedurrumpf habe ich jetzt einfach dazugesetzt und es geht. - Vielen Dank!

Detlef
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 29.10.06 22:26 
P.S.

ich habe noch eine Nachfrage:

wie kann ich denn den Cursor auf ein beliebiges Objekt setzen, also, auf verschiedene Buttons oder auf eine Checkbox, etc.?

Gruß, Detlef
alias5000
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2145

WinXP Prof SP2, Ubuntu 9.04
C/C++(Code::Blocks, VS.NET),A51(Keil),Object Pascal(D2005PE, Turbo Delphi Explorer) C# (VS 2008 Express)
BeitragVerfasst: So 29.10.06 22:33 
Dann musst du halt die Koordinaten dieses Objekts herausfinden. Den Point für SetCursorPos kriegst du dann etwa so:

ausblenden Delphi-Quelltext
1:
Point := Button.ClientToScreen(TPoint(Button.Top, Button.Width));					


Gruß alias5000

_________________
Programmers never die, they just GOSUB without RETURN
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 29.10.06 22:51 
Hi,

danke für deine schnelle Antwort, meine Idee war es, das Objekt im Prozedurkopf zu übergeben, und es etwa in der Form aufzurufen maussprung(checkbox3);
oder maussprung(button8);

Geht das?

Danke für weitere Hilfe, Detlef
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: So 29.10.06 23:21 
Eine Möglichkeit für alle Komponenten fällt mir jetzt nicht ein, aber für spezielle Komponententypen, wie TButton lässt sich folgendes realisieren:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.JumpTo(Sender: TObject);
var
 P: TPoint;
 MyObject: TComponent;
begin
 P.X := TButton(Sender).Width div 2;
 P.Y := TButton(Sender).Height - 7;
 P := TButton(Sender).ClientToScreen(P);
 SetCursorPos(P.X, P.Y);
end;


aufruf dann mit
ausblenden Delphi-Quelltext
1:
JumpTo(Button2);					


Grüße,
Marc
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 29.10.06 23:45 
Hi, Marc., vielen Dank,

ich habe es erstmal so realisiert, dass ich in der proc frage:

if sender = button7 then ... ;
if sender = checkbox3 then ... ;

Na, ja, geht, aber für alle Kompos wäre natürlich besser.

Nochmals vielen Dank für deine weitere Hilfe, Detlef
Marc.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1876
Erhaltene Danke: 129

Win 8.1, Xubuntu 15.10

BeitragVerfasst: So 29.10.06 23:50 
etwas umständlich, da du für jede komponente n paar zeilen hergeben müsstest, aber so ginge es auch:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
procedure TForm1.JumpTo(Sender: TObject);
var
 P: TPoint;
begin
 If (Sender Is TButton) then
  begin
     P.X := TButton(Sender).Width div 2;
     P.Y := TButton(Sender).Height - 7;
     P := TButton(Sender).ClientToScreen(P);
  end else
 If (Sender Is TCheckbox) then
  begin
     P.X := TCheckbox(Sender).Width div 2;
     P.Y := TCheckbox(Sender).Height - 7;
     P := TCheckbox(Sender).ClientToScreen(P);
  end;
   SetCursorPos(P.X, P.Y);
end;
;)
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 30.10.06 00:03 
Hi, Marc., das sieht doch gut aus, - wieder einen Schritt weiter ...

Danke, Detlef
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: Mo 30.10.06 01:29 
Hab die Procedure ein klein wenig verbessert. :wink:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
type
  TForm1 = class(TForm)
    ...
    procedure MouseJumpTo(Target: TControl);

...

procedure TForm1.MouseJumpTo(Target: TControl);
var
  P: TPoint;
begin
  P := Target.ClientToScreen(Point(Target.Width div 2, Target.Height div 2));
  SetCursorPos(P.X, P.Y);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  MouseJumpTo(Button2);
end;


Jetzt ist auch egal von welchem Typ das Ziel ist.

MfG
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: Mo 30.10.06 17:29 
Hi, Coder,

DAS BRINGT'S!

Danke, Detlef