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

7.1 Initialization

If necessary you can run code just before or just after your interface's windows are displayed on screen.

You can do this by defining a :before or :after method on the generic function interface-display. Your method will run just before or just after your interface is displayed on screen.

For example:

(defun make-text (self createdp)
  (multiple-value-bind (s m h dd mm yy)
      (decode-universal-time (get-universal-time))
    (format nil "Window ~S ~:[displayed~;created~] at ~2,'0D:~2,'0D:~2,'0D" 
            self createdp h m s)))
 
(capi:define-interface dd () () (:panes (dp capi:display-pane)))
 
(defmethod capi:interface-display :before ((self dd))
  (with-slots (dp) self
    (setf (capi:display-pane-text dp)
          (make-text self t))))
 
(capi:contain (make-instance 'dd))

Sometimes initialization code can be put in the create-callback of your interface, though adding it in suitable methods for initialize-instance or interface-display is usually better.


CAPI User Guide and Reference Manual (Macintosh version) - 01 Dec 2021 19:31:20