Even if the message is not for you, you still need to pass it on

by Michael S. Kaplan, published on 2006/05/15 22:43 -04:00, original URI: http://blogs.msdn.com/b/michkap/archive/2006/05/15/598548.aspx


As far back as elementary school, there may have been times when notes were being passed. The note would have on it the name of the person it is intended for; if it was not you then you would need to pass it on. Certainly you weren't supposed to throw it away or read it or whatever.

These lessons we learned a youngsters do not always get remembered when they ought be, though....

It was less than a month ago that Raymond Chen reminded people that No, really, you need to pass all unhandled messages to DefWindowProc. And he is entirely correct about the issue.

I thought I'd point out another good example -- the WM_INPUTLANGCHANGEREQUEST notification. It is handled in simple, deterministic way:

Return Value

This message is posted, not sent, to the application, so the return value is ignored. To accept the change, the application should pass the message to DefWindowProc. To reject the change, the application should return zero without calling DefWindowProc.

Remarks

When the DefWindowProc function receives the WM_INPUTLANGCHANGEREQUEST message, it activates the new input locale and notifies the application of the change by sending the WM_INPUTLANGCHANGE message.

The language indicator is present on the taskbar only if you have installed more than one keyboard layout and if you have enabled the indicator using the Keyboard control panel application.

So if your application does not pass the message to DefWindowProc, then the user won't be able to change the keyboard layout. Ick!

Now in fairness, the above deterministic process stopped being 100% true all the time starting with Windows XP; this is an issue that is for the most part by design but does not appear to be in any of the documentation. I'll explain what broke the model and why (as well as how to keep things working properly!) tomorrow....

 

This post brought to you by "ܞ" (U+071e, a.k.a. SYRIAC LETTER YUHD HE)


no comments

Please consider a donation to keep this archive running, maintained and free of advertising.
Donate €20 or more to receive an offline copy of the whole archive including all images.

referenced by

2006/05/16 What broke the input language messages?

go to newer or older post, or back to index or month or day