March 26th, 2026
likeintriguing3 reactions

Why doesn’t WM_ENTER­IDLE work if the dialog box is a Message­Box?

Last time, we looked at how the owner of a dialog can take control just before the dialog box message loop goes idle. I said that I pulled a trick.

The trick is that I used the common file open dialog instead of a simple Message­Box. Indeed, if you replace the call to Get­Open­File­Name with a call to Message­Box, then no WM_ENTER­IDLE message arrives, and you get no beeping. What’s going on?

A dialog can suppress the WM_ENTER­IDLE message by adding the DS_NO­IDLE­MSG dialog style to its template. And that’s what the template used by the Message­Box function does.

So the WM_ENTER­IDLE trick does require a small amount of cooperation from the dialog box, namely that it doesn’t disable WM_ENTER­IDLE messages.

But say you can guarantee the cooperation of the dialog box because you are the dialog box. Right now, the WM_ENTER­IDLE message allows a dialog owner to be notified when the dialog message loop is about to go idle. But what if the dialog box itself wants to know, so it can customize its own message loop?

We’ll look at that next time.

Topics

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

3 comments

Sort by :
  • Iaroslav Chebotarev 1 day ago · Edited

    In fact, it is possible to solve the lack of idle messages from MessageBox box by adding a hook WH_CALLWNDPROC with the hook code like this:
    <code>
    I tested such code and it works! But the problem is, MessageBox is the shared dialog and ability to reply to idle messages will be enabled everywhere, potentially resulting in subsequent calls (e.g. error from idle code when informing about another error). So eventually I preferred to use a replacement which calls DialogBoxParam and left MessageBox only for critical error messages.

    Read more
    • anonymous

      this comment has been deleted.

  • Frédéric B. 1 week ago

    Do we get idle messages if our dialog box calls MessageBox()?