C++/VB - Making userdefined messages like WM_PAINT or WM_QUIT

Asked By Faisal
08-Feb-10 04:43 AM
Raymond Chen's blog says, messages like WM_PAINT, WM_QUIT messages are
treated in special way.
http://blogs.msdn.com/oldnewthing/archive/2005/11/04/489028.aspx

ie, even if more than one message is posted, system combines the
messages only once the windowprocedure is called.
I need this behaviour for a WM_APP or registered message. Is it
possible?
SendMessage
(1)
PeekMessage
(1)
GetMessage
(1)
OnIdle
(1)
Newcomer
(1)
Raymond
(1)
Windowprocedure
(1)
Timers
(1)
  David Lowndes replied to Faisal
08-Feb-10 05:21 AM
You'd need to roll it yourself - use PeekMessage to filter for your
specific message.

Dave
  Goran replied to Faisal
08-Feb-10 09:56 AM
04/489028.aspx

As David said, you can roll your own easily and I do not know of any
mechanics supported by the system either.

That said... it is a strange question. It seems to me that you are not
asking with an explanation of a problem, but with an explanation of a
solution. That's usually a wrong way to ask. What exactly are you
trying to do? If you explain your problem, someone could help much
better.

And finally, could it be that some OnIdle scheme could work for your
case, did you consider that?

Goran.
  Joseph M. Newcomer replied to Goran
08-Feb-10 11:35 AM
See below...

****
I agree.  This is another "How do I implement this solution?" instead of "How do I solve
this problem?" question.

The answer is: you cannot implement this solution.  Don't even waste time trying.

BUT: if you state your problem, there might be a half-dozen different ways of handling it
effectively.  We would have to know what kind of information you want to combine and the
specification of what "combine" means.

THe OnIdle suggestion below is one of the many ways you can tackle this.  There are
others.  Questions include whether or not these messages are created in a single thread or
in multiple threads, and sent via SendMessage or PostMessage.

Note that WM_PAINT is not an official message, and in fact they are not "combined".  What
is combined is the collection of invalidated regions in your client area; when the
WM_PAINT is eventually generated it reports the clipping region as the union of all
invalidated regions.  This is only because the creation of the message is deferred.  In
your case, you either have to come up with a way of deferring the message, or a way of
joe
****
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
  Joseph M. Newcomer replied to Joseph M. Newcomer
08-Feb-10 01:16 PM
Just a clarification: I said WM_PAINT is not an official message.  This means it NEVER,
EVER appears in the message queue; it is never sent via SendMessage or PostMessage.  It is
an entirely synthetic message, created whenever the low-level GetMessage handler feels
like it, specifically, it feels like it if there are no other messages in the queue and
there are no timers pending.
joe


Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
Create New Account
help
8301-13860_3-20004109-56.htm Mike P VC MFC Discussions Microsoft Exchange (1) Joseph M. Newcomer (1) Windows 7 (1) Outlook (1) Python (1) Oracle (1) Perl (1) NNTP newsgroups (1 days). Anyone who demands to use their Web site it is sick. joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm site, and only a moron would use it to replace a simple joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm any adult supervision is not a good combination for producing quality interfaces. joe * ** Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm we see is not afraid to subject end users to gratuitous complexity! joe * ** ** Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder
do you put "C" in front of it? VC MFC Discussions Joseph M. Joseph M. Newcomer (1) Dave David Webber Mozart Music Software (1) Joseph M. Newcomer (1) Research (1) Oracle (1) Boolean (1) Macros (1) OFFSET (1) If you think they else's guidelines and following them blindly is probably a bad idea. joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm specified?" which is not the same as "what standards should I adopt?" joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm may be totally incompetent, but I am no longer entitled to complain!) joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm
AND_CATCH \ n"); E + = szErrMsg; AfxMessageBox( E ); VC MFC Discussions FileNotFoundException (1) PowerPoint (1) Joseph M. Newcomer (1) Office (1) Error (1) MatchCollection (1) GetErrorString (1) StreamWriter (1) See below. . . * ** * You should does whatever it does. The next release might do something completely different! joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm will put this in a header file, e.g., MySerialExceptions.h, and joe * ** * Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm SHOULD have had a cross-reference to CDocument::ReportSaveLoadException, and did not. joe * ** * Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm abort deep recursions all the way back up to the top level. joe * ** * Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder
the native Chinese programmers, so they were lost on me even then. joe * ** * Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm an important measure), the whole design seems just flat-out wrong. joe * ** * joe * ** ** Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm the noise". We used to worry about optimizing things that actually MATTERED. joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm is wrong, and you have to start thinking correctly about the problem. joe Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm
Can any body help me to resolve this. Thanks, rshaik. VC MFC Discussions Joseph M. Newcomer (1) Exception (1) Describe (1) Class (1) TEXT (1) SendMessage (1) EditValue (1) Dialog (1) class CFirst : public CDialog { void SecondChanged(const CString& s) { SetDlgItemText the correct solution is to put a CWnd * pointer in the child dialog, and use SendMessage to notify it. Note that this isolates the interface cleanly, because the second dialog does the contents of the edit control" which is a good deal cleaner. joe * ** ** Joseph M. Newcomer [MVP] email: newcomer@flounder.com Web: http: / / www.flounder.com MVP Tips: http: / / www.flounder.com / mvp_tips.htm methods, for exactly the reason you evoke, modularity. However, I disagree with the use of SendMessage. Yes, that can be done, but that is way to loosely coupled for what it ITextChangeNotification& Listener) : m_Listener(Listener) {} ITextChangeNotification m_Listener; }; In other words, a specific interface is better than SendMessage. Send message is bad for following reasons: it requires a CWnd. That's incidental coupling actually required. It requires giving up type safety (reinterpret_cast) to be able to go through SendMessage. It even does not lower code complexity compared to a separate interface. I know that