WindowProc.
If there is another way. Why can't I use the old way of trapping the
"Allan" <mmress@hotmail.com> wrote in message
news:uRuEXqYqHHA.1220@TK2MSFTNGP04.phx.gbl...
I am just learning VS6 functionality for VS2005. VS6 there is a
classwizard, but not in VS2005.
Besides WindowProc, there are also alot of other handlers I need to use
too.
You probably do not need to add a general window procedure - just
OnThisThatAndTheOther() for various messages. Briefly:
1. Create the dialogue template: in the resource view add the
dialogue
to the .rc file. Edit the temlate by adding controls.
2. Right click on the template, and use "Add class". If you call it
CMyDialog this will generate files (by default) MyDialog.h and
MyDialog.cpp.
3. Click on the caption bar so the whole dialogue is selected. Right
click on it, and select properties. In the properties window, you
can
add various member functions to handle messages. The only subtlety is
that there are two kinds: (1) "messages" which add an entry into the
message map - typically these are obtained from a list of messages like
WM_CLOSE etc. (2) "overrides" which add a virtual member corresponding
to
one in CDialog - like OnInitDialog(). Icons at the top of the
properties
window let you see the two lists.
4. For each control: Click on the control to select it. then right
click
on it and use "Add variable". In the ensuing dialogue: choose whether
to add a control variable (like CButton for a button) or a data variable
(like CString for a static). Give it a name.
5. For each control: Click on the control to select it. then right
click
on it and use "Add handler". This will add an On...() command handler
to your CMyDialog.
In MFC the window procedure is a complicated thing which just makes sure
all the mesages can be handled by the various message handlers that you
can add or override in this way. I have never needed to change it for
any CDialog derived class in the dozen years or more I have been using
MFC, and I don't envisage ever having to. [Though I have very
ocasionally
found use for some of the more subtle ways of using it like the
DefWindowProc() function.]
Oh, and if you open MyDialog.h and puit the caret on the CMyDialog
definition, you can right click and do "properties" and add more things
to
the class from there too.
And another thing: VS2005 manages to do without all the {{{AFXCOMMENT
stuff in CMyDialog.h which used to be there in VS6. This is good as you
can't break it by deleting a comment! But it does mean that it can
add
stuff all over the place within the dialogue definition and "public"s
and
"protected"s will mushroom without limit. This leaves me with a
frequent,
overriding, and utterly draconian desire to tidy the stuff up. So I do
it. But then I never liked the order Microsoft used anyway, and I always
deleted comments like "// Overrides:" (because I can see an override by
the dirty great big "virtual" in front of its name). You still get
afx_msg (which IIRC is #defined to nothing with an enigmatic and
foreboding comment like "intentional placeholder") but I leave them
there
as a "this is a message handler" label.)
[A lot of people miss the VS6 wizard, but I have now got used to the
"properties" way of doing things. The only thing which I *hate* is
that
every time I add a control handler it switches to the C++ so that I can
add code, when often as not I want to add lots of control handlers and
only then edit the code.]
Hope this gets you started,
Dave
--
David Webber
Author of 'Mozart the Music Processor'
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm