Re: MFC and c++ problems
- From: "Tom Serface" <tserface@xxxxxxx>
- Date: Sat, 4 Feb 2006 17:10:56 -0800
Hi Doug,
I would think the parent would define which messages the child could send
and then the child would use those messages. Isn't this how most of the
controls on a dialog work?
Tom
"Doug Harrison [MVP]" <dsh@xxxxxxxx> wrote in message
news:9u0au197q2vbg2rk33ot0o7g16ko0pg7ad@xxxxxxxxxx
The thing about SendMessage is that it's not type-safe, and the target
window has to agree to interpret the number identified by WM_WHATEVER the
same way as the sender. Now, if it isn't a standard message, and the
target
window didn't define the message itself, and you didn't design the classes
to work together, then you have to use RegisterWindowMessage to negotiate
a
message you can both agree on. Using "interfaces" as suggested elsewhere
in
this thread solves these problems. A more general approach is exemplified
by the .NET event facility, in which objects interested in an event
register themselves with the object that generates the event; this is an
implementation of the Observer pattern. In C++, the primary (legitimate)
reason to use Windows messages instead of an OOP approach is to enable use
of the window from other languages. A secondary (not so legitimate) reason
is that it's quicker (and dirtier), especially when you're designing the
window classes together and can set up a common header file that defines
the message they'll both use.
--
Doug Harrison
Visual C++ MVP
.
- Follow-Ups:
- Re: MFC and c++ problems
- From: Doug Harrison [MVP]
- Re: MFC and c++ problems
- From: Joseph M . Newcomer
- Re: MFC and c++ problems
- References:
- MFC and c++ problems
- From: Benry
- Re: MFC and c++ problems
- From: Joseph M . Newcomer
- Re: MFC and c++ problems
- From: Ajay Kalra
- Re: MFC and c++ problems
- From: Joseph M . Newcomer
- Re: MFC and c++ problems
- From: Daniel James
- Re: MFC and c++ problems
- From: Benry
- Re: MFC and c++ problems
- From: Doug Harrison [MVP]
- MFC and c++ problems
- Prev by Date: Re: MFC and c++ problems
- Next by Date: Re: Button rectangle should not be displayed when it is clicked
- Previous by thread: Re: MFC and c++ problems
- Next by thread: Re: MFC and c++ problems
- Index(es):