From: somebody on
"Oliver Regenfelder" <oliver.regenfelder(a)gmx.at> wrote in message
news:b1e6a$4c1a0df2$54774ba2$18408(a)news.inode.at...
> Hello,
>
> Bubba wrote:
>> we were given short note for doing a project on college (two days ago,
>> due is on Monday), that is related to OOP, or to be exact, MFC library.
>> Unfortunately, we were given literally no documentation, so it's free for
>> all.
>
> As somebody already mentioned try to get
> Jeff Prosise 'Programming Windows with MFC'
> it will help.
>
> Also, this is some university assignment so I think they won't make a code
> review and you can ditch a lot of the normally needed error code checking
> error handling stuff and just pray that things work. Although, don't make
> it a bad habbit!
>

Oh, trust me; on that university they will make a code review more than
once.

When I was there, an extra variable in the code which was not necessary,
because you might have used some other previously declared usually resulted
in massive brain fu**ing and sometimes even in failing. Even if some new
people are there these days, they will definitely look at some part of the
code.


From: Joseph M. Newcomer on
See below...
On 17 Jun 2010 07:56:15 GMT, Bubba <nickname(a)banelli.biz.invalid> wrote:

>Joseph M. Newcomer's log on stardate 16 lip 2010
>
>>>we were given short note for doing a project on college (two days
>>>ago, due is on Monday), that is related to OOP, or to be exact, MFC
>>>library. Unfortunately, we were given literally no documentation, so
>>>it's free for all.
>> ****
>> Actually, you have thousands of pages of documentation. Which is
>> almost worse than having none at all. It comes with your compiler.
>> ****
>
>Of course, my remark about lack of documentation was displaced.
>Essentially, my remark was rather aimed at lack of "Hello world" type of
>documentation...
>
>>>Basically, I have to create application with at least two forms or
>>>dialogues. Application has to be able to show persons in a list, and
>>>that those persons can be sorted by name or surname. They can also be
>>>sorted by city or address, but then we have to use tree control.
>> ****
>> Sounds to me like a candiate for a dialog-based app. Fortunately,
>> these are the easiest ones to write. But tossing an assignment like
>> this at a student seems to be gratuitous sadism on the part of the
>> instructor. I usually spend a couple hours showing my students how
>> to create basic dialog-based apps. It is not trivial to get into,
>> and OO programming is a tiny, tiny part of what is going on.
>
>The course itself is so poorly organized that, as I've mentioned in few
>posts before. Hey, only few of our computers support MFC properly. Some
>can't even run Visual Studio. :)
>
>> First, I consider this assignment grossly unfair. As someone who has
>> taught and sometimes continues to teach it, I would consider an
>> assignment like this that did not include in-class demonstrations of
>> how to build an app to be impossible. You can convey this to your
>> instructor for what little good it would do. Other than annoying
>> him/her.
>
>Gladly, but with no effect, as you have well presumed. Course is just
>poorly organized and there is no particular wish to improve it.
>
>> Second, build a simple dialog-based app. Problem here is you have to
>> learn a WHOLE LOT about edit controls, push buttons, list controls,
>> etc. before you can begin to make sense of this, and that is a LOT to
>> do in a single assignment without training! I'd never give an
>> assignment this complex in my classes, and we spend about 30 hours
>> just in lectures about how to use MFC. So your problem is NOT just
>> "building a dialog" but understanding the sublties of a bunch of
>> controls ALL AT ONCE.
>
>Forgive me, but I have to use standard new-kids term - "I LOL'd".
>
>30 hours?! We spent approximately 6 hours, from which we actually did
>something (the ones who were happy enough to make Visual Studio work)
>for perhaps half of that time. Evidently, insufficient, but thanks for
>the reality slap.
>
>> Note: I learned MFC by doing the Scribble tutorial and it took me
>> about three days to get competent, and I was *already* a Windows
>> programmer and knew all about the controls!
>
>Unfortunately, my point of interest is low level programming and C. I'll
>do my best to catch something up in these few days...
>
>> It then took me two years to become an MFC "expert".
>
>I am generally not interested in GUI frameworks, but with proper
>training, I believe not only myself but my colleagues would be
>interested in harnessing MFC.
****
In my Systems Programming course, I do one MFC example, a dialog-based app. It takes
about 20 minuts to set up the basic infrastructure, after which the students then spend a
couple hours spawning a child process and sucking its stdout back over a pipe and
displaying it. I do this so they can see that you can construct a simple dialog-based app
very quickly. I built the same app in under 5 minutes for the GUI (the 20 minutes is so a
group of 6-10 students can keep up with the task and each other) and under 20 minutes for
all the rest, but I'd done it before in other contexts. But the key is that with a bit of
guidance, you can build a simple dialog-based app with simple controls very quickly.
CListCtrl and CTreeCtrl are *not* "simple controls".
****
>
>> Dialogs are easy. Controls are not hard, there's just a LOT to learn
>> about them before you can use them well. You have every right to
>> feel overwhelmed, and I don't have much advice except to buckle down
>> and try the Scribble tutorial. It's the only thing out there that
>> can give you half a chance!
>
>Tell me, I got the impression you are/were holding classes regarding MFC
>- do you happen to have slides/books/material from which your students
>were learning from (of course, if they are freely available)?
***
No, I do a live demo and they follow along. The slides are very sketchy, and because of
my arrangement with the company I teach for, they cannot be published in electronic form.

The slides are mostly intended to remind them of the live demo by capturing the
highlights, and are not useful without the demo. But your problem is sufficiently complex
that I couldn't even teach it over the newgroup. I could do most of the GUI in under 10
minutes (except for the coding of the actual actions) and probably in under a half-hour if
I were demoing it live.

Mostly, what you do is create a dialog-based app. Then, on the dialog, you plunk down the
controls you want, and add some handlers (usually OnBnClicked handlers for the buttons).
You bind the controls (e.g., the edit controls) to control variables, and use functions
like GetWindowText to retrieve the contents of the edit controls, and that's it. To sort,
you decide what field you are sorting on, and make sure the LPARAM of the list control
entry holds that information (you might have it point to a single string, or you might
point it to a class that holds a pair of strings; key is that the sort handler for a
CListCtrl gets only the LPARAM pointers for the two entries to compare). The rest of the
details are window dressing (or, as a British friend of mine characterizes it, "tarting it
up").
joe

>
>Thank you for your copious post. Best regards!
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Joseph M. Newcomer on
See below...
On Thu, 17 Jun 2010 11:30:54 +0200, "somebody" <name(a)gmail.con> wrote:

>
>"Bubba" <nickname(a)banelli.biz.invalid> wrote in message
>news:Xns9D99AF8B4181Cbubbachipsetone(a)130.133.4.11...
>> Greetings,
>>
>> we were given short note for doing a project on college (two days ago, due
>> is on Monday), that is related to OOP, or to be exact, MFC library.
>> Unfortunately, we were given literally no documentation, so it's free for
>> all.
>>
>> Basically, I have to create application with at least two forms or
>> dialogues. Application has to be able to show persons in a list, and that
>> those persons can be sorted by name or surname. They can also be sorted by
>> city or address, but then we have to use tree control.
>>
>> Person can be removed, added or changed. Each person can get indefinite
>> telephone numbers and previous addressee. It also must be possible to save
>> data when exiting the application and loading them afterwards.
>>
>> I did some Googleing and got books, but none seems to have systematic for
>> my problem, in other words, they seem to be to vast in handling the
>> subject, so I'd like to know what's the best way to start doing this type
>> of application.
>>
>
>
>MSDN and Google should be enough for a start. Although there are books like
>Jeff Prosise's Programming Windows with MFC, it will not teach you more than
>an MSDN or any of the examples found by googling.
>
>
>
>Joseph tends to show MFC as something extremely complicated, which is not.
>While I was a kid I created mu first MFC application in a few hours and I
>don't find my intellectual capabilities above average. That doesn't mean
>that I learned entire MFC in a few hours. The OP has no need to learn more
>than necessary just to deliver this Address book assignment. He doesn't need
>to know all the details on CEdit or CTreeCtrl for example. He can do it
>later if he wants/needs to.
****
Most of my essays deal with seriously subtle issues about MFC usage. I teach "enough MFC
to build a simple dialog app" in about 20 minutes. But understanding comes later. But
they key here is that without SOME training in MFC basics, there is no obvious way to pick
it up (I've taught classes to people who couldn't understand why they needed training,
because they "knew" MFC, and they found that it is much more complex than they actually
thought).
joe
****
>
>
>
>Once you become familiar with MFC basics, you might dive behind the scene to
>see how it works. This part is slightly complicated, but nothing to be
>afraid of.
>
>
>
>If you are writing that "Address book" application, since you are in Zagreb,
>post a message at hr.comp.programiranje too when you hit the wall. :-)
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: David Ching on
"Bubba" <nickname(a)banelli.biz.invalid> wrote in message
news:Xns9D99AF8B4181Cbubbachipsetone(a)130.133.4.11...
> Greetings,
>
> Basically, I have to create application with at least two forms or
> dialogues. Application has to be able to show persons in a list, and that
> those persons can be sorted by name or surname. They can also be sorted by
> city or address, but then we have to use tree control.
>

As said, using a ListView control (which allows multiple columns like a
spreadsheet) is more complex than a simple ListBox control which does not.
But maybe you can use a ListBox showing just the first+last names of each
person, one per line. If the list is sorted by surname, repaint the list to
show each person as last+first instead.

So the first form can be a simple dialog containing this ListBox and buttons
to Add/Remove/Change the selected person.


> Person can be removed, added or changed. Each person can get indefinite
> telephone numbers and previous addressee.

When a person is added or changed, the second dialog appears (using
DoModal()). This dialog has fields for First name, Last name, and again
ListBoxes for Telephone and Previous Addresses. Next to these list boxes
are Add/Remove/Change buttons which bring up a 3rd dialog to edit them (in
the same manner as the second dialog).


> It also must be possible to save
> data when exiting the application and loading them afterwards.
>

My first thought is to use the simple and excellent CMarkup XML parser from
CodeProject to save/load the persons as XML. But this takes a bit to
understand. I haven't tried MFC serialization, maybe this is easier and
will suffice for this requirement (even though I would not recommend MFC
serialization for a shipping app due to versioning concerns and other weird
problems.)


> I did some Googleing and got books, but none seems to have systematic for
> my problem, in other words, they seem to be to vast in handling the
> subject, so I'd like to know what's the best way to start doing this type
> of application.
>

To get started quickly, try to find some good tutorial videos. You need to
find ready made solutions here and not some deep discourse into the history
and background of MFC and which takes 2 days to write Hello World. Start
with http://msdn.microsoft.com/en-us/visualc/bb931339.aspx

Good luck,
David

From: Goran on
On Jun 17, 1:39 pm, Bubba <nickn...(a)banelli.biz.invalid> wrote:
>But, as I've said, *my* preference is still "pure" C. :)

Combined with your expressed interest in systems programming, I
certainly hope that's not because Torvalds dislikes C++ ;-). 'cause
when he speaks about it, he's either exaggerating or outright lying.
And that's a sign of fear, not conviction.

Goran.