All Manuals > CAPI User Guide and Reference Manual > 7 Programming with CAPI Windows

7.2 Resizing and positioning

Programmatic resizing can be done using the function set-top-level-interface-geometry. For example, to double the width of an interface about its center:

(setf interface (contain (make-instance 'interface)))

Use the mouse or window manager-specific gesture to resize the interface, then evaluate:

(multiple-value-bind (x y w h) 
    (top-level-interface-geometry interface)
  (execute-with-interface interface 
                          'set-top-level-interface-geometry 
                          interface 
                          :x (round (- x (* 0.5 w))) 
                          :y y 
                          :width (* 2 w) 
                          :height h))

All resize operations are subject to the constraints. The constraints can be altered programmatically as described in 6.5.3 Changing the constraints.

Resize operations are also subject to automatic modification by the system in cases where the new window geometry coincides with a system area such as the macOS menu bar or the Microsoft Windows taskbar, as described in 7.2.1 Positioning CAPI windows.

7.2.1 Positioning CAPI windows

You should not assume that a window is located where it has just been programmatically positioned. Instead you should query the current position by top-level-interface-geometry.

So if you wish to display CAPI interface windows W1 and W2 relative to each other. You should:

  1. Display W1 (by display), then:
  2. Query position of W1, then:
  3. Arrange for W2 to have the desired relative position, for example in its make-instance or later by set-hint-table, then:
  4. Display W2.

The reason for this is that the window system may disallow certain positions (for example on the macOS menu bar) therefore you cannot be certain of the position of W1.


CAPI User Guide and Reference Manual (Windows version) - 01 Dec 2021 19:33:50