Thread overview
Can D use MFC for gui?
Jul 15, 2004
Lynn Allan
Jul 16, 2004
Stewart Gordon
Jul 16, 2004
Lynn Allan
Jul 16, 2004
Stewart Gordon
Jul 19, 2004
Stewart Gordon
Jul 16, 2004
Ilya Minkov
Jul 19, 2004
Stewart Gordon
Jul 16, 2004
a
July 15, 2004
Can a D program use MFC for its gui?

I'm considering porting a relatively simple freeware app to D ... somewhat as a POC ... getting up to speed with D.  This app currently uses Visual C++ 6 with MFC.

My impression is that the status of gui's usable by D is pretty immature. I'm not a fan of "hold-your-nose" MFC, but it does work, that's what I'm familiar with, and you can write some very "small footprint" apps because essentially every WIntel box with Win98-SE or later has mfc42.dll.

I've looked briefly at the winsamp.d code, and notice that dmd 0.95 has references to mfc. I infer that a sufficiently motivated person could write a D program that used MFC to write a SDI (single document) or dialog app.

Is this correct? Is there any sample code that has a D program calling MFC functionality to put up a "Hello From MFC" window? The 0.1 version I'm envisioning only needs a multiline edit box, several buttons, and several drop-down combo-boxes.

Semi-related question ... I wonder if this usage would outside of MFC licensing?

TIA,
Lynn A.





July 16, 2004
Lynn Allan wrote:

<snip>
> Is this correct? Is there any sample code that has a D program calling MFC functionality to put up a "Hello From MFC" window?

D doesn't have an interface to C++, so you can't do it directly.  I get the impression there are ways of doing it, but don't know about them. But I also get the impression that MFC (like OWL) uses macros in an unusual way that doesn't convert easily to D.

There are various D GUI libraries, but they're still at early stages of development.  DFC is presumably modelled on MFC, but this is only implied.  The other one that's a thin layer over the Windows API is my own, SDWF.

http://www.geocities.com/one_mad_alien/dcode/
http://smjg.port5.com/pr/d/sdwf/
http://www.wikiservice.at/wiki4d/wiki.cgi?AvailableGuiLibraries

> The 0.1 version I'm envisioning only needs a multiline edit box, several buttons, and several drop-down combo-boxes.

SDWF doesn't support combo boxes yet, but I'm guessing that the ListBox class could interface one of these.  But assuming that you're using dialog resources, it supports the others just fine.

I also haven't tried using a dialog as a main window, but I think it just might work.

Stewart.

-- 
My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.
July 16, 2004
Hi Steward,

I'll look closer at your SDWF. Does it support Tree controls? That would suffice for the missing drop-down combo box.

Lynn A.

> > The 0.1 version I'm envisioning only needs a multiline edit box, several buttons, and several drop-down combo-boxes.
>
> SDWF doesn't support combo boxes yet, but I'm guessing that the ListBox class could interface one of these.  But assuming that you're using dialog resources, it supports the others just fine.


July 16, 2004
Lynn Allan wrote:

> Hi Steward,
> 
> I'll look closer at your SDWF. Does it support Tree controls? That would
> suffice for the missing drop-down combo box.
<snip top of upside-down reply>

Not at the moment.  Supporting more controls is one of several planned improvements.

Stewart.

-- 
My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.
July 16, 2004
Lynn Allan schrieb:
> Can a D program use MFC for its gui?

I'm aftraid trying to get MFC access from D would be technically a pretty pointless thing. Besides, not everyone has the MFC license - only people having a commercial C++ compiler do.

A better alternative is wxWindows, since its license is not restrictive, it supports multiple platforms, and is somewhat similar. Besides, it has been wrapped for Python and other langs using SWIG. Now we have SWIG for D, so one could consider a major portion of the work done.

> I'm considering porting a relatively simple freeware app to D ... somewhat
> as a POC ... getting up to speed with D.  This app currently uses Visual C++
> 6 with MFC.
> 
> My impression is that the status of gui's usable by D is pretty immature.
> I'm not a fan of "hold-your-nose" MFC, but it does work, that's what I'm
> familiar with, and you can write some very "small footprint" apps because
> essentially every WIntel box with Win98-SE or later has mfc42.dll.

Considering MFC wraps Winapi, and has to be double-wrapped to be usable from D, i don't think you get any size advantage compared to a native D library, rather the opposite.

One can make a pretty thin class library though, if it's made entirely dependant on the Winapi. Good examples are VXCL and Classlib from the C++ world, which give about 50 K large executables for a simple case like yours.

> I've looked briefly at the winsamp.d code, and notice that dmd 0.95 has
> references to mfc. I infer that a sufficiently motivated person could write
> a D program that used MFC to write a SDI (single document) or dialog app.

I'm aftraid it's not so. Where does dmd have any reference to MFC?

I think what you found is a library contributed by Matthew written in C++, recls, which is for directory traversal. This library pulls Winstl in, which whats to know whether MFC has been used in the project. However, this knowledge is utterly irrelevant to the ability to compile recls, which is then linked in using C interface. So none of D library or samples has awareness of MFC.

> Is this correct? Is there any sample code that has a D program calling MFC
> functionality to put up a "Hello From MFC" window? The 0.1 version I'm
> envisioning only needs a multiline edit box, several buttons, and several
> drop-down combo-boxes.

Doesn't undig cut it? Undig strives to be platform-agnostic in the interface though, which makes it a bit bigger than necessary.

> Semi-related question ... I wonder if this usage would outside of MFC
> licensing?

Wrapping MFC should be OK, but every coder to use it must have a licensed copy - first wxWindows version was like that. I didn't have a license till recently, and even now i'd not be happy to depend on it.

-eye
July 16, 2004
Try DFL !  C# style Forms for D, www.dprogramming.com/dfl

Anon

In article <cd6rhr$2f1m$1@digitaldaemon.com>, Lynn Allan says...
>
>Can a D program use MFC for its gui?
>
>I'm considering porting a relatively simple freeware app to D ... somewhat as a POC ... getting up to speed with D.  This app currently uses Visual C++ 6 with MFC.
>
>My impression is that the status of gui's usable by D is pretty immature. I'm not a fan of "hold-your-nose" MFC, but it does work, that's what I'm familiar with, and you can write some very "small footprint" apps because essentially every WIntel box with Win98-SE or later has mfc42.dll.
>
>I've looked briefly at the winsamp.d code, and notice that dmd 0.95 has references to mfc. I infer that a sufficiently motivated person could write a D program that used MFC to write a SDI (single document) or dialog app.
>
>Is this correct? Is there any sample code that has a D program calling MFC functionality to put up a "Hello From MFC" window? The 0.1 version I'm envisioning only needs a multiline edit box, several buttons, and several drop-down combo-boxes.
>
>Semi-related question ... I wonder if this usage would outside of MFC licensing?
>
>TIA,
>Lynn A.
>
>
>
>
>


July 19, 2004
Stewart Gordon wrote:
<snip>
> SDWF doesn't support combo boxes yet, but I'm guessing that the ListBox class could interface one of these.  But assuming that you're using dialog resources, it supports the others just fine.

Oops ... I was wrong.  The message IDs for combo boxes are inconsistent with those for list boxes, so it doesn't work at the moment.  But it would be straightforward to make it work.

> I also haven't tried using a dialog as a main window, but I think it just might work.

As it happens I hadn't got that right, but have now got it working on my box.  Consider SDWF 0.3 to be in the pipeline....

Stewart.

-- 
My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.
July 19, 2004
Ilya Minkov wrote:

> Lynn Allan schrieb:
> 
>> Can a D program use MFC for its gui?
> 
> I'm aftraid trying to get MFC access from D would be technically a pretty pointless thing. Besides, not everyone has the MFC license - only people having a commercial C++ compiler do.
> 
> A better alternative is wxWindows, since its license is not restrictive, it supports multiple platforms, and is somewhat similar.

That is like saying Java is better than D - it depends on what you want out of it.

http://www.digitalmars.com/d/faq.html#q7

It's the same with different GUI libraries.  wxWidgets (fka wxWindows), DUI and others are designed for cross-platform GUI development.  MFC and others, OTOH, are meant for developing efficient native apps.

<snip>
> One can make a pretty thin class library though, if it's made
> entirely dependant on the Winapi. Good examples are VXCL and Classlib
> from the C++ world, which give about 50 K large executables for a
> simple case like yours.
<snip>

And, of course, OWL, MFC and SDWF.

Stewart.

-- 
My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.