Moving subforms

Summary

Placing subforms on a masterform seems pretty simple. Drag the form from the explorer onto the masterform. Done! Well, this could be enhanced. Be prepared or do it yourself.

Eine Subform auf einem anderen Formular zu platzieren erscheint einfach. Aus der Formular-Liste des Explorer auf die Zielform ziehen und loslassen. Fertig! Tatsächlich läßt sich das verbessern. Arbeiten Sie vor oder machen Sie es selbst.


Bevor es Sinn macht den Befehl aus dem Popup-Menü des Subform-Objektes anzuwenden, gilt es das Formular vorzubereiten.

Dazu wählen Sie ganz unten aus dem gleichen Popup-Menü den Befehl Formular bearbeiten. Das spart Extra-Wege.

Vorarbeiten

Jetzt sind Sie im Formular, das Sie als Subform verwenden wollen. Ich mache die Formulargröße abhängig von einem unsichtbaren Rechteck in der rechten unteren Ecke. Das ist das Maß für die Breite. Die Höhe wird hier leider nicht abgefragt, die kommt aus der Markierungslinie für den Datenteil. Den Kopfteil setze ich auf 0.

automatic sizing: width and height

Ich interpretiere die unterschiedliche Vorgehensweise als ein Relikt aus der Zeit, als Subforms noch Listenforms waren. Heute ist das nicht mehr logisch.

Diese Vorgehensweise klappt, wenn im Ziel-Formular die passende Größe für die Instanz der Subform vorgesehen ist. Doch ist das selten bis nie der Fall. Darum

Selber machen

Ich arbeite mit zwei unsichtbaren Rechtecken auf dem Master-Formular. Das eine hat den Objektnamen Payload und liegt im sichtbaren Bereich des Formulars. Payload hat die Eigenschaften zu wachsen oder sich zu bewegen, wie es an der Position notwendig ist.

Das zweite hat den Objektnamen Parking und liegt außerhalb des Formulars. Das Rechteck Parking bewegt sich so, daß es immer außerhalb des Formulars bleibt.

Die Subform lege ich ebenfalls außerhalb des sichtbaren Bereiches des Formulares an. Sie bekommt einen beschreibenden Objektnamen wie sf_Buchen. Dazu die Wachsen- und Bewege-Eigenschaften wie Payload.

Je nach Situation gebe ich der Subform sf_Buchen die Koordinaten von Payload oder Parking mit dem Befehl OBJECT SET COORDINATES. Ist Payload das Ziel, wird OBJECT SET VISIBLE auf True gesetzt und beim Ziel Parking auf False.

sf_Buchen move to Payload or move to Parking

Sobald ich das selber mache, kapsele ich die Funktionalität in meine Methode, hier Object_Move_To („Show“;$payload;$sf_Buchen) bzw. Object_Move_To („Hide“;$parking;$sf_Buchen). Mehr dazu in More to show.



Before using the context-menu command to automatically size a subform prepare the form-properties.

Select Edit form from the same context-menu, that saves mousing miles.

Prepare

This is the form which I’m going to use as subform. I set the form-size to be depend on a small invisible rectangle I placed at the lower right corner. That size determines the width of the subform. That rectangle doesn’t determine the height. You need to set the markerline for detail-area instead. I also set header-area to 0.

automatic sizing: width and height

This illogicalness is probably a relict of the times, when there were only list-subforms.

Working this way is ok as long as the subform has the proper proportions for the masterform, which is seldom or never the case. Which brings us to

Do it yourself

I use two invisible rects on the master-form. One is named Payload and is placed inside the visible area of the form. Payload grows or moves as is appropriate at this position.

The second one is named Parking and is placed outside the visible area of the form. The rect Parking moves to always stay in the outside-region.

The subform is placed outside the visible area of the form, too. I name it appropriate to the function it serves like sf_Buchen. Growing and moving properties same as Payload.

Depending on situation the subform sf_Buchen gets the coordinates of Payload or Parking using the command OBJECT SET COORDINATES. Is Payload the target, OBJECT SET VISIBLE is set to True, False for target Parking.

sf_Buchen move to Payload or move to Parking

When doing things myself I build a functionality like Object_Move_To („Show“;$payload;$sf_Buchen) or Object_Move_To („Hide“;$parking;$sf_Buchen). Different usage of the functionality : More to show.