On Thu, 22 Dec 2005 18:47:39 +0100, Edi Weitz edi@agharta.de wrote:
My guess is that this doesn't work because of threading issues - .NET is trying to call into Lisp from a thread which wasn't created by Lisp.
And I was right. Here's a solution that avoids these problems and works for me. Files are at the end of this message.
1. Build a DLL (they don't have the threading problems I mentioned - see link in my earlier email) using LispWorks as usual, something like (from a console window):
"\Program Files\LispWorks\lispworks-4460.exe" -init deliver.lisp
2. Make sure RDNZL.dll can be found - put it into c:\Windows\System32 for example.
3. Start the DLL as a program:
rundll32 demo.dll,demo
You should now see a window on which you can "draw" using the mouse. After every fifth stroke a message should come up telling you how many strokes the app has counted so far.
If you don't have a LispWorks license to deliver executables you can download the DLL to play with from
http://nanook.agharta.de/InkDemo.zip
and start with #2 above.
I don't know how to do that with AllegroCL but I guess Franz' support will help you. If they come up with a solution it'd be nice if you could post it here.
Cheers, Edi.
-------------------- deliver.lisp --------------------
(load-all-patches)
;; modify to match the location of RDNZL on your PC (load "/home/lisp/RDNZL/load.lisp")
(use-package :rdnzl)
(load (compile-file "tablet.lisp"))
(shutdown-rdnzl)
(deliver 'init "demo" 1 :dll-exports '("demo"))
(quit)
-------------------- tablet.lisp --------------------
(enable-rdnzl-syntax)
(import-types "Microsoft.Ink" "InkOverlay" "InkCollectorStrokeEventHandler") (import-types "System.Windows.Forms" "Form" "Application" "MessageBox") (import-type "System.EventHandler") (use-namespace "Microsoft.Ink") (use-namespace "System.Windows.Forms") (use-namespace "System")
(defparameter *stroke-counter* 0)
(defun handle-stroke (object event) (declare (ignore object event)) (when (zerop (mod (incf *stroke-counter*) 5)) [MessageBox.Show (format nil "~A strokes so far..." *stroke-counter*)]))
(defun demo () (let ((window (new "Form")) (ink-overlay)) (flet ((on-load (object event) (declare (ignore object event)) (setf ink-overlay (new "InkOverlay" [%Handle window]) [%Enabled ink-overlay] t) [+Stroke ink-overlay (new "InkCollectorStrokeEventHandler" #'handle-stroke)])) [+Load window (new "EventHandler" #'on-load)] [Application.Run window])))
(disable-rdnzl-syntax)
(fli:define-foreign-callable ("demo" :calling-convention :stdcall) ((hwnd w:hwnd) (hinst w:hinstance) (string :pointer) (cmd-show :int)) (declare (ignore hwnd hinst string cmd-show)) (demo))
(defun init () (init-rdnzl))