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/)
-   -   Prism [D8] WinForms: Location setzen im Constructor wirkt nicht? (https://www.delphipraxis.net/27571-%5Bd8%5D-winforms-location-setzen-im-constructor-wirkt-nicht.html)

Phoenix 12. Aug 2004 11:10


[D8] WinForms: Location setzen im Constructor wirkt nicht?
 
Hallöchen: Ich habe ein Problem bei Delphi 8 mit Winforms. Ich will ein Formular erzeugen, das sich - wenn man mehrere Monitore besitzt - über alle Monitore ausdehnt (soll ein Screensaver werden).

Nun gehe ich beim Erzeugen des Forms her und mache dies:

Delphi-Quellcode:
   { Step through all screens and add width / height to the main form, and
   reposition the main form to start at the upper left point of all screens and
   to stop at the lower right point of all screens }
   for i := 0 to ( Length(Screen.AllScreens) - 1) do
   begin
      // match the Bounds of all Screens in our internal array one by one:
      m_screens[i] := Screen.AllScreens[i].Bounds;

      // now calculate the offsets of the other screens to create
      // a single, big form that spans all monitors, do this for all
      // screens except the main screen - we used that for initialization:
      if m_screens[i] <> m_screen then
      begin

         // make display screen bigger:
         m_screen.Height := m_screen.Height + m_screens[i].Height;
         m_screen.Width := m_screen.Width + m_screens[i].Width;

         // Eventually need to move display screen:

         // X axis only
         // if current screen is on the left of our main screen:
         // move display area to the left edge
         if m_screens[i].Left < m_screen.Left then
            m_screen.X := m_screens[i].Left;

         // Y axis only
         // if current screen is above our main screen:
         // move display area to the upper edge
         if m_screens[i].Top < m_screen.Top then
            m_screen.Y := m_screens[i].Top;

      end;
   end;

        // position so setzen, das Form richtig positioniert werden müsste:
   bounds := m_screen;
        // das da oben scheint nicht zu wirken, also explizit:
   Location.X := m_screen.X;
   Location.Y := m_screen.Y;
Dies mache ich alles noch im Constructor nach InitializeComponent.

Die einzelnen Schritte funktionieren, das Form erhält die korrekte Größe und nachher gehe ich noch her, und erzeuge Panels in den sichtbaren Bereichen, die auch innerhalb des Forms korrekt positioniert und gezeichnet werden (und genau die Monitore abdecken).

Das einzige Problem ist, das das Formular nicht an Location.X und Location.Y angezeigt wird (ein Showmessage verrät mir jedoch, das die Werte am ende der Methode auf den korrekten (in meinem Tesfall negativen) Wetren stehen) sondern immer an 0,0. Das ist blöd, wenn einer der Monitore der nicht gerade PrimaryScreen ist, links bzw. oberhalb (oder beides) des Hauptmonitors beginnt.

Wie kann ich also das Form im Constructor so beeinflussen, das es an gesetzten, ggf. auch negativen Koordianten angezeigt wird?

Phoenix 12. Aug 2004 14:02

Re: [D8] WinForms: Location setzen im Constructor wirkt nich
 
:wall: Man sollte vielleicht auch versuchen, etwas weiter zu denken:

Delphi-Quellcode:
self.StartPosition := FormStartPosition.Manual;


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