doors icon indicating copy to clipboard operation
doors copied to clipboard

Using doors i want to create an empty window. Is it possible?

Open huseyindenli opened this issue 1 year ago • 1 comments

but i get "Unsupported system" during intsllation.

huseyindenli avatar Nov 19 '24 10:11 huseyindenli

@huseyindenli The build is fixed now. You can create a window like this:

(in-package #:cl-user)

(cffi:defcallback (wndproc :convention :stdcall)
    :pointer ((hwnd :pointer)
              (msg :uint)
              (wparam :pointer)
              (lparam :pointer))
  (cond ((= msg #x0002)                 ; WM_DESTROY
         (doors.ui:post-quit-message)
         (cffi:null-pointer))
        (t (cffi:foreign-funcall ("DefWindowProcW" :convention :stdcall
                                                   :library doors:user32)
                                 :pointer hwnd
                                 :uint msg
                                 :pointer wparam
                                 :pointer lparam
                                 :pointer))))

(defun show-window ()
  (let ((class (doors.ui:make-wndclass
                :style '(:vredraw :hredraw :dbl-clks)
                :wndproc (cffi:callback wndproc)
                :cursor (cffi:foreign-funcall ("LoadCursorW" :convention :stdcall
                                                             :library doors:user32)
                                              :pointer (cffi:null-pointer)
                                              :pointer (cffi:make-pointer #x7F00)
                                              :pointer)
                :background (1+ 5)
                :class-name "My class")))
    (doors.ui:register-class class)
    (unwind-protect
         (let ((wnd (doors.ui::create-window*
                     :style* :overlapped-window
                     :class-name "My class"
                     :window-name "Hello"
                     :style '(:overlapped-window :visible))))
           (doors.ui::show-window wnd :show)
           (loop :with msg = (doors.ui:make-msg)
                 :while (doors.ui:get-message msg)
                 :do (doors.ui:translate-message msg)
                     (doors.ui:dispatch-message msg)))
      (doors.ui:unregister-class "My class"))))

However, I haven't touched the lib for ages, and back then it was basically an experiment. You'd be better off with pure CFFI: https://gist.github.com/Lovesan/17007d7571486dd94b6c97588a545a7d

I'm planning to rewrite the library in the future, though

Lovesan avatar Nov 21 '24 03:11 Lovesan