Woah, let's just stop and think here...
First of all, Windows itself sends messages in the WM_USER+n
range, that's why WM_APP
was invented (I found this out the hard way). But it gets worse... there's nothing to stop badly behaved applications broadcasting WM_USER+n
or WM_APP+n
messages, and because human beings stole the crystal of infinite stupidity from the Gods, this does indeed happen in the real world.
So, repeat after me, the only safe message is one I define myself and can only see myself. Use RegisterWindowMessage. And even then, be untrusting. When I need a string to define a RegisterWindowMessage, I use GUIDGEN to create the string and put a human-readable app-specific prefix on the resulting gobbledygook. Because guess how many lazy programmers registered their message using "WM_MYMESSAGE" as the name... and then decided that broadcasting it would be a cool idea?
Bet on the stupidity of your fellow humans - it's always a winning bet.
If you want authoritative background on this whole topic, see here. No that's not my website, it's Joe Newcomer's.