From: Benoit Paul
Subject: lisp and MFC
Date: 
Message-ID: <ek6g5.56418$1h3.825150@news20.bellglobal.com>
Hi!

I would like to make a program in lisp and use a MFC GUI.  Does anybody has
suggestions or documentation about the subject?

thanks a lot,
Ben

From: David Bakhash
Subject: Re: lisp and MFC
Date: 
Message-ID: <c29snsuvq7m.fsf@mint-square.mit.edu>
"Benoit Paul" <··········@sympatico.ca> writes:

> I would like to make a program in lisp and use a MFC GUI.  Does
> anybody has suggestions or documentation about the subject?

One suggestion I'd have is to use Corman Lisp on Windows.  Supposedly
you have access to the full Win32 stuff with it.  That Lisp can (from
what I've read) parse C++ header files, and so it (supposedly) does so
with MFC.  Please don't quote me.  You can probalby get a good link to
it from http://www.lisp.org

dave
From: Oliver Niggemann
Subject: Re: lisp and MFC
Date: 
Message-ID: <8lrhm4$a3m$1@news.uni-paderborn.de>
> > I would like to make a program in lisp and use a MFC GUI.  Does
> > anybody has suggestions or documentation about the subject?
>
> One suggestion I'd have is to use Corman Lisp on Windows.  Supposedly
> you have access to the full Win32 stuff with it.  That Lisp can (from
> what I've read) parse C++ header files, and so it (supposedly) does so
> with MFC.  Please don't quote me.  You can probalby get a good link to
> it from http://www.lisp.org

We use Corman Lisp with a MFC GUI, simply attach the CormanLisp dll to the
MFC program.
It works quite well. Harlequin's LispWorks should do the same (I haven't
tried it yet).

    Oliver Niggemann
From: David Bakhash
Subject: Re: lisp and MFC
Date: 
Message-ID: <c29hf9ammpu.fsf@nerd-xing.mit.edu>
"Oliver Niggemann" <······@uni-paderborn.de> writes:

> > > I would like to make a program in lisp and use a MFC GUI.  Does
> > > anybody has suggestions or documentation about the subject?

> We use Corman Lisp with a MFC GUI, simply attach the CormanLisp dll to the
> MFC program.

well, I think that it would ideally be the other way around; i.e. that
the ``program'' would be in Corman CL, and the MFC callable from there.

dave
From: Oliver Niggemann
Subject: Re: lisp and MFC
Date: 
Message-ID: <8ls7t6$h01$1@news.uni-paderborn.de>
"David Bakhash" <·····@alum.mit.edu> schrieb im Newsbeitrag
····················@nerd-xing.mit.edu...
> "Oliver Niggemann" <······@uni-paderborn.de> writes:
>
> > > > I would like to make a program in lisp and use a MFC GUI.  Does
> > > > anybody has suggestions or documentation about the subject?
>
> > We use Corman Lisp with a MFC GUI, simply attach the CormanLisp dll to
the
> > MFC program.
>
> well, I think that it would ideally be the other way around; i.e. that
> the ``program'' would be in Corman CL, and the MFC callable from there.

Our applications normally work like this: The user asks for a computation
using the GUI
(written in MFC). This computation is done using lisp and the results are
presented using
the MCF GUI again. Since a computation starts and ends at the GUI part,
using a lisp
dll makes sense for us. But of course, other problems may need other
solutions .....
Furthermore IMHO the Lisp-DLL approach seems to be from a technical point of
view easier.

    Oliver Niggemann
From: David Bakhash
Subject: Re: lisp and MFC
Date: 
Message-ID: <m33dkup908.fsf@cadet.dsl.speakeasy.net>
"Oliver Niggemann" <······@uni-paderborn.de> writes:

> Our applications normally work like this: The user asks for a
> computation using the GUI (written in MFC). This computation is done
> using lisp and the results are presented using the MCF GUI
> again. Since a computation starts and ends at the GUI part, using a
> lisp dll makes sense for us. But of course, other problems may need
> other solutions .....  Furthermore IMHO the Lisp-DLL approach seems
> to be from a technical point of view easier.

well, then the question is really, what is the "application" that is
written in Lisp?  The point of using MFC calls from Lisp was to be
able to write Windows applications in Common Lisp.  It seems in your
case that the application was this GUI, and it is not written in
Common Lisp.  I was really trying to answer the question "How do you
write applications in Common Lisp which use the MFC, but are not
written in C++?"

I do understand what you guys are doing, and how it's different.  The
lisp dll is sufficient for your needs.

dave
From: ·····@corman.net
Subject: Re: lisp and MFC
Date: 
Message-ID: <8m4s0v$ies$1@nnrp1.deja.com>
In article <··············@cadet.dsl.speakeasy.net>,
  David Bakhash <·····@alum.mit.edu> wrote:
> well, then the question is really, what is the "application" that is
> written in Lisp?  The point of using MFC calls from Lisp was to be
> able to write Windows applications in Common Lisp.  It seems in your
> case that the application was this GUI, and it is not written in
> Common Lisp.  I was really trying to answer the question "How do you
> write applications in Common Lisp which use the MFC, but are not
> written in C++?"
>
The problem here is mainly MFC. MFC expects to be the application
framework, i.e. the entire application flow of control and UI,
from starting up to quitting, is under control of MFC. It is
extremely difficult to use only parts of MFC (other than a few
small classes such as CString or CFile). I consider this a deficiency
and inflexibility of MFC. In an MFC app, all UI related code
(and perhaps all the code) typically reside in classes which
inherit from MFC classes (and of course are written in C++).

However, even if MFC were suitable for creating a GUI by calling
it from Lisp, then you still have a problem that the Corman Lisp
FFI (and Lisp FFI's in general) are not very good at calling C++.
C++ compilers vary in terms of calling conventions and data
layouts of compiled code, and object instance formats are not
standard. Of course, MFC does adhere to the Microsoft C++
conventions (at least for the current version) so one could
make a custom FFI which talks to Visual C++ 6.0 code. However,
this is likely to need routine maintenance, as Microsoft modifies
their compiler, and in any case the FFI will probably not be
able to completely handle C++, but only the small subset of the
language that MFC supports (for example, no multiple inheritance).
This is ugly, and hackish, and this is why I have tended away from
supporting C++ interfaces. C interfacing is fairly clean, easy
and portable by comparison.

By the way, the Corman Lisp IDE is currently implemented in MFC,
and I have dealt with this issue quite a bit.

Microsoft invented COM to get around C++ (and other language)
binary incompatibility problems. In my opinion, its best use
is for this. A Corman Lisp application should be able to
use COM objects to build a UI, such as ActiveX controls.
COM support is included in Corman Lisp, but fairly primitive.
You still need to have a pretty deep understanding of COM
to use it at this time.

Roger Corman


Sent via Deja.com http://www.deja.com/
Before you buy.
From: The Glauber
Subject: Re: lisp and MFC
Date: 
Message-ID: <8lruqh$c5o$1@nnrp1.deja.com>
In article <···············@mint-square.mit.edu>,
[...]
> One suggestion I'd have is to use Corman Lisp on Windows.  Supposedly
> you have access to the full Win32 stuff with it.  That Lisp can (from
> what I've read) parse C++ header files, and so it (supposedly) does so
> with MFC.  Please don't quote me.  You can probalby get a good link to
> it from http://www.lisp.org


Corman Lisp is at
http://www.corman.net/CormanLisp.html
--
Glauber Ribeiro
··········@my-deja.com    http://www.myvehiclehistoryreport.com
"Opinions stated are my own and not representative of Experian"


Sent via Deja.com http://www.deja.com/
Before you buy.
From: Reini Urban
Subject: Re: lisp and MFC
Date: 
Message-ID: <3982d6fb.74942782@judy>
David Bakhash wrote:
>"Benoit Paul" <··········@sympatico.ca> writes:
>
>> I would like to make a program in lisp and use a MFC GUI.  Does
>> anybody has suggestions or documentation about the subject?
>
>One suggestion I'd have is to use Corman Lisp on Windows.  Supposedly
>you have access to the full Win32 stuff with it.  That Lisp can (from
>what I've read) parse C++ header files, and so it (supposedly) does so
>with MFC.  Please don't quote me.  You can probalby get a good link to
>it from http://www.lisp.org

I disagree.
You can easily use the "WinAPI" from Corman Lisp, ACL or Lispworks,
either via the FFI or the better convenience graphic functions from the
latter two. Better do GUI without the MFC.

The "MFC" as C++ class library is totally useless if you use ACL or
Lispworks. And it is hard to use with Corman Lisp, because you cannot
interface to the C++ classes easily yet. 
In fact, nobody wants to do that. The Lisp objects are much better.

Theoretically you can do it if you use a certain MSVC only and look at
the COM functions which use the early bound, vtable approach, which is
in memory the same as a C++ class. So it would be really easy to
interface to a C++ class, but is hard to derive from it dynamically,
without knowing the C++ name mangling scheme.

E.g. see Corman Lisp/sys/ffi.lisp: defun-com-method to define a
restricted C++ callable class method.
But I know nobody so far how ever came into or even near this mess,
besides the available COM FFI interfaces which is much easier to do than
a generic C++ FFI.

Or as Oliver did, call Corman from a C++ MFC app. Then you can pass
foreign C++ pointers to the lisp, e.g. to help lisp doing MFC events or
call some MFC methods.
--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/lisp/ffis.html