Next Previous Up Top Contents Index

1 Introduction to the FLI

1.3 Using the FLI to set the cursor position

A similar Windows function,SetCursorPos, can be used to set the cursor position. TheSetCursorPos function takes twoLONGs. The following code defines an interface function to callSetCursorPos.

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

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 - 12 Oct 1998

Next Previous Up Top Contents Index

Generated with Harlequin WebMaker