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.

The post Why doesn’t <CODE>WM_<WBR>ENTER­IDLE</CODE> work if the dialog box is a <CODE>Message­Box</CODE>? appeared first on The Old New Thing.


From The Old New Thing via this RSS feed