Einzelnen Beitrag anzeigen

Benutzerbild von MuTzE
MuTzE

Registriert seit: 24. Sep 2003
59 Beiträge
 
#7

Re: Fensterposition/-größe einer fremden Anwendung

  Alt 20. Okt 2006, 15:41
Hm wenn ich es so mache gehts bei mir auch. Komisch.


Ich habe diesen Code benutzt um an das Handle des Fensters zu kommen:


Delphi-Quellcode:
function EnumWindowsProc(hWindow: hWnd; lParam: LongInt): boolean; stdcall;
var lpBuffer: PChar;
    WindowCaptionFound: boolean;
    ClassNameFound: boolean;
begin
  GetMem(lpBuffer, 255);
  result:=true;
  WindowCaptionFound:=false;
  ClassNameFound:=false;
  try
    if GetWindowText(hWindow, lpBuffer,255)>0 then
      if Pos(PFindWindowStruct(lParam).Caption, StrPas(lpBuffer))>0
      then WindowCaptionFound:=true;
    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 FindAWindow(WinCaption: string; WinClassName: string): THandle;
var WindowInfo: TFindWindowStruct;
begin
  with WindowInfo do begin
    caption := WinCaption;
    className := WinClassName;
    WindowHandle := 0;
    EnumWindows(@EnumWindowsProc, LongInt(@WindowInfo));
    result := WindowHandle;
  end;
end;

Und damit gehts irgendwie net.

Hat jemand ne andere Lösung um an das Fensterhandle zu kommen?
A8N32-SLI Deluxe | AMD 64 X2 3800+ @ 2700 MHz | Corsair TWINX1024-3200XL @ 270 MHz | ASUS EN7800GTX @ 490/1300 | Samsung SP2504C | Plextor PX-712SA | Logitech UltraX Media Keyboard | Razer Copperhead Chaos Green | Razer eXactMat | Sennheiser PC150
  Mit Zitat antworten Zitat