Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   GUI-Design mit VCL / FireMonkey / Common Controls (https://www.delphipraxis.net/18-gui-design-mit-vcl-firemonkey-common-controls/)
-   -   Delphi Probleme mit Findwindow in dll? Result = 0? (https://www.delphipraxis.net/122159-probleme-mit-findwindow-dll-result-%3D-0-a.html)

SimStar001 10. Okt 2008 12:55


Probleme mit Findwindow in dll? Result = 0?
 
Hallo, ich führe folgenden code in einer dll aus:

Delphi-Quellcode:
Function Find_IvAc_WindowHandle : HWND;
Var
  NextHandle: HWND;
  WinTitle, WinClass: Array[0..255] of Char;
  Const ClassName = 'Afx:00400000:0';
        WindowTitle = 'IvAc';
begin
  Result := 0;
  NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST);
  while NextHandle > 0 do
  begin
   
    GetWindowText(NextHandle, WinTitle, SizeOf(WinTitle));
    GetClassName(NextHandle, WinClass, SizeOf(WinClass));
    if (Copy(WinTitle, 1, Length(WindowTitle)) = WindowTitle) and
    (Copy(WinClass, 1, Length(ClassName)) = ClassName) then
    begin
      Result := NextHandle;
      Break;
    end
    else
      NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
  end;
end;

es wird aber kein Handle gefunden, es wird immer 0 zurpckgegeben!?

Muss ich wenn ich diesen code in einer dll ausführe etwas anders machen!?

DeddyH 10. Okt 2008 13:06

Re: Probleme mit Findwindow in dll? Result = 0?
 
Ich denke, es liegt an Application.Handle. Das dürfte sich zwischen Applikation und DLL unterscheiden, wenn ich das noch richtig in Erinnerung habe.

SimStar001 10. Okt 2008 13:08

Re: Probleme mit Findwindow in dll? Result = 0?
 
Ok und was muss ich dann dafür in der dll schreiben?

DeddyH 10. Okt 2008 13:10

Re: Probleme mit Findwindow in dll? Result = 0?
 
Übergib das Handle doch einfach an die Funktion.

toms 10. Okt 2008 13:37

Re: Probleme mit Findwindow in dll? Result = 0?
 
Delphi-Quellcode:
GetWindow(GetActiveWindow, GW_HWNDFIRST);

SimStar001 10. Okt 2008 15:10

Re: Probleme mit Findwindow in dll? Result = 0?
 
danke klappt!


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:11 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