Archived

This topic is now archived and is closed to further replies.

What exactly is MFC?

This topic is 5627 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

All I know about MFC is it provides a nicer way to be notified of messages - you supply a function to be called, and that it's very good for complicated dialogs. Why and how is it better for complicated window control setups, do you have to radically alter all code to use it or just the initialisation stuff? Oh also I got the impression you didn't need a complicated callback function for every button/text input thingy. Is this true? Does standard windows (MSVC++) support an easy way of linking controls to functions ie will it automatically generate an empty function for me (like in JBuilder)? John 3:16 [edited by - d000hg on July 16, 2002 3:41:56 PM]

Share this post


Link to post
Share on other sites
Google is still your friend, as is MSDN. MFC is a framework that abstracts you from Win32 API and simplifies common programming tasks, see the links for more info.

---
Come to #directxdev IRC channel on AfterNET

Share this post


Link to post
Share on other sites
Claimed to be Microsoft Foundation Class, but most of the time, it is Microsoft Fustration Class. It contains loads of odd preprocessing #defines plus, a function call made in MFC might means thousands line of code being executed. And if you are trying to have MFC work your way (instead of having you to work the MFC way)... then it is like using a Pirate Lego set to create a nice sport car set. I can't imagine how Mr. Hook drives the car - you know, it is not easy to steer the car with a hook, and accelerate the car with a wooden 'leg'.

[edited by - DerekSaw on July 16, 2002 9:20:04 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by d000hg
...Does standard windows (MSVC++) support an easy way of linking controls to functions ie will it automatically generate an empty function for me (like in JBuilder)?


I think Borland C++Builder serves you best in this case.

Share this post


Link to post
Share on other sites
quote:
Original post by DerekSaw
Claimed to be Microsoft Foundation Class, but most of the time, it is Microsoft Fustration Class.


with the current msdn documenation, technical notes, and widely available source code you can only be frustrated if you don''t know how to search. mfc is frustrating sometimes, but far less often that you''re making it out to be.
quote:

It contains loads of odd preprocessing #defines


you''d be surprised how much preprocessor stlport, or any general-purpose library, has. learn to read the preprocessor. browse information greatly helps in this respect.
quote:

plus, a function call made in MFC might means thousands line of code being executed.


yadda yadda. mfc''s overhead is nowhere near this big. and you''re forgetting all the nice things that mfc does so that you can write five lines of code instead of a thousand it would take you to implement equivalent functionality in plain win32.
quote:

And if you are trying to have MFC work your way (instead of having you to work the MFC way)... then it is like using a Pirate Lego set to create a nice sport car set. I can''t imagine how Mr. Hook drives the car - you know, it is not easy to steer the car with a hook, and accelerate the car with a wooden ''leg''.


read the docs, resources, and code samples. see the point on frustration above. mfc is easy to use if you know where to fund information, and there is an incredible amount of information available.

is mfc overkill for a tutorial app? maybe. was it designed for writing games? probably not. however, it''s nowhere near as bad as you''re describing it. many tedious tasks in win32 are made very easy by mfc. it certainly does a pretty good job at what it was designed for -- providing a fairly high level win32 wrapper. i suspect you just don''t have an in-depth knowledge of it, and are speaking of ignorance.

did i mention that Windows Template Library does a lot of what mfc does and is much cleaner? play with it if you''re not afraid of the source.

---
Come to #directxdev IRC channel on AfterNET

Share this post


Link to post
Share on other sites
Here''s a little advice. Do NOT discount MFC without using it. I did that for a couple of years, thinking it was crap. But I just recently started using it at my internship about a month ago. Using the classwizard, you can do things very easily and quickly. Complex Windows programs (multidocument windows, big dialog boxes, etc.) become very simple. A lot of people foolishly say it sucks without knowing a thing about it, I know because I use to be one of them. But now I will reach for MFC if I want to simplify a program and make my life easier. Gosh this sounds like an infomercial. Anyways, just try it.

Share this post


Link to post
Share on other sites
niyaw, that''s my feeling about MFC anyway. I don''t feel good when looking at those similar BEGIN_MESSAGE_MAP(), END_MESSAGE_MAP, TRY/CATCH/THROW.

quote:
Original post by BitBlt
Here''s a little advice. Do NOT discount MFC without using it. I did that for a couple of years, thinking it was crap. But I just recently started using it at my internship about a month ago. Using the classwizard, you can do things very easily and quickly. Complex Windows programs (multidocument windows, big dialog boxes, etc.) become very simple. A lot of people foolishly say it sucks without knowing a thing about it, I know because I use to be one of them. But now I will reach for MFC if I want to simplify a program and make my life easier. Gosh this sounds like an infomercial. Anyways, just try it.

I''ve used it before (even that time they don''t even have ClassWizard, but a lousy Programmer WorkBench ) and I''m still using it now. And yes... it was easy, when you do it ''their'' way. Anyway, I would anytime prefer C++Builder VCL to MFC because the former is way lot faster (read: RAD).

IMHO, using application framework (eg. MFC, OWL, VCL) is not a good way learn Windows programming from the start.

Share this post


Link to post
Share on other sites
The Win32 API is a bunch of C functions with very little
dependencies. Each function does a small task. This is kinda
the same approach OpenGL takes. This way, the API does not
enforce a specific application design.

The developer has to deal with handles and such stuff, but he
can still decide how to structure his application.

The MFC (Microsoft Foundation Classes) instead are a
framework
. The purpose of a framework is to make the use
of an API as simple as possible. Its purpose is also to
establish standards (like standardized dialog boxes,
standardized input behaviour, ...).

One more thing: A framework dictates the application design.
And that is where different opinions become an issue. Some
people like the fact that they don't have to think about
application structure and design. They just press a few buttons
in the class wizard and they get some already derived app and
window classes with standardized behaviour. Others hate the fact
that the framework takes away their freedom. They don't like
the overall design of the framework (even if they do like OOP).
They think that they might have done it better. Or they think
that it's way too bloated. Maybe they don't accept the imposed
overhead because they only need a small part of the
functionality the framework provides.

Well, it is obviously that this applies to every framework
and so it does to MFC. Nobody forces you to use MFC so
don't flame it. It was created with some good ideas in mind
(standardization, simplification, ...) and whether its actual
architecture is good or bad is a tough question. The MFC were
meant to provide an object-oriented framework to the Win32
skeleton API written in C but they were also designed to make
it easy for existing Win32 programmers to quickly become
familiar with the new framework. That's why the function resp.
method names are in most cases identical. And that's why
the framework does not really hide the "old" stuff (handles
and such).

If you ask me for an opinion: I don't really like the MFC
approach either. But working directly with the Win32 API can
only be justified when dealing with small and simple apps. I
sometimes use MFC because I don't see a real alternative. If
you want a more generic framework that hides more of the Win32
API stuff, you have to write your own wrapper or use one of
those freely available on the net. Most of them include support
for multiple platforms so you won't be restricted to Windows
only. If you instead like the MFC design and architecture
then use it of course and be happy with it. It does simplify
a lot of tasks, that's for sure.

If you need a windowing framework and - in case you need it -
what framework you should actually use depends on the project.
MFC should suffice in most cases...

[edited by - Origin on July 17, 2002 9:42:47 AM]

[edited by - Origin on July 17, 2002 9:44:18 AM]

Share this post


Link to post
Share on other sites
quote:
Original post by DerekSaw
IMHO, using application framework (eg. MFC, OWL, VCL) is not a good way learn Windows programming from the start.


I agree, I had used standard Win32 for a couple of years before using MFC, and I still use Win32 mostly. But I''ll use MFC for getting something complicated up quick. That way I have more time to actually work on the real task, instead of making sure the window is properly displaying, etc.

Share this post


Link to post
Share on other sites
It comes down to using the right tool for the job.

MFC is for quickly and easily creating windows applications, specifically document based ones. It works best with Visual Studio AppWizard and ClassWizard. It requires a certain way of structuring your program. If your target application does not fit these requirements, DO NOT USE MFC, else you will be frustrated beyond belief trying to do things differently than the MFC wants you to. It works great for what it was intended. Sure, there''s overhead, but with UI applications, as long as it responds within a half second, nobody cares.

If you want to do things differently, you''ll have to learn how to use the Win32 library directly. Games fall into this category, because you want complete control over everything.

Share this post


Link to post
Share on other sites
Ditto. I rarely need to use complex dialog boxes in my games, and when I do I almost always want them to have the same look as the rest of my game, so I handle it myself.
MFC is fine as long as you want your program to look like every other Windows program. Not to say that this is bad! It would certainly be helpful for a word processor or other business app, but in my experience games like to be "different".

Share this post


Link to post
Share on other sites
MFC is a not exactly a software engineering masterpiece or a shining example of good code. However, it does work (well, usually) and it does manage to make up for its bugs by saving a lot of development time. And yes, it does take time to learn, but as other people have said it isn''t too hard to learn MFC if you already understand C++ and Win32.

Most of the complaints about MFC come from three viewpoints:

1. People who don''t really understand how to program, so they couldn''t figure out how to do something. Then they bad-mouth MFC out of frustration.

2. People who hate Microsoft, so they trash anything produced by Microsoft just because...well, they do.

3. People who have studied the MFC source code and really do understand its problems.

Yes, MFC does have some rather annoying problems. And, of course, I fall into that third category of really knowledgeable people.

I don''t want to mislead anyone; despite its problems MFC is still quite useful.


quote:
Original post by daerid

dumbest thing I''ve heard all day


Somebody is seriously lacking a sense of humor, and it''s not me.

Share this post


Link to post
Share on other sites
WTL stands for the Windows Template Library. It''s some kind of alternative framework, similar in some respects to MFC, but as barazor said WTL doesn''t require any special DLLs and is generally a cleaner design. You should be able to find it on the Microsoft Download site somewhere by searching for "WTL".

Share this post


Link to post
Share on other sites
For my terrain editor I want a floating toolbar, consisting of many buttons each with a picture rather than text. When passing the cursor over, I want the bar at the bottom of the screen to say e.g "Paints current texture to map".
What is that last part called? Is this easy without MFC?

I have a big problem with the MSVC help, in that all the windows controls give MFC stuff when you look at them in the index. Bummer.

What exactly is classwizard? I tried using it in my win32 project and it blathered on about adding new classes when I created a dialog. What was the class it created for a button for exactly?


John 3:16

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
WTL is being phased out...
well anyway, porting between wtl and mfc(as a last resort) would probably not be too hard, since they are very similar

Share this post


Link to post
Share on other sites