我想根据下面的示例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))))
答案 0 :(得分:0)
我更改了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)