Re: Difference between WM_APP and WM_USER
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Sat, 03 Jun 2006 02:00:28 -0400
Both are risky to use. WM_USER range messages are used for a lot of purposes by
Microsoft, so it results in all sorts of nasty conflicts if you try to use it for some
other purpose. For example, I had for some years used WM_USER and WM_USER+1 as messages,
which I'd send to child dialogs (I just started numbering them at WM_USER, as suggested by
Petzold). But when I started coding in MFC, I discovered that MFC uses WM_USER and
WM_USER+1 as internal messages to CDialog classes. Oops (that problem took many hours to
discover). Sometimes you want to "broadcast" a message to child windows using
SendMessageToDescendants, and you can't be sure when you're going to hit some control that
uses WM_USER-based messages for its own purposes.
Now you can use WM_APP, but this has a serious "modularity" problem. Suppose you write a
DLL that uses WM_APP+7 as a message to a designated window. Suppose I write a DLL that
uses WM_APP+7 as a message to a designated window. Now suppose some poor programmer wants
to use both of our DLLs in an application, both called from the same window which needs a
target. The problem is that this programmer doesn't see WM_APP+7 as the value; what the
programmer sees is "UWM_MY_NOTIFICATION" and "UWM_YOUR_DATA_READY" as messages. Big
whoops. (No, don't say it won't happen or can't happen. It has. It's happened to me
several times). This is why I gave up entirely some years ago and use only Registered
Window Messages with a GUID in the name. It is the Only Safe Way To Avoid Future
Disaster.
See my essay on Message Management on my MVP Tips site.
joe
On 2 Jun 2006 14:12:24 -0700, nicetom786@xxxxxxxxx wrote:
What is the difference between WM_APP and WM_USER ?Joseph M. Newcomer [MVP]
What is for each used?
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: Difference between WM_APP and WM_USER
- From: Jeff Partch [MVP]
- Re: Difference between WM_APP and WM_USER
- References:
- Difference between WM_APP and WM_USER
- From: nicetom786
- Difference between WM_APP and WM_USER
- Prev by Date: Re: delete *this possible?
- Next by Date: Re: Transparent Radio Button
- Previous by thread: Re: Difference between WM_APP and WM_USER
- Next by thread: Re: Difference between WM_APP and WM_USER
- Index(es):