Autor Beitrag
kachel81
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63



BeitragVerfasst: Mo 27.09.04 16:19 
Wie bekomme ich anwendungsweit heraus, welches Control sich unterm Mauszeiger befindet. Ich habs schon mit ControlAtPos() versucht, daß liefert mir aber nur das Control, das das aufrufende Control direkt zum Parent hat. Ich brauche das aber wie gesagt anwendungsweit.
kachel81 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63



BeitragVerfasst: Mi 29.09.04 13:18 
Hab was gefunden, das funktioniert. Falls einer Mal ein ähnliches Problem hat:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
function FindControlAtPos: TWinControl;
var
  Pt: TPoint;
  FormHandle: HWND;
begin
  Result := nil;
  try
    // aktuelle CursorPos ermitteln
    GetCursorPos(Pt);

    // zu welchem Fenster gehört der Punkt
    FormHandle := WindowFromPoint(Pt);
    // wurde was gefunden
    if FormHandle > 0 then
      // Control finden
      Result := FindControl(FormHandle);
  except
    Result := nil;
  end;
end;


Moderiert von user profile iconmatze: Code- durch Delphi-Tags ersetzt
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 29.09.04 13:30 
Ich habe den Source zwar nicht geprüft, aber ich wäre davon ausgegangen, dass man dafür ein Fukntion benötigt, die die Mausposition als Parameter benötigt.
Bist du sicher, dass das so funzt?
.Chef
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1112



BeitragVerfasst: Mi 29.09.04 13:59 
Ist doch dabei:
ausblenden Delphi-Quelltext
1:
WindowFromPoint(Pt)					

_________________
Die Antworten auf die 5 häufigsten Fragen:
1. Copy(), Pos(), Length() --- 2. DoubleBuffered:=True; --- 3. Application.ProcessMessages bzw. TThread --- 4. ShellExecute() --- 5. Keine Vergleiche von Real-Typen mit "="!
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6393
Erhaltene Danke: 147

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Mi 29.09.04 14:02 
Ich war mir nur nicht sicher, da ja nur das Fenster unter der Maus festgestellt wird. Welches Control dann gesucht wird, könnte auch was anderes sein. Z.B.: das ActiveControl des Fensters.
kachel81 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 63



BeitragVerfasst: Do 30.09.04 15:00 
Das funktioniert!

In meiner Anwendung habe ich einen TTreeView mit Zurück-Fkt. und einen TWebBrowser ebenfalls mit Zurück-Fkt., anhängig von der Mausposition wird dann beim Klicken auf den Maus-Zurück-Button in der "richtigen" Komponente navigiert.
NetSpider
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 123

Windows XP Pro
Delphi 7 Enterprise
BeitragVerfasst: Fr 20.07.07 08:38 
Hi,
der Quelltext funktioniert allerdings nicht bei einem TImage...
Gibts da eine Moeglichkeit?

Danke - lg, NetSpider


... P.S. Ach ja - und wie verhaelt es sich bei einem TImage -> Enabled := false?
Das ist das eigentliche Problem.

_________________
Wer in die Fußstapfen anderer tritt hinterlässt keine eigenen Spuren!
Lannes
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2352
Erhaltene Danke: 4

Win XP, 95, 3.11, IE6
D3 Prof, D4 Standard, D2005 PE, TurboDelphi, Lazarus, D2010
BeitragVerfasst: Fr 20.07.07 23:42 
Hallo,

TImage ist kein fensterorientiertes Steuerelement(TWinControl), da hilft Dir ControlAtPos weiter, denn es liefert TControl zurück.
Der Parameter AllowDisabled hilft Dir bzgl. Enabled weiter.

_________________
MfG Lannes
(Nichts ist nicht Nichts) and ('' <> nil ) and (Pointer('') = nil ) and (@('') <> nil )