Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Library: Windows API / MS.NET Framework API (https://www.delphipraxis.net/20-library-windows-api-ms-net-framework-api/)
-   -   Delphi Alle Fensterhandle finden anhand der WindowCaption (https://www.delphipraxis.net/56422-alle-fensterhandle-finden-anhand-der-windowcaption.html)

idontwantaname 5. Nov 2005 13:05


Alle Fensterhandle finden anhand der WindowCaption
 
Hallo !!

Manchmal kommt es vor, dass man Handle mehrerer Fenster braucht, die jedoch alle die selbe WindowCaption haben.
Hierzu hab ich folgende Funktion mit der Hilfe von neolithos (der Thread) geschrieben

Delphi-Quellcode:
type THandleArray = array of HWND;

function FindAllWindows(const WindowCaption: String): THandleArray;
type
  PParam = ^TParam;
  TParam = record
    WindowCaption: String;
    Res: THandleArray;
  end;
var
  Rec: TParam;
  function _EnumProc(_hWnd: HWND; _LParam: LPARAM): LongBool; stdcall;
  var
    cTitle: array[0..1023] of Char;
  begin
    with PParam(_LParam)^ do
    begin
      GetWindowText(_hWnd, cTitle, SizeOf(cTitle));
      if (CompareText(cTitle, WindowCaption) = 0) then
      begin
        SetLength(Res, Length(Res)+1);
        Res[Length(Res)-1] := _hWnd;
      end;
      Result := True;
    end;
  end;
begin
  Rec.WindowCaption := WindowCaption;
  SetLength(Rec.Res, 0);
  EnumWindows(@_EnumProc, Integer(@Rec));
  Result := Rec.Res;
end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:19 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz