LispWorks Foreign Language Interface User Guide and Reference Manual > 1 Introduction to the FLI

NextPrevUpTopContentsIndex

1.3 Using the FLI to set the cursor position

A similar Windows function, SetCursorPos , can be used to set the cursor position. The SetCursorPos function takes two LONG s. The following code defines an interface function to call SetCursorPos .

(fli:define-foreign-function (set-cursor-position "SetCursorPos")
    ((x :long)
     (y :long))
  :result-type :boolean)

For example, the cursor position can now be set to be near the top left corner by simply using the following command:

(set-cursor-position 20 20)

For a more extravagant example, define and execute the following function:

(defun test-cursor ()
  (dotimes (x 10)
    (dotimes (d 300) 
      (let ((r (/ (+ d (* 300 x)) 10.0)))
           (set-cursor-position
              (+ 300 (floor (* r (cos (/ (* d pi) 150.0)))))
              (+ 300 (floor (* r (sin (/ (* d pi) 150.0)))))
           )))))
(test-cursor)
LispWorks Foreign Language Interface User Guide and Reference Manual - 21 Dec 2009

NextPrevUpTopContentsIndex