MFC difficult!

Started by
10 comments, last by Tran Minh Quang 21 years, 5 months ago
Can anyone give me an advice to study MFC well? I found classess made me crazy all time and i can not know where should i start to study mfc. Thanks for your reply
Advertisement
I''m tempted to just write MSDN, but that''d be mean. The path I took to learning MFC was to start with scribble, then I looked at "Teach yourself visual C++ 5 in 24 hours". Now normally, I steer clear of those kinda books, but it was free (borrowed from a friend) and I was poor. Actually it''s pretty good (although a bit out of date by now) for just getting to grips with DOING stuff in MFC (building dialogs, menus, etc), and it covers pretty much everything you need to get started.

After that a very good book you might want to pick up is MFC Internals. It explains all the insides of MFC and how it relates to win32 SDK. It''s an interesting read, even though I don''t agree with all the authors principles (you SHOULD NOT need to look at the implemenatation of a class to use it, that''s the point of OO! and also you should NEVER rely on a sideeffect of a method). either way it does a good job of explaning each area of mfc and the reasons behind most of the design decisions (even the weird ones!!)
if you think programming is like sex, you probably haven't done much of either.-------------- - capn_midnight
Follow the Scribble step-by-step tutorial. Just read more on the CWinApp and CFrameWnd classes... and try to code a "Hello, world!" Windows app (not a dialog) in MFC without the Wizard. (hint: use CWinApp and CFrameWnd, and add msg handling for WM_PAINT)
"after many years of singularity, i'm still searching on the event horizon"
Here are the lecture notes from my Windows Programming instructor. They teach MFC, in what seems to be a fairly easy to understand way. At least, it''s working for me.

It should help you, at least by giving you another person''s idea of teaching it.

http://www.mathcs.sjsu.edu/faculty/beeson/courses/cs130/LectureNotes/



£§
£§
The "scribble" tutorial that comes with MFC is excellent.
Hi.

Okay, here is my MFC adventure.

I started out learning C++. C++ remains the only programming language I have learned and use. My goal has always been to develop programs for Windows. I knew at one point I will have to begin learning either MFC, Borland, Qt, or Win32 API. I remember posting messages asking members about MFC and Win32 API and trying to decide what I should start with. I decided on MFC because Win32 API was too difficult at the time.

My first venture with MFC began with Programming Windows with MFC Second Edition by Jeff Prosise. At first glance after I received that reference from Amazon was that MFC was way too complicated. Heck, there were too many lines of code I had no idea about, which I later learned were AppWizard and ClassWizard generated code. Anyways, I began reading Prosise''s book hoping to program Windows applications. I was wrong. I was could understand MFC enough to use the key concepts Prosise presents in the book. Approximately a month later I reached chapter 9, which is where Prosise introduces Doc/View architecture. I was excited because I knew that could be the breakthrough point where I will learn the tool to easily design and implement Windows applications.

Doc/View is easy because AppWizard generates a skeletal program that you can compile and run immediately. However as I soon found out, I still have to program all aspects of the program from text, menu, toolbar, buttons, windows, views, etc. The bottomline was that I was not ready to develop a Windows program. In fact, I was nowhere near that level of experience or even understanding of MFC to develop my first project.

At that point I lost confidence. I thought MFC was too difficult. I posted messages on boards asking members concepts about Doc/View that all MFC programmers must know. I thought of quiting. Then I decided to give MFC one more attempt because I saw that *MFC code was easy C++, it is the MFC generated code that really confused me*. I put Programming Windows with MFC Second Edition aside and bought Introduction to Programmng MFC with Visual C++ by Richard Jones. It was the wises decision and became an important reason I made a breakthrough with MFC.

Here is my advice:

- Start learning MFC via *Introduction to Programmng MFC with Visual C++ by Richard Jones* first

Richard Jones wrote an incredible introduction to MFC. He explains everything in a very concise, simple, and easy way to understand. His teaching technique is more effective to programmers of all levels because he explains and shows the transition from core C++ to MFC. You will see a gradual change from core C++ to MFC. That is one key element to learning MFC and Windows programming.

- Do all or as many exercises that from Introduction to Programmng MFC with Visual C++. Finish all exercises no matter how "stupid" or "tedious" you may think of them. The most important element to learning MFC as well as all real world programming including gaming, Win32 API, Winsock, and COM is *practice*. You have to programming!

Do not start out learning MFC via Programming Windows with MFC Second Edition by Jeff Prosise* Start out with Introduction to Programmng MFC with Visual C++ by Richard Jones first.

- Once you are done reading and doing all exercises from Jones'' book, start thinking about beginning your own projects. Remember, think big. Try to consider a project that involves many messages so you will gain experience with the way Windows handles messages. I recommend a text editor.

- Now you are ready for Programming Windows with MFC Second Edition by Jeff Prosise. It is an unparalleled MFC *reference*. You will at one point or another need to look up something from Prosise''s book. There are no exceptions! Buy it, read it, and keep it as a reference. In fact, I honestly feel that all MFC programmers should have a copy of it. It is to MFC as Programming Windows by Charles Petzold is to Win32 API.

Follow the steps above and with an open mind and desire to become a decent Windows MFC programmers, I believe you will master the fundamentals of MFC without three months or less. Again, you must practice. I highly recommend that you do all exercises from Jones'' book. I highly recommend that you start your own projects as soon as possible. One reason is when you start your own project, you will get an understanding of many MFC tools. You will gain experience. If you need help, post messages at forums. There are many experienced programmers that can and will help you. I recommend the following forums for programming:

C Board
CodeGuru
Code Project
GameDev Forums
MSDN Newsgroups

Do not lose hope. Have confidence and practice, practice, and practice!

Thanks,
Kuphryn
Okay, this might seem like putting a pot of petroleum dangerously close to fire, but could someone please sum up the pro''s (not the cons - I''ve already experienced some of those) of (using) MFC as opposed to either migrating to some higher level language (C# - note that I have very little experience with the language, and this is only my first impression), or doing the fun part themselves (building the "foundation" classes) - the functionality will most likely remain the same, but IMO the code would be a couple of hundred times less perpelexing (a very personal point of view). So - I call upon the advocates of MFC (just advocates - no flamers and other evil weasels) to really give MFC a meaning. I suppose I could run a search on the topic and come up with a godzillion of threads loaded with for and against arguments, but I''d just like to see the for arguments for now.

Note that I personally am a dedicated shunner of MFC, so my curiosity is simply directed at those who see the great potential in it - maybe someone can open my eyes...

Crispy
"Literally, it means that Bob is everything you can think of, but not dead; i.e., Bob is a purple-spotted, yellow-striped bumblebee/dragon/pterodactyl hybrid with a voracious addiction to Twix candy bars, but not dead."- kSquared
I learned win32 from msdn docs, then I moved to mfc but found it confusing since my c++ skills were nil. Then once I got up to speed with c++ oop I then tried mfc once again and this time it clicked. I used mfc docs in msdn + knowledge base articles and it worked for me. Mfc is trully great api once you get to know it. The vc++ mfc wizard is somewhat limiting and broken but lookup knowledge base articles how to get around the problems. I didn''t experience any bugs in mfc so far. There are also mfc sources in your vc6 folder. I used them to lookup and use some functions to manipulate filenames during open/saveas dlg boxes. One biggest problem with MFC is that you need to know the order of the api function calls(those calls the api makes on behalf of you), otherwise you''ll get incorrect parameter values. Take about two weeks off and study the mfc docs and it''ll start making sense. The scribble should be a starting app. Ofcourse it goes without saying that you should know win32 pretty well because you''ll be using it, since mfc doesn''t have all the necessary api functions that win32 has.


ForgEd3D world editor

I have limited experience in terms of Windows GUI tools using C++ other than MFC. Nonetheless, I believe MFC is powerful because Microsoft designed and implemented MFC using C++ and its OOP paradigm. Furthermore, MFC provide the flexibility of Win32 API integration. MFC is a powerful Windows GUI programming tool because it was designed and implemented by Microsoft, developed using and designed for C/C++, and it provides a foundation for extensibility in Windows GUI programming via Win32 API.

Kuphryn
I''ve used both Win32 and MFC and I''d say MFC has a number of pros vs. the Win32 API, in no particular order, here are a few:

1) A lot of documentation is available for MFC, it''s been around for a long time so there are lots of samples/help available on the web and books.

2) Saves time.

Sure you can write your own foundation library and use that, but if your goal is to write a GUI then you''re really just wasting time. The time it takes you to learn the win32 api to the degree that you can make your own, usable, foundation library you could have finished most of your application using MFC.

I admit that MFC can take a bit longer to get up and running than a simple win32 app, but once you have learned the basics and are familiar with the MFC design, it is easier to use.

3) Consistent behaviour. MFC is standard on windows, so if you use the MFC classes your app will behave as the user expects a windows app to behave.

4) Compared to higher languages, like C#, you have to advantage of not requiring everyone to have the .NET stuff installed. Practically no one other than developers has it, and people probably won''t until it comes standard with a Windows install.


So, I''m no MFC fanatic or anything, but it does have a number of distinct advantages that can make writing a windows GUI in C++ easier.

To keep on topic, I leanred MFC through the MFC book from Microsoft, but I was already familiar with Win32 through the Programming Windows95 book, so I''m not sure if it is a good place to start Windows programming from.

This topic is closed to new replies.

Advertisement