From: remixer on
Thanks everybody. I am able to read clipboard, based on Chris double's
code very easily. I also stumbled across a clisp implementation on this
newsgroup, which looks even cleaner. I want to be able to grab the
clipboard *when it changes* (rather than polling it all the time, which
is wasteful)

As I understand a WM_COPY message or WM_DRAWCLIPBOARD notification is
generated when the clipboard changes. How does one make a function that
does something when the clipboard change event occurs? I apologize for
the naivete and would be happy if you pointed me in the direction of
any example code fragment that shows how to respond to a windows event
notification. I would be ecstatic if it was using CLISP.

Thanks.

From: Jack Unrue on
On 23 Sep 2006 20:08:09 -0700, "remixer" <remixer1(a)gmail.com> wrote:
>
> As I understand a WM_COPY message or WM_DRAWCLIPBOARD notification is
> generated when the clipboard changes. How does one make a function that
> does something when the clipboard change event occurs? I apologize for
> the naivete and would be happy if you pointed me in the direction of
> any example code fragment that shows how to respond to a windows event
> notification. I would be ecstatic if it was using CLISP.

WM_COPY is a command message sent to a control when one wants
to copy the current selection within the control to the
clipboard. It's not a notification that your application
processes (unless you're implementing a custom control, of
course). As you mentioned, WM_DRAWCLIPBOARD is the message
you need to process.

Here is an introduction to Win32 programming with CL (including
the processing of messages) written in terms of LispWorks:

http://cl-cookbook.sourceforge.net/win32.html

Here is sample code written in terms of SBCL:

http://www.lisphacker.com/files/lisp-winapi.tgz
http://www.lisphacker.com/files/hello-win32.tgz

My library uses CFFI, and here is a pointer to the source
file where I process messages (note that my code is more
complicated than the previous samples as it attempts to
implement somewhat greater functionality):

http://common-lisp.net/websvn/filedetails.php?repname=graphic-forms&path=%2Ftrunk%2Fsrc%2Fuitoolkit%2Fwidgets%2Fevent.lisp&rev=0&sc=0

Now that you have some references for general message processing
code, you need to delve into the clipboard API to be able to
handle WM_DRAWCLIPBOARD. The following article, although written
in terms of MFC, covers lots of clipboard topics including the
handling of WM_DRAWCLIPBOARD and you might find the whole thing
apropos to what you are trying to do:

http://www.chiramattel.com/george/Default.aspx?ptabindex=1&ptabid=5

So the challenge then is to translate that info to the equivalent
Lisp code using whichever FFI you've chosen.

You will need to search around in the Win32 programming newsgroups for
more, as I don't have any Lisp-based sample code for this myself (yet).

--
Jack Unrue
http://common-lisp.net/project/graphic-forms
First  |  Prev  | 
Pages: 1 2 3
Prev: Lis(t|p) comprehensions
Next: Pocket Lisp Machine