Subject: [clisp-list] Creating windows

From: André Vargas Abs da Cruz <[email-masked]>
Date: Thu Oct 16 10:57:31 2003

Hello,

	I am new to CLISP but i am enjoying a lot developing software
with it. I have a question which probably has been already asked: i am
using clisp on a Windows XP box and i am trying to use the FFI package
to call some Win32 API functions in order to open a window to draw some
results. I have already been successful in calling some of those
functions but i am having trouble with two things:

	- First: is there any way i can retrieve a instance handle for
the clisp application i am running ? Some Win32 api functions require me
to pass an instance handle in order to successfully execute it.

	- Second: i need to define a callback function in lisp that will
be called from the win32 api. In other words, i am trying to define a
function "A" in lisp which is going to be passed to a win32 api function
"B". The api will then eventually call the function "A" defined in my
lisp code. Is it possible to do it in CLISP ?

	Thanks !!!

	Regards
	André Vargas

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.525 / Virus Database: 322 - Release Date: 9/10/2003

---

From: Sam Steingold <[email-masked]>
Date: Thu Oct 16 11:47:02 2003

> * André Vargas Abs da Cruz <[email-masked]> [2003-10-16 14:57:02 -0300]:
>
> - First: is there any way i can retrieve a instance handle for the
> clisp application i am running ? Some Win32 api functions require me

what is an "instance handle"?
is there a win32 api function that returns it?

> - Second: i need to define a callback function in lisp that will be
> called from the win32 api. In other words, i am trying to define a
> function "A" in lisp which is going to be passed to a win32 api
> function "B". The api will then eventually call the function "A"
> defined in my lisp code. Is it possible to do it in CLISP ?

<http://clisp.cons.org/impnotes/dffi.html#def-call-in>
<http://clisp.cons.org/impnotes/dffi.html#ex-call-in>

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
I want Tamagochi! -- What for?  Your pet hamster is still alive!

---

From: Sam Steingold <[email-masked]>
Date: Thu Oct 16 12:14:20 2003

> to pass an instance handle in order to successfully execute it.

(use-package "FFI")

(defconstant MAX_PATH 1024)

(def-call-out get-module-file-name (:library "kernel32.dll")
  (:name "GetModuleFileNameA")
  (:arguments (application-instance-handle c-pointer)
              (name (c-ptr (c-array-max character #.MAX_PATH)) :out :alloca)
              (size int))
  (:return-type uint32))

(def-call-out get-module-handle (:library "kernel32.dll")
  (:name "GetModuleHandleA")
  (:arguments (name c-string))
  (:return-type c-pointer))

[16]> (get-module-file-name (get-module-handle nil) max_path)
37 ;
"d:\\gnu\\clisp\\current\\build-g\\lisp.exe"
[17]> (get-module-file-name (get-module-handle "kernel32") max_path)
30 ;
"C:\\WINNT\\system32\\KERNEL32.dll"
[18]>

see modules/bindings/win32 for more examples.

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
Lisp is a language for doing what you've been told is impossible. - Kent Pitman

---

From: Sam Steingold <[email-masked]>
Date: Thu Oct 16 12:20:11 2003

> to pass an instance handle in order to successfully execute it.

Just pass NIL (NULL).

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com>
((lambda (x) (list x (list 'quote x))) '(lambda (x) (list x (list 'quote x))))

---

From: André Vargas Abs da Cruz <[email-masked]>
Date: Thu Oct 16 12:27:08 2003

Worked just fine. I'll look also for the other references you gave.
Thank you very much for your help !!!

regards
andré

-----Original Message-----
From: Sam Steingold
Subject: [clisp-list] Re: Creating windows

Just pass NIL (NULL).

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.honestreporting.com> ((lambda
(x) (list x (list 'quote x))) '(lambda (x) (list x (list 'quote x))))

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects. See the people
who have HELPED US provide better services: Click here:
http://sourceforge.net/supporters.php
_______________________________________________
clisp-list mailing list
[email-masked]
https://lists.sourceforge.net/lists/listinfo/clisp-list

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.525 / Virus Database: 322 - Release Date: 9/10/2003

---

---

From: Dan Stanger <[email-masked]>
Date: Thu Oct 16 14:53:05 2003

This is what the gdi module in the packages directory does.

André Vargas Abs da Cruz wrote:

> SourceForge.net hosts over 70,000 Open Source Projects.
> See the people who have HELPED US provide better services:
> Click here: http://sourceforge.net/supporters.php