Re: Homework question relating to docview
"Doug Harrison [MVP]" <dsh@mvps.org> wrote in message
news:nn1e9357kotpa66mogmcc8m7c2uojce7jt@4ax.com...
"Message handler" and "virtual" aren't mutually exclusive. That said,
those
functions aren't message handlers but are instead called from various
message handlers as part of the open/save procedures. A major problem with
normal (non-virtual) message handlers is getting polymorphic behavior out
of them; you have to use SendMessage or PostMessage, which is clumsy and
error-prone. Functions that are intended to be overridden and called from
many places are best expressed as virtual functions, which of course can
be
called from message handlers.
Well, I never thought of this as a problem because e.g. if I handle
WM_ERASEBACKGND, in that handler, I've always been able to call
CBaseClass::OnEraseBkgnd() and did not have to resort to SendMessage(). I
don't exactly know what magic makes that work.
If you want to find the actual message
handlers, search for ID_FILE_SAVE and ID_FILE_OPEN. You'll find the UI is
done outside of the CDocument functions you quoted, which are essentially
the customizable, non-UI guts of the open/save procedures.
Found them, thanks. :-) So I guess the AppWizard wires those commands
(e.g. from menubar and toolbar) to the CDocument handlers when the project
is created. Neat.
-- David