Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Visual C++: the need for MFC

Reply
Thread Tools

Visual C++: the need for MFC

 
 
Man-wai Chang ToDie (33.6k)
Guest
Posts: n/a
 
      06-14-2008

Is it possible to build a Visual C++ GUI program without using MFC,
using VC++ 2008 Express Edition?

Forget about the time and speed issue.

--
@~@ Might, Courage, Vision, SINCERITY.
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Xubuntu 8.04) Linux 2.6.25.6
^ ^ 20:42:01 up 2 days 10:36 2 users load average: 1.08 1.14 1.06
? ? (CSSA):
http://www.swd.gov.hk/tc/index/site_...ub_addressesa/
 
Reply With Quote
 
 
 
 
Nick Keighley
Guest
Posts: n/a
 
      06-14-2008
On Jun 14, 1:44*pm, "Man-wai Chang ToDie (33.6k)"
<(E-Mail Removed)> wrote:

> Is it possible to build a Visual C++ GUI program without using MFC,
> using VC++ 2008 Express Edition?
>
> Forget about the time and speed issue.


yes. For details ask in a microsoft ng.
eg. comp.os.ms-windows.programmer.win32


-- Nick Keighley
 
Reply With Quote
 
 
 
 
Linonut
Guest
Posts: n/a
 
      06-14-2008
* Man-wai Chang ToDie (33.6k) peremptorily fired off this memo:

> Is it possible to build a Visual C++ GUI program without using MFC,
> using VC++ 2008 Express Edition?


Pick a cross-platform framework such as FLTK, wxWidgets, Qt, gtk++, or
others, and use that for developing a GUI.

You might see if there some open-source projects already out there that
work on Windows, to get a good code example.

--
When we have the information highway, I'll put it [information about
himself] out there. Everybody who wants to pay, I don't know, one cent, can
see what movies I'm watching and what books I'm reading and certain other
information. If I'm still interesting, I'll rack up dollars as people
access that part of the highway.
-- Bill Gates, Interview in Playboy magazine (1994)
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      06-14-2008
Man-wai Chang ToDie (33.6k) wrote:
>
> Is it possible to build a Visual C++ GUI program without using MFC,
> using VC++ 2008 Express Edition?
>
> Forget about the time and speed issue.
>


Well, the "wizard" of the lcc-win compiler generates
a skeleton for a GUI application complete with menu/main loop
window class registering/opening, etc with just a few clicks.

The output language is just C (NOT C++) so there is surely
no MFC involved.

You can download the lcc-win C compiler at no charge from
the address below.

--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      06-14-2008
Man-wai Chang ToDie (33.6k) wrote:
>
> Is it possible to build a Visual C++ GUI program without using MFC,
> using VC++ 2008 Express Edition?


You can avoid using MFC by using the Win32 API directly, but you
*really* don't want to do that, believe me. Even creating the simplest
of dialogs using the Win32 API is a nightmare.

If you don't mind using alternative libraries, consider WTL or some of
the portable ones (such as wxwidgets).
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      06-15-2008
Juha Nieminen wrote:
> Man-wai Chang ToDie (33.6k) wrote:
>> Is it possible to build a Visual C++ GUI program without using MFC,
>> using VC++ 2008 Express Edition?

>
> You can avoid using MFC by using the Win32 API directly, but you
> *really* don't want to do that, believe me. Even creating the simplest
> of dialogs using the Win32 API is a nightmare.
>


No, it is fairly easy, and you get used to it fairly quickly.

This horror story has been repeated at will by people that want to
promote this or that library.

I always use C for my dialogs. Suppose a dialog that asks for a number,
with two OK Cancel buttons.

The minimal code to handle that dialog is:
INT_PTR CALLBACK AskALine(HWND hDlg,MSGTYPE message,WPARAM wParam,LPARAM
lParam)
{
int i, c, line;
HWND hCB;
char tmpbuf[10];
switch (message) {
case WM_COMMAND:
switch (GETIDFROMWPARAM(wParam)) {
case IDOK:
GetDlgItemText(hDlg,IDGOTOLINENR, tmpbuf, 9);
if (!ValidateInteger(tmpbuf, &line))
return 1;
if (l <= 0)
break;
EndDialog(hDlg,line);
return 1;
}
}
return (HandleDefaultMessages(hDlg, message, wParam, lParam));
}

That is all. True, the "HandleDefaultMessages" procedure will
be a more complex one, but essentially that is ALL the code
you will want to write. And guess what?

That code was written for windows 3.1. And that code performs
perfectly under windows Vista 64 bits. It was "ported" from
16 bits to 32, and from 32 to 64. And it does NOT need anything
more than EXACTLY what you need.

But obviously I am wrong. Keeping it simple is no longer a
good strategy nowadays.

> If you don't mind using alternative libraries, consider WTL or some of
> the portable ones (such as wxwidgets).



--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      06-15-2008
jacob navia wrote:
> I always use C for my dialogs. Suppose a dialog that asks for a number,
> with two OK Cancel buttons.
>
> The minimal code to handle that dialog is:
> INT_PTR CALLBACK AskALine(HWND hDlg,MSGTYPE message,WPARAM wParam,LPARAM
> lParam)
> {
> int i, c, line;
> HWND hCB;
> char tmpbuf[10];
> switch (message) {
> case WM_COMMAND:
> switch (GETIDFROMWPARAM(wParam)) {
> case IDOK:
> GetDlgItemText(hDlg,IDGOTOLINENR, tmpbuf, 9);
> if (!ValidateInteger(tmpbuf, &line))
> return 1;
> if (l <= 0)
> break;
> EndDialog(hDlg,line);
> return 1;
> }
> }
> return (HandleDefaultMessages(hDlg, message, wParam, lParam));
> }


I fail to see where is it that you define the actual contents of the
dialog: Title bar text, dialog text and its location, a textfield (or
similar, to ask for the number) and its geometry, the amount and
contents of the buttons...

The only thing I see there is a callback function which handles
signals received by something.

Note that we are talking about Visual Studio Express here: AFAIK it
doesn't have fancy graphical window design editors. If you want to
create a new window type using the Win32 API, you'll have to write it
completely by hand. And, AFAIK, this is a real nightmare.
 
Reply With Quote
 
jacob navia
Guest
Posts: n/a
 
      06-15-2008
Juha Nieminen wrote:
> jacob navia wrote:
>> I always use C for my dialogs. Suppose a dialog that asks for a number,
>> with two OK Cancel buttons.
>>
>> The minimal code to handle that dialog is:
>> INT_PTR CALLBACK AskALine(HWND hDlg,MSGTYPE message,WPARAM wParam,LPARAM
>> lParam)
>> {
>> int i, c, line;
>> HWND hCB;
>> char tmpbuf[10];
>> switch (message) {
>> case WM_COMMAND:
>> switch (GETIDFROMWPARAM(wParam)) {
>> case IDOK:
>> GetDlgItemText(hDlg,IDGOTOLINENR, tmpbuf, 9);
>> if (!ValidateInteger(tmpbuf, &line))
>> return 1;
>> if (l <= 0)
>> break;
>> EndDialog(hDlg,line);
>> return 1;
>> }
>> }
>> return (HandleDefaultMessages(hDlg, message, wParam, lParam));
>> }

>
> I fail to see where is it that you define the actual contents of the
> dialog: Title bar text, dialog text and its location, a textfield (or
> similar, to ask for the number) and its geometry, the amount and
> contents of the buttons...
>
> The only thing I see there is a callback function which handles
> signals received by something.
>
> Note that we are talking about Visual Studio Express here: AFAIK it
> doesn't have fancy graphical window design editors. If you want to
> create a new window type using the Win32 API, you'll have to write it
> completely by hand. And, AFAIK, this is a real nightmare.



Obviously you need a resource editor that generates the dialog template
for you.

Such an editor is present in the compiler system

lcc-win

or in many other compilers.

To do a simple dialog like the one I described you need
around 10 clicks of the mouse and it is all done.

You can download lcc-win at the URL below


--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
 
Reply With Quote
 
Nick Keighley
Guest
Posts: n/a
 
      06-16-2008
On 15 Jun, 13:23, jacob navia <(E-Mail Removed)> wrote:
> Juha Nieminen wrote:
> > Man-wai Chang ToDie (33.6k) wrote:


> >> Is it possible to build a Visual C++ GUI program without using MFC,
> >> using VC++ 2008 Express Edition?

>
> > * You can avoid using MFC by using the Win32 API directly, but you
> > *really* don't want to do that, believe me. Even creating the simplest
> > of dialogs using the Win32 API is a nightmare.

>
> No, it is fairly easy, and you get used to it fairly quickly.
>
> This horror story has been repeated at will by people that want to
> promote this or that library.


Jocob is correct. Writing applications using in32 is not particularly
difficult.


--
Nick Keighley
 
Reply With Quote
 
Jerry Coffin
Guest
Posts: n/a
 
      06-16-2008
In article <d6ac9a2d-fce0-4d88-bd8f-21fbae48d780
@m3g2000hsc.googlegroups.com>, http://www.velocityreviews.com/forums/(E-Mail Removed) says...

[ ... ]

> Jocob is correct. Writing applications using in32 is not particularly
> difficult.


It isn't _particularly_ difficult, that's true.

OTOH, using the raw API, you have about 50 lines of code to register a
window class, create a window and make it visible. You have another 30-
40 lines for even an extremely minimal message processor. You have
another 25 lines for a message loop plus calling the above. If you want
an MDI application, roughly double all of those (i.e. you have to
register an extra window class, create not just two but three windows,
be ready to respond to messages to do things like cascade and tile the
child windows, etc.)

For beginners, this is rather intimidating: they have to write a couple
of hundred lines of code (or so) just to get to the point of a bare
minimum program that doesn't really even DO anything yet -- it just
creates an empty window that you can resize, minimize, maximize, etc.

For experienced programmers, it's no longer intimidating, but it is
repetitive and boring. Nearly the only reasonable alternative is to use
a library of one sort or another -- if you don't use a conventional
library of object code, then you use a "library" of source code from
which to cut and paste chunks of code to avoid retyping the same junk
over and over and over again.

The bottom line is that for most people's programs most of the time,
writing to the raw Win32 API is a pointless waste of time.

We now return you to your regularly scheduled (but topical) flaming...

--
Later,
Jerry.

The universe is a figment of its own imagination.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with exposure of object in MFC visual c++ Test C++ 2 03-17-2006 01:43 AM
Derive from MFC DLL to MFC APP yopwojtek C++ 1 08-06-2005 05:12 PM
Debug (DLL MFC) -> Debug (Static MFC) ringos75 C++ 0 04-14-2005 01:50 PM
Visual C++ MFC error with Windows XP Jimmie C++ 1 08-26-2003 02:17 AM
Re: Using advanced MFC components without the use of MFC Scott McPhillips C++ 0 07-05-2003 03:46 AM



Advertisments