What windows messages should a well behaved app support?
Precisely those messages needed to do its job - no more, no less.
Ask a vague question, get a vague answer :-P
Precisely those messages needed to do its job - no more, no less.
Ask a vague question, get a vague answer :-P
Agree'd, but I think pointing out a couple of the non-obvious ones you want to consider would be good:
WM_SYSKEYDOWN, specifically VK_MENU. In some fullscreen windows if the user hits alt it can hang the program for no apparent reason. The user just needs to hit alt again or esc but this is just bad to allow it to happen.
WM_SYSCOMMAND, specifically SC_SCREENSAVE. Letting the screen saver kick in is also bad form in a fullscreen app.
WM_DISPLAYCHANGE, often overlooked but in multimonitor setups you need to notice this if your app were on say the second monitor and the user hit Windows-P and changed to mirroring, if they have 2 different resolution monitors your full screen app could be forced into a different resolution. DX would trigger a device lost or reset I believe but a GL game needs to catch this and readjust view areas and all that.
The various CPU frequency change messages, power notifications (sleep/hibernate/etc) and related. You may not care about the CPU change but your app should respect sleep/hibernate and say disconnect from servers and/or go to a menu and wait for wakeup etc.
Hmm, I remember there being a number more of these annoying edge cases you really should handle but can't think of any more off the top of my head.
A few others.
WM_MENUCHAR for reasons outlined at http://stackoverflow.com/questions/3662192/disable-messagebeep-on-invalid-syskeypress
WM_INPUT if you're using raw input (obviously).
WM_MOVE and WM_SIZE are good places to handle any internal state you may have that depends on the window size and position. WM_SIZE is not a good place for lost device handling, nor is WM_ACTIVATE.
WM_CLOSE may be handy to prevent the player from accidentally closing the window when they may not intend to.
WM_ACTIVATE to detect when you're no longer the focus; this is useful because you can start Sleeping, skip display updates and otherwise behave like a civilized program on the player's computer. Don't use it for lost device handling.
WM_DESTROY can be a good place to clean up resources.
A few others.
WM_MENUCHAR for reasons outlined at http://stackoverflow.com/questions/3662192/disable-messagebeep-on-invalid-syskeypress
WM_INPUT if you're using raw input (obviously).
WM_MOVE and WM_SIZE are good places to handle any internal state you may have that depends on the window size and position. WM_SIZE is not a good place for lost device handling, nor is WM_ACTIVATE.
WM_CLOSE may be handy to prevent the player from accidentally closing the window when they may not intend to.
WM_ACTIVATE to detect when you're no longer the focus; this is useful because you can start Sleeping, skip display updates and otherwise behave like a civilized program on the player's computer. Don't use it for lost device handling.
WM_DESTROY can be a good place to clean up resources.
Those are good messages to handle but only the menu one is the type of edge case stuff I was thinking of. Not saying this is wrong, just that I'd be more interested in getting a good list of all those rarely used but oh so annoying messages a game should handle but usually doesn't. As much for the original poster as for me, I used to have a list but I can't seem to find the damned thing. :)
Precisely those messages needed to do its job - no more, no less.
You can choose to handle all or none.
Most important is that you pass ALL of them on to DefWindowProc unless you explicitely handle it and the docs say you can return a specific value from your WndProc.
Precisely those messages needed to do its job - no more, no less.
Why even answer if that's all you have to say?
Because it's really correct. An open-ended question like that implies that the author is either not thinking about the question or else is not thinking about solutions.
Precisely those messages needed to do its job - no more, no less.
Why even answer if that's all you have to say?
Actually his answer sums up a strategy which is important in order to not introduce unwanted quirks. The less messages that a window handles, the less likely it is to misbehave. DefWindowProc() does A LOT of things to implement standard behavior of windows, and it expects to receive certain messages with certain data in a certain order. If your window messes with the order (by calling certain functions in its message handler which cause certain events which will in turn send certain messages before they return, or by not passing certain messages to DefWindowProc()), then there is a chance your window will break one of the standard behaviors implemented by DefWindowProc().
So yes, only process the messages that you need to process.