我想在下面的示例a的基础上添加一个列表框。
The Common Lisp Cookbook - Using the Win32 API
我添加了一个函数sendmessage,它映射到它的windows API计数器部分并从wndproc调用它。
但它抱怨了如下类型转换错误。
CL-USER 1 > (create-toplevel-window "ppp")
Error: #<Pointer to type (:UNSIGNED :SHORT) = #x01E902D8> cannot be
converted to foreign type (:UNSIGNED-INTEGER-TYPE 32).
以下是与错误相关的函数有办法解决这个问题吗?
我试图用lparam将sendmessage定义为(:unsigned:short),但没有用。
(fli:define-foreign-function
(SendMessage "SendMessage" :dbcs)
((hwnd hwnd) (msg uint) (wparam ulong) (lparam (:unsigned :long)))
:result-type ulong :calling-convention :stdcall)
(fli:define-foreign-callable
(wndproc :result-type :long :calling-convention :stdcall)
((hwnd hwnd) (msg (:unsigned :long))
(wparam (:unsigned :long)) (lparam (:unsigned :long)))
(case msg
(#.WM_CREATE
(fli:with-foreign-string ;; class name pointer
(cn-p ec bc :external-format (external-format)) "LISTBOX"
(fli:with-foreign-string ;; window name pointer
(wn-p ec bc :external-format (external-format)) ""
(let ((lstbx (createwindowex hwnd cn-p wn-p
(logior ws_visible ws_child lbs_notify)
cw_usedefault cw_usedefault cw_usedefault cw_usedefault
0 0 200 100)))
(fli:with-foreign-string (msg ec bc :external-format (external-format)) "item1"
(sendmessage lstbx LB_ADDSTRING 0 msg ))))))
;;0 0 (GetModuleHandle-current 0) 0))))
;;(createwindowex "listbox4test" hwnd))
;;(#.WM_PAINT (wndproc-paint hwnd msg wparam lparam))
#+console (#.WM_DESTROY (PostQuitMessage 0) 0)
(t (DefWindowProc hwnd msg wparam lparam))))
最佳答案
我更改了sendmessage函数,如下所示。
而这一次,它没有抱怨。
(fli:define-foreign-function
(SendMessage "SendMessage" :dbcs)
((hwnd hwnd) (msg uint) (wparam ulong) (lparam :pointer)) ;;;(lparam (:unsigned :long)))
:result-type ulong :calling-convention :stdcall)
关于lisp - lispworks fli:无法转换为外来类型,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39943429/