RegisterWindowMessage vs WM_USER

I read in the documentation that:
"Only use RegisterWindowMessage when more than one application must process
the same message. For sending private messages within a window class, an
application can use any integer in the range WM_USER through 0x7FFF. "

It seems much more convenient to use RegisterWindowMessage  even within the
same app as you can use it inside several dofferent classes and get the same
result for the same string without the classes having to know about each
other. OTOH if you use WM_USER the messaging ID must be known to all the
classes that use it by some form of include and that seems awkward.


What's the downside of using RegisterWindowMessage  within the same app?

Johnny



0
11/24/2004 8:07:33 AM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
1287 Views

Similar Articles

[PageSpeed] 34

Just what you need: check out  http://www.developerfusion.com/show/1713/2/ 
for an extensive article on that very subject by Joseph Newcomer

-Denny Brook

"Johnny" <removeThis.gbl_user99@hotmail.com> wrote in message 
news:vjXod.140227$bk1.79257@fed1read05...
>I read in the documentation that:
> "Only use RegisterWindowMessage when more than one application must 
> process
> the same message. For sending private messages within a window class, an
> application can use any integer in the range WM_USER through 0x7FFF. "
>
> It seems much more convenient to use RegisterWindowMessage  even within 
> the
> same app as you can use it inside several dofferent classes and get the 
> same
> result for the same string without the classes having to know about each
> other. OTOH if you use WM_USER the messaging ID must be known to all the
> classes that use it by some form of include and that seems awkward.
>
>
> What's the downside of using RegisterWindowMessage  within the same app?
>
> Johnny
>
>
> 


0
11/24/2004 7:48:17 PM
>It seems much more convenient to use RegisterWindowMessage  even within the
>same app as you can use it inside several dofferent classes and get the same
>result for the same string without the classes having to know about each
>other. OTOH if you use WM_USER the messaging ID must be known to all the
>classes that use it by some form of include and that seems awkward.

What's so awkward about a common header file containing the defined
value? Strikes me as more maintainable that having to maintain the use
of the same string in each file.

>What's the downside of using RegisterWindowMessage  within the same app?

It's an unnecessary overhead. The code to handle a fixed numerical
value is more efficient and easier.

Dave
-- 
MVP VC++ FAQ: http://www.mvps.org/vcfaq
0
davidl7375 (2060)
11/24/2004 8:10:58 PM
"David Lowndes" <davidl@example.invalid> wrote in message
news:pjp9q0hg5ra4m6tltfh35nomv0pq0qlplt@4ax.com...
>
> What's so awkward about a common header file containing the defined
> value? Strikes me as more maintainable that having to maintain the use
> of the same string in each file.

David, thanks for your reply. Can't say I understand how using the same
string in each file is less maintainable than using a similar label  in each
file plus a header reference, but YMMV. Seems about on a par to me. Same
amount of stuff to be changed if you change a label except one extra place
in the case of WM_USER But your point about overhead is well taken.
After having read JM's article on messaging linked to in the previous msg in
this thread I'm surprized that no-one has mentioned that WM_USER has been
deprecated by MS and that we should use WM_APP instead.



0
11/25/2004 4:34:10 AM
"Johnny" <removeThis.gbl_user99@hotmail.com> wrote in message
news:xhdpd.141674$bk1.38452@fed1read05...
> After having read JM's article on messaging linked to in the previous msg
in
> this thread I'm surprized that no-one has mentioned that WM_USER has been
> deprecated by MS and that we should use WM_APP instead.

WM_USER hasn't been deprecated by MS. It still serves the same purpose it
always has: "define private messages for use by private window classes".
WM_APP serves a different purpose.

-- 
Jeff Partch [VC++ MVP]



0
jeffp (1712)
11/25/2004 5:11:28 AM
"Jeff Partch [MVP]" <jeffp@mvps.org> wrote in message
news:#z0p50q0EHA.3900@TK2MSFTNGP10.phx.gbl...
> "Johnny" <removeThis.gbl_user99@hotmail.com> wrote in message
> news:xhdpd.141674$bk1.38452@fed1read05...
> > After having read JM's article on messaging linked to in the previous
msg
> in
> > this thread I'm surprized that no-one has mentioned that WM_USER has
been
> > deprecated by MS and that we should use WM_APP instead.
>
> WM_USER hasn't been deprecated by MS. It still serves the same purpose it
> always has: "define private messages for use by private window classes".
> WM_APP serves a different purpose.
>
perhaps I mis-stated that but not by much. Your argument is with Joseph
Newcomer not me...I'm just the messenger after reading his article
http://www.developerfusion.com/show/1713/2/

Johnny "Now If I could only stir up this much attention over that imagelist
showing cyan post ...."



0
11/25/2004 5:26:26 AM
Johny

a more recent note on the subject can be found here in the DiLascia/Partch
exchange in MSDN

rlf

"Johnny" <removeThis.gbl_user99@hotmail.com> wrote in message
news:x2epd.141693$bk1.14759@fed1read05...
>
> "Jeff Partch [MVP]" <jeffp@mvps.org> wrote in message
> news:#z0p50q0EHA.3900@TK2MSFTNGP10.phx.gbl...
> > "Johnny" <removeThis.gbl_user99@hotmail.com> wrote in message
> > news:xhdpd.141674$bk1.38452@fed1read05...
> > > After having read JM's article on messaging linked to in the previous
> msg
> > in
> > > this thread I'm surprized that no-one has mentioned that WM_USER has
> been
> > > deprecated by MS and that we should use WM_APP instead.
> >
> > WM_USER hasn't been deprecated by MS. It still serves the same purpose
it
> > always has: "define private messages for use by private window classes".
> > WM_APP serves a different purpose.
> >
> perhaps I mis-stated that but not by much. Your argument is with Joseph
> Newcomer not me...I'm just the messenger after reading his article
> http://www.developerfusion.com/show/1713/2/
>
> Johnny "Now If I could only stir up this much attention over that
imagelist
> showing cyan post ...."
>
>
>


0
rlfine8815 (162)
11/26/2004 1:39:03 AM
ooooops - forgot to paste the link

http://msdn.microsoft.com/msdnmag/issues/04/07/CQA/

rlf


"Roy Fine" <rlfine@twt.obfuscate.net> wrote in message
news:uf3mwn10EHA.4072@TK2MSFTNGP10.phx.gbl...
> Johny
>
> a more recent note on the subject can be found here in the DiLascia/Partch
> exchange in MSDN
>
> rlf
>
> "Johnny" <removeThis.gbl_user99@hotmail.com> wrote in message
> news:x2epd.141693$bk1.14759@fed1read05...
> >
> > "Jeff Partch [MVP]" <jeffp@mvps.org> wrote in message
> > news:#z0p50q0EHA.3900@TK2MSFTNGP10.phx.gbl...
> > > "Johnny" <removeThis.gbl_user99@hotmail.com> wrote in message
> > > news:xhdpd.141674$bk1.38452@fed1read05...
> > > > After having read JM's article on messaging linked to in the
previous
> > msg
> > > in
> > > > this thread I'm surprized that no-one has mentioned that WM_USER has
> > been
> > > > deprecated by MS and that we should use WM_APP instead.
> > >
> > > WM_USER hasn't been deprecated by MS. It still serves the same purpose
> it
> > > always has: "define private messages for use by private window
classes".
> > > WM_APP serves a different purpose.
> > >
> > perhaps I mis-stated that but not by much. Your argument is with Joseph
> > Newcomer not me...I'm just the messenger after reading his article
> > http://www.developerfusion.com/show/1713/2/
> >
> > Johnny "Now If I could only stir up this much attention over that
> imagelist
> > showing cyan post ...."
> >
> >
> >
>
>


0
rlfine8815 (162)
11/26/2004 1:48:05 AM
"Roy Fine" <rlfine@twt.obfuscate.net> wrote in message
news:en2Qzs10EHA.2884@TK2MSFTNGP11.phx.gbl...
> ooooops - forgot to paste the link
>
> http://msdn.microsoft.com/msdnmag/issues/04/07/CQA/
>
> > a more recent note on the subject can be found here in the
DiLascia/Partch
> > exchange in MSDN

Thanks for the link Roy. It's great that there is a diversity of viewpoint.
I note that WM_APP is not as "guaranteed" as it would seem as when looking
for the definition of WM_REFLECT came across the following inside
VC98\MFC\Include\AFXMSG_.H
#define WM_REFLECT_BASE 0xBC00
followed by a bunch more that are offset from that.
Although really high in the space, falls within 0x8000~0xC000 where it seems
it shouldn't be.
It may be that I'm using outdated files but the documentation that goes with
those clearly says
"Message numbers in the third range (0x8000 through 0xBFFF) are available
for application to use as private messages. Message in this range do not
conflict with system messages. "
So it must be that I am mistaken. Seems like these waters are still somewhat
murky.
Johnny


0
11/26/2004 3:46:11 AM
Reply:

Similar Artilces:

Decimal point vs comma
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) when entering normal numbers in cells using decimal point it will not autosum. by using a comma in place of decimal point no problem. i must have a setting wrong The "wrong setting" most likely is in your OS X System Preferences. Go to the 'Language & Text' Preferences & adjust your 'Region' and/or 'Numbers' formats. Excel will pick up on the changes when you next launch it. HTH |:>) Bob Jones [MVP] Office:Mac On 4/3/10 2:03 PM, in article 59bb66c1.-1@webcrossing.JaKI...

RegisterWindowMessage
Hi, I am sending windoew message from a c# application to c++(unmanage) application using this code System.UInt32 rm= RegisterWindowMessage("12345"); System.IntPtr ptr=(IntPtr)HWND_BROADCAST; PostMessage(ptr,(int)rm,5,5); PostMessage(ptr,WM_AAA,5,5); but the c++(vc-6 mfc) dont catch the message, when i use the RegisterWindowMessage("12345"); in the c++ application it return a diffrent number from that in the c# application why? Thanks. Don't use PostMessage for the broadcast: "You can also broadcast messages to all top-level windows by specifying HWND_BR...

purchase inhouse vs web hosting
For a small company ready to make a substantial investment in CRM, can someone lay out the basic pros and cons of considering webhosting for the applications and database, as opposed to bringing it inhouse on an company- owned server? I am assuming that if brought in house, I will still be purchasing help desk support in addition to having a fluent in-house administrator. Thank you. Usually when you elect to use a hosted solution, you have to go with a very standard offering, and are very restricted about the changes that you can make to the application to reflect requirements of yo...

Finder vs.Outbak.dll -- 2
.... FINDER caused an invalid page fault in module OUTBAK.DLL at 018f:01a65468 Also, when the .psf backup dialog box runs, a dos window runs in the background... Someone previously posted this - I have the same issue. Does anyone have a clue as to why this happens and how to correct it? Of course, there is nothing in the MS Lack of Knowledge Base! -- Message posted via http://www.officekb.com ...

Gainskeeper in M2K4 vs Captial Gains in M2K3
What value does Gainskeeper add to M2K4? I can check my Capital Gains via M2K3 and even do scenerio tasks. Thanks!! In microsoft.public.money, $2K3 User wrote: >What value does Gainskeeper add to M2K4? I can check my Capital Gains via >M2K3 and even do scenerio tasks. Money does not do wash sale recognition and handling. It handles the schedule D well for most people. ...

RegisterWindowMessage vs WM_USER
I read in the documentation that: "Only use RegisterWindowMessage when more than one application must process the same message. For sending private messages within a window class, an application can use any integer in the range WM_USER through 0x7FFF. " It seems much more convenient to use RegisterWindowMessage even within the same app as you can use it inside several dofferent classes and get the same result for the same string without the classes having to know about each other. OTOH if you use WM_USER the messaging ID must be known to all the classes that use it by some form of ...

Memory Table vs. CTE
I had posted a week or so ago about a performance issue with Null-able variables being passed into stored procedures and the performance gains by setting those parameters to local variables declared in the stored procedure. I followed that advice and all was well. How ever, the stored procedure started to time out the again, running the stored proc on my local SQL server would take 3:45 to return 5 rows. Something was wrong. The stored procedure was using 4 CTE tables, one of those tables being referenced in 5 different locations through-out the stored proc. The only change I made t...

mfc70d.dll in VS.NET 2003 problem
I have some MFC dll's which were compiled in VS.NET 2002. I am at present working in VS.NET 2003. I now need to use these dlls but whenever I try to run my app I get the following error. This application has failed to start because MFC70D.DLL. Re-installing the application may fix this problem. I really dont want to spend a whole day re-installing VS.NET 2003 !! Any ideas?? Hi, This means that your MFC DLLs where compiled and linked in DEBUG mode and when you load the DLL it is trying to open the VS.NET 2002 MFC DEBUG DLL. It's not asking you to reinstall VS.NET 2003, that&#...

Archive Settings for Inbox vs Subfolders
Can I set up one Archive setting for the main Inbox and different archive settings for its subfolders (those folders that were created under the Inbox)? I want ot delete all messages over 365 days old in the Inbox but archive those ove 365 in all of the subfolders. I want to make sure that Outlook will not delete those older messages in the subfolders. Thanks. Denny Riffert Yes. Right click on the folders and choose properties then a new archive setting. See http://www.slipstick.com/tutorials/auto/archive.htm if you need help doing it. -- Diane Poremsky [MVP - Outloo...

Double vs Decimal?
This is a spin off from the thread "Immediate Window: Annoying Notation?" It's a *really* big deal to me all-of-a-sudden bc it sounds like my current SOP might be at variance with good practice. Lotta years ago (JET 3.something) and for reasons not recollected I settled on Double as my data type of choice for big numbers with lots of decimal places. Now it's sounding like Decimal is the preferred vehicle, but I'm a little confused - no... make that a *lot* confused. If Decimal is so "right", how come VBA doesn't support it directly in the Dim statement...

Outlook 2000 VS Outlook 2003 Speed
Hi, I have found that outlook 2003 is much slower than outlook 2000 when it accessing the public folders. Anyone facing similar issue? Any tricks to overcome it? Thanks MWGP ...

Ending Cash Balance in Investment Transactions Register vs Cash Transactions #2
This subject is the same as a previous topic. There didn't seem to be a conclusion in the last discussion of this problem, so I decided to address it once again for those who may still be suffering from this issue. Nonetheless, it's probably worth it for you to read the previous discussion for additional background and context information. THE PROBLEM: In MS Money 2004, for whatever reason, some transactions are stored as Opening Balance transactions and they're hidden from the user such that the opening balance will always be greater than zero even when there are no transaction...

Reminder Time vs Due By Field
I'm using O2003. For a contact, there is the Due by Field. There is also a Reminder Time field. If you update the Due By field, it updates the Reminder Time field. However, if you update the Reminder Time field, it does not update the Due By field. By default for a contact, you have access to the Due By field. The Reminder field is avaialble, but you have to manually add it. In Tasks, it seems to work the same in that if you update the Due By field, it updates the Reminder Time field. However, if you update the Reminder Time field, it does not update the Due By field. However, you have a...

malloc() vs "new" vs HeapAlloc() vs ...
I'm implementing a "doubly" linked list data structure. My linked list will contain more than 300,000 nodes, so I'd like to conserve as much memory as possible. My list nodes will be C++ structures defined like this : typedef struct tagNode { int x, y; char c; NODE *next, *prev; } NODE; Alternatively, I could use a C++ object to implement this node. ie : class Node { public: int x, y; char c; Node *next, *prev; }; My questions are : 1) Which node type ...

Rules vs. Download Headers Only
I have a rule set to notify me when I receive a message from a specific person. I also have Outlook configured to download only emails of under 20k in size (to avoid huge download delays when picking up email in areas where I must access via a slow connection). Although the Header has been downloaded, and the rule is based only on header (From:) information, it still will not run until the message has been downloaded. The result is that I am not aware of arrival of important email from this person. Has anyone come up with a way to get rules to work on headers only? Thanks, Scott Ke...

scan source vs. tech data vs. bluestar
Which is better? Which one provides better pricing? What about better tech support? Shipping times and fees? Best product lineup? Best sales support? Which are you using and why? David Bluestar gives me amazing customer service. As long as they are competitive on pricing I will give them my business "dh" <dh@discussions.microsoft.com> wrote in message news:39E1D5CB-23D3-49FB-B9B8-BC855A75FB2D@microsoft.com... > Which is better? > Which one provides better pricing? > What about better tech support? > Shipping times and fees? > Best product lineup? > Bes...

Money 2004 vs. Quicken w/ Online
When using quicken, I downloaded transactions and Quicken would give me an ONLINE balance as well as the one that showed in the account register. Does Money ASSUME they are the same and just ignore the REAL balance form the bank? Thanks, Jeff No. Money shows the downloaded balance and the local balance. These may or may not be equal at any qiven time. It also depends on whether the institution actually includes the balance in the download. Regards, John Buschman "Jeff" <joedirt@datahook.com> wrote in message news:<evA2fWWSEHA.556@tk2msftngp13.phx.gbl>... > ...

Bill
Hello, I have a recurring payment in the Bills section set up for my mortgage payment. The amount of the escrow payment increased recently, so I attempted to change the amount. I'm not sure what I did, but now when I double-click on the recurring payment, instead of a "Record payment" window, I get an "add transaction" window, and when I add the transaction, the due date on the Bills page does not roll to the next payment date. Does anybody have any idea how I can fix this? Thank you. ...

Vlookup or Other vs Sort?
Excel 2003 ... What I have Range A4:A103 ... ascending values 1, 2, 3, to 100 Range B4:J103 ... unique line-item records Range K4:K5003 ... ascending values 1, 2, 3, to 100 (each repeat 50 times) Range L4:T5003 ... I need a formula to return each of the line-item records contained in Range B4:J103 (each 50 times) I am using a VLOOKUP formula with a chg to return Col only, but I am having the following issues: =VLOOKUP($K4,$A$3:$J$5003,4,0) ... returns "0" when an empty cell is found (I do not wish to see a "0" ... I want an empty cell) ... so I start...

Contacts vs Personal Address Book. Can't pull emails into TO fiel
Howdy, I'm using Outlook 2k3 and having a slight problem. WHen I view my Contact list in the main view, I have two sets (not sure why but I'll be combining them). These lists have standard name, email, etc. Problem is when I go to create a new email message and click the TO: button, it tries to look for my Personal Address Book which I don't have. How can I make it not use the PAB and use the Contacts list instead? Thanks. OK, I think I just stumbled on the issue. For some reason on my COntacts Properties, the check box to tell Outlook to use that in the Address Book ...

ByVal vs ByRef when generating tree
I have a tree data structure in xml. I currently use ByVal and recursion to draw the tree. My understanding is that each time I pass the child node to the recursive function, it creates a copy of the node containing items at the point and all subitems. I'm wondering it it would make a lot of difference in memory usage if I pass the child node by ref. teddybear schrieb: > I have a tree data structure in xml. I currently use ByVal and > recursion to draw the tree. My understanding is that each time I pass > the child node to the recursive function, it creates a copy of the...

Sharing system view to Users vs Views on Mobile
Hi, As i notice in system view, we can only share it to the team. Is it possible that it's also being shared to certain user? The workaround that i can think of is to add view on each of the user page manually. Since i am also using mobile express, if i create view for user manually, as i believe, this view is not available. Only System view will be available. Is there a better solution? Carrie ...

VS 2010 and VS 2008
Just spent a happy Sunday morning installing VS 2010. Plus point: it found one syntax error in my several thousand .cpp files which VS 2008 missed. Problems: one or two minor ones not yet resolved. Is there any reason why a resource only DLL compiled with VS2008 should not work properly with a program compiled with VS2010 ? What about other non-MFC DLLs with a pure C interface? Dave -- David Webber Mozart Music Software http://www.mozart.co.uk For discussion and support see http://www.mozart.co.uk/mozartists/mailinglist.htm >Is there any reason why a resource ...

Compatibility issues with macros (2000 vs. 2003)?
Customers are reporting issues when sending documents created in Excel 2003 to those with 2000. They are unable to use the macros. It is not an issue of security settings--all are set to medium. A user said they heard there was a way to create a macro in 2003 that is "saved as" 2000. Aside from issues with features in 2003 not in 2000, does anyone have any knowledge or experience with this issue? Thanks, Lori Hi Lori, I also have some customers whose 2003 macros error out on 2000 machines. For me it has always been an issue revolving around 2003 features not in 2000. Th...

Object Store vs RAM disk
Hello, what are the main differences between Object Store and RAM disk ? They are both in RAM...are there performance differences ? access differences ? Thanks, Paolo -- Paolo Patierno Embedded Software Engineer ...