What happens if I manually post an auto-generated message into my message queue?

As we well know, the window manager generates various messages on-demand rather than posting them into the queue at the time the event occurs. But what happens if you manually post one of these messages, like Post­Message(hwnd, WM_PAINT, 0, 0)? Does that clear the internal flag that says "This window needs a paint message?"


The window manager does not have a prank call detector. If you post a fake WM_PAINT message, then a fake WM_PAINT message shows up in the message queue. The part of the window manager which manages the "Does this window need to be repainted?" does not wiretap every telephone call to see if somebody is prank-calling a window with the WM_PAINT message, and then say, "You know what? I'm going to make that prank call a reality and make it act like a real WM_PAINT message."

Imagine if the act of prank-calling somebody caused Prince Albert to stop by for a visit!

In particular, the posted message goes into the posted message queue and will rise to the front of the queue as messages are retrieved. On the other hand, the auto-generated message will remain in its proto-message state until the queue is finally empty.

It then follows as a consequence that if you post one of these auto-generated messages, like WM_TIMER message, you don't get any magical coalescing behavior because the coalescing happens as part of the auto-generation, not as part of the Post­Message. These prank-call messages also appear in the message queue in posted order rather than being generated at low priority like normal auto-generated messages.

Comments (18)
  1. Joshua says:

    Wouldn't the BeginPaint call have cleared the flag or am I missing something?

    [Yeah, I chose a bad example because you can cancel a pending paint by calling Begin­Paint. The remarks still apply to timers and mouse-move messages. -Raymond]
  2. John says:

    Imagine if the act of prank-calling somebody caused Prince Albert to stop by for a visit!

    Is this some kind of <male anatomy> joke?

  3. SimonRev says:

    It is a reference to a prank phone call (which were more effective in the days before caller ID). answers.yahoo.com/…/index

  4. Rick C says:

    "Is [Prince Albert] some kind of <male anatomy> joke?"

    These kids today.  The Prince Albert prank phone call is right up there with "Is your refrigerator running?  Then you'd better go catch it!" or asking the operator of a department store to page your friend, Jim Naseum.

  5. Wondering says:

    What will happen if you post an auto-generated message as a blog post?

  6. hdfan2 says:

    I wonder why WinAPI allows posting messages below WM_USER at all?

  7. @hdfan2 says:

    WM_GETTEXT < WM_USER (one example of many), and I'd personally like to be allowed to send it.

  8. NO WAY to contact Raymond??? -- Off-topic Comment FTW! says:

    —PART 2—

    Wow, you don't even lemme SEE my own post???

    Oh & here's a suggestion: Re-open the Suggestion Box, Re-enable the Contact page (hint: use a Captcha or something to stop spam!), Fix all those broken links mentioned above!

    Bonus Tip: Stop using Microsoft's Useless number-URLs…example…

    Useless URL…


    Informative URL…


    Also, if you didn't infer this from above, plz set this up…


    …as a list of all blog posts on "2013-05-24"…ditto for the other OBVIOUS URLs…

    blogs.msdn.com/b/oldnewthing/archive/2013/05 — should be: all blog posts on "2013-05"

    blogs.msdn.com/b/oldnewthing/archive/2013 — should be: all blog posts in 2013

    —/PART 2—

  9. blog software fail says:

    OMFG apparently part 1 failed the 1st time, that's why they are out of order!

  10. asdbsd says:

    …wait wait wait: "Now that we've learned"??? I haven't learned anything yet

    This is comedy gold.

  11. @NO WAY to contact Raymond says:


    Here, that took me like 20 seconds to find using google.

    And regarding the missing contact link… with a readership this big I imagine he would need to answer emails all day if he was easy to reach, probably even as the personal support go-to guy.

    [It takes even less time if you realize that "last time" is probably "yesterday". And the comment page is disabled for spam reasons. If you really need to contact me, you will eventually find my email address. It's not that hard, really. -Raymond]
  12. Jim says:

    Ah, I thought the Prince Albert comment was a Blackadder reference (en.wikipedia.org/…/Blackadder&)

  13. Joshua says:

    @NO WAY: Contacting Raymond requires solving a logic puzzle and a reading comprehension test, but it can be done.

  14. laonianren says:

    @"No way to contact Raymond".

    Top tip: rather than guessing URLs, you can access previous posts by clicking the "Archives" link in the box labelled "Basics" at the top-right of the page.

  15. Troll food says:

    Perhaps the Archive for 2006-07-26 is here? (logical URL, if I do say so myself)… blogs.msdn.com/b/oldnewthing/archive/2006/07/26

    Aside from the search tools and archive index, one might realise that there's a pattern with all the pages ending in ".aspx". It'll get you to the month (oh horrors…) Anyways, a quick flip through the month and you might even discover there's an "Index to the series…". Poor li'l fella.

  16. NO WAY to contact Raymond??? -- Off-topic Comment FTW! says:

    —PART 1—

    OK, so, there's NO WAY to contact Raymond!

    * "Contact Me" link? nope! it links to "Suggestion Box 4": blogs.msdn.com/b/oldnewthing/archive/2010/07/20/10040074.aspx

    * "Suggestion Box 4" is closed for comments (like EVERY SINGLE POST he's EVER made)

    Hmm, let's start over at the beginning (home page of blog)…


    * "Contact Me" link? Hmmm…different URL? (progress?): blogs.msdn.com/oldnewthing/pages/232903.aspx

    * "How to contact Raymond" page: "you can send email using the Contact page": blogs.msdn.com/oldnewthing/contact.aspx — or NO you CAN'T — "Update 25 March 2007: The contact page has been disabled…"…so that's a dead end too!

    * "Contact" page: instead of being NOT being linked to or showing an error msg, you just get a "blank" page! Then entire Blog "chrome" (header, footer, sidebar) loads, but it has a blank main area with no information explaining the problem. Useless!

    So, what's left? I know, I'll post an off-topic Comment on the newest blog entry!, sure it'll get deleted, but at least it'll get read! Sorry, but YOU left me no other choice than to post here!

    In any case, the REAL REASON I wanted to contact Raymond…

    On this post (which has comments disabled {like EVERY SINGLE POST you've EVER made})…

    What happens when you get dllimport wrong?


    …it says…

    "Now that we've learned what the dllimport declaration specifier does…"

    …wait wait wait: "Now that we've learned"??? I haven't learned anything yet, where's the PREVIOUS BLOG POST, that this one assumes I've read? There's NO LINK ANYWHERE.

    Since there's no LINK to the post where we DIDN'T LEARN "what the dllimport declaration specifier does", let's try to brute-force it out of the Blog…

    We are here…


    Perhaps the Archive for 2006-07-26 is here? (logical URL, if I do say so myself)…


    Nope: redirect to error msg: blogs.msdn.com/msgs/?messageid=9

    Archive for 2006 07?…


    Nope: redirect to LOGIN: login.live.com/login.srf

    WTF does it want me to login for??? I'm just trying to guess the "archive" URL.

    Archive for 2006?…


    Nope: redirect to LOGIN again: login.live.com/login.srf

    …so, since I obviously tried, can you plz link me to the post where it explains what "Now that we've learned what the dllimport declaration specifier does" was talking about???…

    "Please shorten the content to 3072 or less"…oh dear GOD you are trying to limit me! CANNOT COMPLY! MUST. TYPE. MORE. Well, now you just get MORE TEXT!!!

    —/PART 1—

  17. Brian G. says:

    My favorite is always the outrage expressed when somebody's free time isn't spent solving the problems of others in a way that makes the other people happy. I hope you don't let this sort of response convince you to quit blogging, Raymond.

  18. Troll food says:

    Haha. I just bothered reading the comments on that 'Index to the seriea' article on DLL imports/exports. Well played if it was intentional.

Comments are closed.

Skip to main content