![]() |
WindowFromPoint
Ich möchte einen bestimmten Bereich vom Screen zu kopieren und nutze zur Ermittlung des zu kopierenden Bereichs die unten stehende Funktion.
Vorab: Es funktioniert, aber ich habe Fragen. Wenn der Mauszeiger nicht auf ein Fenster zeigt, sondern auf einen leeren Bereich auf dem Desktop, ergibt
Delphi-Quellcode:
nicht 0.
WindowFromPoint(MP)
Mit der modifizierten Version (untere Funktion) kriege ich folgende Ergebnisse.
Code:
Mein Eindruck ist, dass
MP: 876, 498
Fenster an Mousepos Win: 65822 Win-Text: "FolderView" Win-Class: "SysListView32" Win hat Parent Parent: 65820 Parent-Text: "" Parent-Class: "SHELLDLL_DefView" Parent: 65818 Parent-Text: "Program Manager" Parent-Class: "Progman" ST: stControl WinRect=DesktopRect, Screen kopieren ST: stScreen
Delphi-Quellcode:
niemals 0 ergibt.
WindowFromPoint(MP)
Frage: Warum ist das so?
Delphi-Quellcode:
type
TSourceType=(stScreen,stWindow,stControl);
Delphi-Quellcode:
FUNCTION GetSourceRect(var ST:TSourceType):TRect;
var MP:TPoint; Win:HWND; begin GetCursorPos(MP); Win:=WindowFromPoint(MP); if Win=0 then begin // // Kein Fenster an MousePos. Screen kopieren Result:=Screen.DesktopRect; ST:=stScreen; end else begin // Fenster oder Control kopieren if GetParent(Win)<>0 then begin // Ist Control (hat Parent) ST:=stControl; end else begin // Fenster kopieren ST:=stWindow; end; GetWindowRect(Win,Result); if Result=Screen.DesktopRect then ST:=stScreen; end; end;
Delphi-Quellcode:
var List:String;
Delphi-Quellcode:
FUNCTION GetSourceRectList(var ST:TSourceType):TRect;
//------------------------------------------------------------------------------ PROCEDURE Add(const S:String); begin if List<>'' then List:=List+#13; List:=List+S; end; //------------------------------------------------------------------------------ PROCEDURE AddWin(Win:HWND; const S:String); var Buf:Array[0..256] of Char; begin Add(S+': '+IntToStr(Win)); GetWindowText(Win,Buf,255); Add(S+'-Text: "'+Buf+'"'); GetClassName(Win,Buf,255); Add(S+'-Class: "'+Buf+'"'); end; //------------------------------------------------------------------------------ PROCEDURE AddParents(Win:HWND); var Temp:HWND; begin AddWin(Win,'Parent'); Temp:=Win; repeat Win:=Temp; Temp:=GetParent(Win); if Temp<>0 then AddWin(Temp,'Parent'); until Temp=0; end; //------------------------------------------------------------------------------ var MP:TPoint; Win:HWND; begin GetCursorPos(MP); Win:=WindowFromPoint(MP); Add('MP: '+IntToStr(MP.X)+', '+IntToStr(MP.Y)); if Win=0 then begin // Kein Fenster an MousePos. Screen kopieren Add('Kein Fenster an Mousepos'); Add('ST: stScreen'); Result:=Screen.DesktopRect; ST:=stScreen; end else begin // Fenster oder Control kopieren Add('Fenster an Mousepos'); AddWin(Win,'Win'); if GetParent(Win)<>0 then begin // Ist Control (hat Parent) Add('Win hat Parent'); AddParents(GetParent(Win)); Add('ST: stControl'); ST:=stControl; end else begin // Fenster kopieren Add('Win hat kein Parent'); Add('ST: stWindow'); ST:=stWindow; end; GetWindowRect(Win,Result); if Result=Screen.DesktopRect then begin Add('WinRect=DesktopRect, Screen kopieren'); Add('ST: stScreen'); ST:=stScreen; end; end; end; |
AW: WindowFromPoint
Ich würde annehmen, dass Windowfrompoint Dir das DesktopWindow zurückliefert, wenn sonst kein anderes Fenster vorhanden ist (sollte also = GetDesktopwindow) sein.
|
AW: WindowFromPoint
Genau, in Windows ist (fast) alles ein Fenster (selbst ein kleines Edit).
Und der Desktop ist nunmal standardmäßig eine ListView der ersten Instanz einer Explorer.exe. Ausnahme diese wurde beended, nicht gestartet (KioskModus), oder ist abgestürzt. :stupid: |
AW: WindowFromPoint
Hi,
If you want to make it fail, then you need a Windows without the Explorer, so either try to kill/disable it, or try on Windows Server Core (without GUI) ![]() I love (re)installing these after renting a dedicated server, just removing the GUI and Shell, but it seems Microsoft did removed this feature recently so you can't uninstall/install the GUI any more, shame ! Server 2008/2012 does support this feature unless they ruined it by some update, Server 2016/2019 not sure, the recent ones sure not have the ability to install/uninstall the GUI. |
AW: WindowFromPoint
Zitat:
aber nein, es ist nicht das DeskTopWindow. Hab mal das DeskTopWindow der Liste hinzugefügt, mit
Delphi-Quellcode:
Noch ein (für mich) Mysterium:
AddWin(GetDesktopWindow,'Desktop');
Das DeskTopWindow hat die Caption "Logitech Gaming Software".
Code:
MP: 1303, 525
Desktop: 65552 Desktop-Text: "Logitech Gaming Software" Desktop-Class: "#32769" Fenster an Mousepos Win: 65822 Win-Text: "FolderView" Win-Class: "SysListView32" Win hat Parent Parent: 65820 Parent-Text: "" Parent-Class: "SHELLDLL_DefView" Parent: 65818 Parent-Text: "Program Manager" Parent-Class: "Progman" ST: stControl WinRect=DesktopRect, Screen kopieren ST: stScreen |
AW: WindowFromPoint
Zitat:
aber nein, es ist nicht das DesktopWindow. |
AW: WindowFromPoint
Zitat:
Das da klingt aber verdächtig nach dem Desktop und der Explorer.exe Zitat:
|
AW: WindowFromPoint
Zitat:
Seems i have to live with the situation (don't want to change the system). |
AW: WindowFromPoint
Zitat:
"Dann hat sich bei dir eben bösartig ein Hook deines Maustreibers dort reingehackt." Ja, so scheint es zu sein. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 17:24 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