我想根据下面的示例 A 添加一个列表框。 Common Lisp Cookbook - 使用 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))))