AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Win32/Win64 API (native code) Delphi Fenster suchen (Grösse bekannt!)
Thema durchsuchen
Ansicht
Themen-Optionen

Fenster suchen (Grösse bekannt!)

Ein Thema von Clemens L. · begonnen am 10. Feb 2009 · letzter Beitrag vom 11. Feb 2009
 
Benutzerbild von stoxx
stoxx

Registriert seit: 13. Aug 2003
1.111 Beiträge
 
#3

Re: Fenster suchen (Grösse bekannt!)

  Alt 11. Feb 2009, 17:06
Hab Dir mal meinen Code gesucht ...

den kann man auch so aufrufen

hWindow := FindWindowPartStr('Delphi-Praxis;Delphi-Forum', 'IEFrame');
Delphi-Quellcode:
function GetStringNr(const NR : integer; const Value : AnsiString; const delim : char = ';'): Ansistring;
var i, idx : integer;
    iOrd : byte;
    Res : AnsiString;
    Used : Integer;
begin
  Result := '';
  idx := 1;
  Used := 0;
  SetLength(Res, Length(Value));

  for i := 1 to length(Value) do
  begin
    if Value[i] = delim then
       begin
          inc(IDX);
          continue;
       end;
    If IDX > NR then break;
    if IDX = NR then
     begin
      inc(Used);
      Res[used] := Value[i];
     end;
  end; // von for
   SetLength(Res, Used);
   result := res;
end; // von GetStringNRh

//==============================================================================

type
  PFindWindowStruct = ^TFindWindowStruct;
  TFindWindowStruct = record
    CaptionPartCount : Integer;
    CaptionParts: string;
    ClassName: String;
    WindowHandle: THandle;
end;
//==============================================================================
function EnumWindowsProc(hWindow: hWnd; lParam: LongInt): boolean; stdcall;
var lpBuffer: PChar;
    WindowCaptionFound: boolean;
    ClassNameFound: boolean;
    i : Integer;
    s : String;
begin
  GetMem(lpBuffer, 255);
  result:=true;
  WindowCaptionFound:=false;
  ClassNameFound:=false;
  try
    if GetWindowText(hWindow, lpBuffer,255)>0 then begin

        WindowCaptionFound := true;
        for i := 1 to PFindWindowStruct(lParam).CaptionPartCount do begin
            s := GetStringNr(i,PFindWindowStruct(lParam).CaptionParts);
            if Pos(s, StrPas(lpBuffer) )= 0
               then WindowCaptionFound:= false;
        end; // for i (PFind)
    end;

    if PFindWindowStruct(lParam).ClassName='then
      ClassNameFound:=true
      else if GetClassName(hWindow, lpBuffer, 255)>0 then
        if Pos(PFindWindowStruct(lParam).ClassName, StrPas(lpBuffer))>0
        then ClassNameFound:=true;

    if (WindowCaptionFound and ClassNameFound) then begin
      PFindWindowStruct(lParam).WindowHandle:=hWindow;
      result:=false;
    end;
  finally
    FreeMem(lpBuffer, sizeof(lpBuffer^));
  end;
end;
//==============================================================================
function FindWindowPartStr(const aCaptionParts: string; const aWinClassName: string = ''): THandle;
var WindowInfo: TFindWindowStruct;
begin
  with WindowInfo do begin

        if aCaptionParts = 'then
          CaptionPartCount := 0 else
              CaptionPartCount := StrCharCount(aCaptionParts,';') + 1;

        CaptionParts := aCaptionParts;
        className := aWinClassName;
        WindowHandle := 0;
        EnumWindows(@EnumWindowsProc, LongInt(@WindowInfo));
        result := WindowHandle;
  end;
end;
Phantasie ist etwas, was sich manche Leute gar nicht vorstellen können.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:22 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