Thema: Delphi Handle von Control

Einzelnen Beitrag anzeigen

Jeopardize

Registriert seit: 20. Mär 2007
Ort: Villach
65 Beiträge
 
Turbo Delphi für .NET
 
#1

Handle von Control

  Alt 4. Apr 2009, 14:25
Moin DPler ,
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:
var H1, H2: HWND;
...
H := FindWindow('MozillaUIWindowClass',nil);
(Das funktioniert noch)

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:
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;
Aufruf:
Delphi-Quellcode:
H2 := iFindControlByNumber(H1,'MozillaWindowClass',6);
  if H2 <> 0 then ShowMessage('Control gefunden');
Die MsgBox erscheint aber nie.
So funktioniert es komischerweise:
Delphi-Quellcode:
H2 := iFindControlByNumber(H1,'MozillaWindowClass',1);
  if H2 <> 0 then ShowMessage('Control gefunden');
Nun, ich will aber die 6te Instanz, nicht die erste^^
Hoffe jemand hat eine Lösung oder wenigstens eine Idee.
mfg, Jeopardize
  Mit Zitat antworten Zitat