By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,786 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,786 IT Pros & Developers. It's quick & easy.

Visual C++: the need for MFC

P: n/a

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/
Jun 27 '08 #1
Share this Question
Share on Google+
16 Replies


P: n/a
On Jun 14, 1:44*pm, "Man-wai Chang ToDie (33.6k)"
<toylet.toy...@gmail.comwrote:
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
Jun 27 '08 #2

P: n/a
* 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)
Jun 27 '08 #3

P: n/a
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
Jun 27 '08 #4

P: n/a
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).
Jun 27 '08 #5

P: n/a
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
Jun 27 '08 #6

P: n/a
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.
Jun 27 '08 #7

P: n/a
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
Jun 27 '08 #8

P: n/a
On 15 Jun, 13:23, jacob navia <ja...@nospam.comwrote:
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
Jun 27 '08 #9

P: n/a
In article <d6ac9a2d-fce0-4d88-bd8f-21fbae48d780
@m3g2000hsc.googlegroups.com>, ni******************@hotmail.com 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.
Jun 27 '08 #10

P: n/a
jacob navia wrote:
3: Simplicity.
This one made me ROTFL.
Jun 27 '08 #11

P: n/a
jacob navia wrote:
Only those people that used the windows API are now able to develop
their applications without any problems now!
And they'll run only on Windows (Wine is a half-working hack, not a
robust platform.) Applications today are best developped in a
cross-platform way, this not only makes them easier ported to other
existing systems, it also makes them more portable towards future
developments just in the same way that writing in a higher-level
language compared to assembler will make your software more portable if
the industry moves on from processor type X to processor type Y.
Jun 27 '08 #12

P: n/a
Jerry Coffin wrote:
>MFC is obsolete and hasn't been updated for several YEARS now.

False! It was updated (significantly) for Visual Studio 2008 -- which is
to say within the last few months (note how I've used the exclamation
point to emphasize something that clearly is NOT known to many
developers).

MFC's last update was in 1998. Ten years passed and nothing was updated,
until now. I did not know about this new release. So, obviously a
library that is updated in a 10 YEAR basis is considered OK.

There is no point in discussing this further.

Use MFC. I will go on using the API.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
Jun 27 '08 #13

P: n/a
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.
Use WTL 8, it comes with a project wizard.
http://www.download.com/Windows-Temp...-10731539.html

But why do you wanna use Visual Studio 2008 Express? You have to also
deploy its redist package, which has so many installation problems and
they become your problems.

Jul 1 '08 #14

P: n/a
On Jun 17, 12:49*am, Jerry Coffin <jcof...@taeus.comwrote:
False! It was updated (significantly) for Visual Studio 2008 -- which is
to say within the last few months (note how I've used the exclamation
point to emphasize something that clearly is NOT known to many
developers).
Jerry needs no support from me but just to bolster his point, please
read the Visual C++ team blog's latest entry:
http://blogs.msdn.com/vcblog/archive...the-booth.aspx

The recent updates to MFC apparently was the talk of TechEd 2008.

Also, I don't know if Jerry knows about this but John Torjo's template
based C++-GUI library is also shaping up to be a fine competitor:
http://msdn.microsoft.com/en-us/magazine/cc534994.aspx
Jul 1 '08 #15

P: n/a
I suppose it depends on what you are after...

If you are developing your own applications, please see above posts.

Otherwise, if you are looking for a job in C/C++, then the above is
probably a moot point. It would then be prudent to learn MS or
whatever compiler would impress a potential employer these days.

Feedscrn
Jul 4 '08 #16

P: n/a
In article <22a707fe-d775-4a99-b3af-dd8ed82d5159
@r66g2000hsg.googlegroups.com>, rd*****@lycos.com says...
On Jun 17, 12:49*am, Jerry Coffin <jcof...@taeus.comwrote:
False! It was updated (significantly) for Visual Studio 2008 -- which is
to say within the last few months (note how I've used the exclamation
point to emphasize something that clearly is NOT known to many
developers).
Jerry needs no support from me but just to bolster his point, please
read the Visual C++ team blog's latest entry:
http://blogs.msdn.com/vcblog/archive...the-booth.aspx

The recent updates to MFC apparently was the talk of TechEd 2008.
Right -- I should also mention that although it's clearly the _largest_
update to MFC in quite a while, this really is NOT the first in ten
years as was stated elsethread. Documentation of them has been minimal
(to put it nicely) but I believe every release of the compiler has
included at least a few minor updates to MFC.
Also, I don't know if Jerry knows about this but John Torjo's template
based C++-GUI library is also shaping up to be a fine competitor:
http://msdn.microsoft.com/en-us/magazine/cc534994.aspx
Yup -- while this clearly has a lot less support, it also looks like
quite a decent library.

--
Later,
Jerry.

The universe is a figment of its own imagination.
Jul 7 '08 #17

This discussion thread is closed

Replies have been disabled for this discussion.