Autor Beitrag
Danny87
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Di 24.10.06 01:27 
Hey Leute,

kann mir bitte jemand sagen, wie ich mit Hilfe des Handles eines Fensters dessen Left- und Top-Werte
auslesen kann?
So in der Art wie Form1.Left oder Form1.Top.
Das Fenster ist allerdings kein von mir erstelltes sondern kann zB ein Windowsfenster, ein Spiel o.ä. sein.
Das Fensterhandle hab ich bereits.


Gruss
Daniel
Reinhard Kern
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 591
Erhaltene Danke: 14



BeitragVerfasst: Di 24.10.06 09:20 
user profile iconDanny87 hat folgendes geschrieben:
Hey Leute,

kann mir bitte jemand sagen, wie ich mit Hilfe des Handles eines Fensters dessen Left- und Top-Werte
auslesen kann?
So in der Art wie Form1.Left oder Form1.Top.
Das Fenster ist allerdings kein von mir erstelltes sondern kann zB ein Windowsfenster, ein Spiel o.ä. sein.
Das Fensterhandle hab ich bereits.


Gruss
Daniel


Hallo,

die Win32 API Funktion GetWindowPlacement liefert alles Nötige, siehe SDK-Hilfe oder folgendes Beispielprogramm:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
  { place in doneapprun }

procedure TRKIniClass.SaveMainPosition (WH : HWnd; usewh : boolean);
var WP : TWindowPlacement;
    newvalue : integer;
begin
if WH = 0 then exit;
if not MainWindow_SavePos then exit;
WP.length := SizeOf (TWindowPlacement);
if not GetWindowPlacement (WH,@WP) then exit; { get last Position }
newvalue := WP.rcNormalPosition.left; { x }
if newvalue <> MainWindow_StartX then put_iniint(GenSection,'StartX',newvalue);
newvalue := WP.rcNormalPosition.top;
if newvalue <> MainWindow_StartY then put_iniint(GenSection,'StartY',newvalue);
if not usewh then exit;
newvalue := WP.rcNormalPosition.right - WP.rcNormalPosition.left; { w }
if newvalue <> MainWindow_StartW then put_iniint(GenSection,'StartW',newvalue);
newvalue := WP.rcNormalPosition.bottom - WP.rcNormalPosition.top; { h }
if newvalue <> MainWindow_StartH then put_iniint(GenSection,'StartH',newvalue);
end;


Gruss Reinhard
Danny87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 688

Windows 10 Pro 64bit
Sprachen: HTML, PHP, JavaScript, Delphi || IDE: RAD Studio 10.1 Berlin Starter, WeBuilder
BeitragVerfasst: Di 24.10.06 13:46 
Danke :-)
Das war genau das was ich gesucht hab :-)

Gruss
Daniel