![]() |
Handle von Control
Moin DPler :mrgreen: ,
ich versuche gerade an das Handle von einer Control-Instanz(so wie Button1,Button2) in einer anderen Anwendung zu kommen. Zuerst hole ich das Handle vom Fenster:
Delphi-Quellcode:
(Das funktioniert noch)
var H1, H2: HWND;
... H := FindWindow('MozillaUIWindowClass',nil); Und dann versuche ich das Handle von einer Control-Instanz zu bekommen (Fenster-Klasse = MozillaUIWindowClass, Control-Klasse = MozillaWindowClass) Von der Control-Klasse will ich die 6te Instanz. Dafür habe ich diese Funktion im Swiss Delphi-Center gefunden:
Delphi-Quellcode:
Aufruf:
function FindControlByNumber(hApp: HWND; ControlClassName: string; ControlNr: Word = 1): HWND;
var i: Word; hControl: HWND; begin Result := 0; if IsWindow(hApp) then begin Dec(ControlNr); hControl := 0; for i := 0 to ControlNr do begin hControl := FindWindowEx(hApp, hControl, PChar(ControlClassName), nil); if hControl = 0 then Exit; end; end; Result := hControl; end;
Delphi-Quellcode:
Die MsgBox erscheint aber nie.
H2 := iFindControlByNumber(H1,'MozillaWindowClass',6);
if H2 <> 0 then ShowMessage('Control gefunden'); So funktioniert es komischerweise:
Delphi-Quellcode:
Nun, ich will aber die 6te Instanz, nicht die erste^^
H2 := iFindControlByNumber(H1,'MozillaWindowClass',1);
if H2 <> 0 then ShowMessage('Control gefunden'); Hoffe jemand hat eine Lösung oder wenigstens eine Idee. :) mfg, Jeopardize |
Re: Handle von Control
Hallo
Zitat:
Die Mozilla (resp. Firefox) Fenster-Hierarchie ist aber so aufgebaut:
Code:
Mein WinSpy Tool hat folgenden Code erzeugt.
MozillaUIWindowClass
MozillaWindowClass MozillaWindowClass MozillaWindowClass MozillaContentWindowClass MozillaWindowClass MozillaWindowClass
Delphi-Quellcode:
var
wndMain, wndChild: HWND; begin wndMain := FindWindow('MozillaUIWindowClass', nil); if wndMain <> 0 then begin wndChild := FindWindowEx(wndMain, 0, 'MozillaWindowClass', nil); wndChild := FindWindowEx(wndChild, 0, 'MozillaWindowClass', nil); wndChild := FindWindowEx(wndChild, 0, 'MozillaWindowClass', nil); wndChild := FindWindowEx(wndChild, 0, 'MozillaContentWindowClass', nil); wndChild := FindWindowEx(wndChild, 0, 'MozillaWindowClass', nil); wndChild := FindWindowEx(wndChild, 0, 'MozillaWindowClass', nil); if wndChild <> 0 then begin ShowMessage('Window Handle: ' + IntToStr(wndChild)); end; end; end. |
Re: Handle von Control
Danke erstmal, ganz schön kompliziert.
Das macht es recht schwer den ich hatte vor eine Funktion zu schreiben die immer das Handle des Controls zurückgibt. Aber dann muss ich das wohl anders lösen. :) EDIT: WinSpy funktioniert super, echt praktisch :mrgreen: |
Re: Handle von Control
Schon habe ich das nächste Problem: :(
Delphi-Quellcode:
Diese Funktionen liefern nicht die Position vom Control auf dem Bildschirm, sondern offensichtlich nur Abstand von der nächst-höheren Instanz weg. Gibts da ne bessere Möglichkeit?
function GetWindowLeft(Window: HWND): Integer;
var Place:TWindowPlacement; begin Place.Length:=SizeOf(TWindowPlacement); GetWindowPlacement(Window,@Place); result := Place.rcNormalPosition.Left; end; function GetWindowTop(Window: HWND): Integer; var Place:TWindowPlacement; begin Place.Length:=SizeOf(TWindowPlacement); GetWindowPlacement(Window,@Place); result := Place.rcNormalPosition.Top; end; EDIT: Habe es selbst gefunden, wenn es jemand wissen will^^:
Delphi-Quellcode:
GetWindowRect(Handle,TRect);
X := TRect.Left; Y := Trect.Top; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:36 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