Fog Creek Software
Discussion Board




MFC Annoyance

I've been happily programming in C++ for several years without having to learn MFC. Until now. So, I got a copy of Jeff Prosise's "Programming Windows with MFC" and started working through the samples.

Typically, the first sample program in each chapter will give a step by step walkthrough, then the remaining samples will just show the code, assuming you can figure it out. Fine. I code these using the wizards and hand coding.

But once I got to the dialogs chapter, my samples won't execute. I've checked my code versus the sample code (provided on CD) using windiff, and all the .cpp and .h files match. I also verified that all my controls had the same names as the ones in the sample code. I even double checked that the sample code would compile and run correctly, which it did.

So I'm at a loss. If all the code matches, why won't it run? Are their VC++ 6.0 IDE settings that I should be aware of that would effect the operation? Any tips.

Thanks.

The MF in MFC
Friday, September 19, 2003

Im a VFP user so I have no idea, but aren't the C++ Include search directories set per workspace in VC++ 6?

Chris
Friday, September 19, 2003

It would certainly help if you described what happens when you try to run them...

Andy
Friday, September 19, 2003

how about *.rc , StdAfx.h etc
?

Nekto
Friday, September 19, 2003

There are certainly build settings that need to be correct, you must have the right libraries included for a start. But without knowing how it fails we can offer no useful advice.

Mr Jack
Friday, September 19, 2003

MFC is sooooo 90's.

Rick
Friday, September 19, 2003

Crack open your resource editor an dmake sure all of the IDs (or rather the ID_MYEDIT type names) of the dialog and its controls in your dialog resource match what the code is expecting, and that each ID is #defined to a unique number in your resource.h.  The resources live in the .rc file, which is just a text file so it can be diffed against the sample code.

If the problem is some compiler setting, those live in the project file (.dsp in VC6 and earlier)  which is also just a text file. 

Keith Wright
Friday, September 19, 2003

All the files matched exactly - including the stdafx.h and *.rc. I couldn't find any differences in the project settings either.  That was the frustrating part - everything matched.

I finally did figure out what the problem was, though. Earlier, I had made some changes to the resource symbol values in the resource.h file.  But when I recompiled, the IDE didn't detect the changes. I had to do a Clean, then re-compiled, and everything worked fine.

The MF in MFC
Friday, September 19, 2003

Visual Studio using MFC has one file that is its nastiest most evil file.  It is the .aps file.  It is a cache of the .rc.  Visual Studio seems to have trouble figuring out when the .aps is not current, and I think maybe I've heard that sometimes it overwrites your real files with what it has errantly in cache (though maybe I missheard that part).  Behaves particularly badly when you are doing source control, and multiple developers.  it might have been the source of your troubles.

Keith Wright
Friday, September 19, 2003

I have been using MFC for more than 5 years 8-12 hours per day now. Overall, it is a fantastic way to get desktop apps done quickly and relatively easily.

BUT, you will run into these kinds of issues from time to time. The good news is that once you solve them a few times they are usually pretty quick to identify and correct. It is really just a matter of getting used to some of the quirky ways that MSVC++ works and then working within the system. Leter you will learn how to bypass and hack the system, but I digress...

If you have any simple MFC getting started questions, feel free to send me an email (click on my name below). I have learned from a lot of other developers over the years and am happy to try and help where I can...

There ain't nothin that I don't know about CString... ;)

Have a good weekend.

- Brett

Brett Kapilik
Friday, September 19, 2003

Thanks Brett. For now just pointing me to a good VC++ forum would be helpful.

Thje
Friday, September 19, 2003

Accidentally hit the Enter key when correcting "Thje"

The MF in MFC
Friday, September 19, 2003

*  Recent Topics

*  Fog Creek Home