Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Fensterposition auslesen und setzen! (https://www.delphipraxis.net/123885-fensterposition-auslesen-und-setzen.html)

The Riddler 10. Nov 2008 20:23


Fensterposition auslesen und setzen!
 
Und weiter geht es: Ich möchte gern die Position eines fremden Fensters auslesen und setzen.

Das Auslesen klappt wunderbar. Ich lese mit diesem Code alle Positionen der aktiven Fenster aus (kommen in ne StringList):
Delphi-Quellcode:
var
  p: TWindowPlacement;

    p.Length:=SizeOf(TWindowPlacement);
    GetWindowPlacement(wHandle, @p); //Positionen auslesen und nachfolgend in StringLists speichern
    CasinoWindows.Add(IntToStr(wHandle));
    CasinoLeft.Add(IntToStr(p.rcNormalPosition.Left));
    CasinoTop.Add(IntToStr(p.rcNormalPosition.Top));
    CasinoRight.Add(IntToStr(p.rcNormalPosition.Right));
    CasinoBottom.Add(IntToStr(p.rcNormalPosition.Bottom));
Das Setzen der Position funktioniert leider nicht, die Fenster bleiben auf ihrer alten Position. Fehlermeldung kommt allerdings auch keine. Im konkreten Beispiel möchte ich Fenster1 an die Position von Fenster2 schieben:
Delphi-Quellcode:
var
  p: TWindowPlacement;
  hhd: HWND;
begin
  hhd := StrToInt(CasinoWindows[0]);
  p.rcNormalPosition.Left := StrToInt(CasinoLeft[1]);
  p.rcNormalPosition.Top := StrToInt(CasinoTop[1]);
  p.rcNormalPosition.Right := StrToInt(CasinoRight[1]);
  p.rcNormalPosition.Bottom := StrToInt(CasinoBottom[1]);
  SetWindowPlacement(hhd, @p);
Kann mir bitte jemand helfen? Thx

Die Muhkuh 10. Nov 2008 20:30

Re: Fensterposition auslesen und setzen!
 
Probier mal so:

Delphi-Quellcode:
var
  p: TWindowPlacement;
  hhd: HWND;
begin
  hhd := StrToInt(CasinoWindows[0]);
  p.length := SizeOf(TWindowPlacement);
  p.rcNormalPosition.Left := StrToInt(CasinoLeft[1]);
  p.rcNormalPosition.Top := StrToInt(CasinoTop[1]);
  p.rcNormalPosition.Right := StrToInt(CasinoRight[1]);
  p.rcNormalPosition.Bottom := StrToInt(CasinoBottom[1]);
  SetWindowPlacement(hhd, @p);

The Riddler 10. Nov 2008 20:38

Re: Fensterposition auslesen und setzen!
 
Danke, dass hat in der Tat gefehlt. :oops:

Aber ich denke mit
Delphi-Quellcode:
SetWindowPos(hhd, 0, StrToInt(CasinoLeft[1]), StrToInt(CasinoTop[1]), 0, 0, SWP_NOSIZE or SWP_NOZORDER);
is es eh eleganter.


Alle Zeitangaben in WEZ +1. Es ist jetzt 12:19 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz