- The comment below and all this code is probably due to not using WM_NEXTDLGCTL
- message when changing focus (but just SetFocus() which is not enough), see
- http://blogs.msdn.com/oldnewthing/archive/2004/08/02/205624.aspx for the
- full explanation.
-
- TODO: Do use WM_NEXTDLGCTL and get rid of all this code.
-
+ In normal Windows programs there is no need to handle default button
+ manually because this is taken care by the system provided you use
+ WM_NEXTDLGCTL and not just SetFocus() to switch focus betweeh the controls
+ (see http://blogs.msdn.com/oldnewthing/archive/2004/08/02/205624.aspx for
+ the full explanation why just calling SetFocus() is not enough).
+
+ However this only works if the window is a dialog, i.e. uses DefDlgProc(),
+ but not with plain windows using DefWindowProc() and we do want to have
+ default buttons inside frames as well, so we're forced to reimplement all
+ this logic ourselves. It would be great to avoid having to do this but using
+ DefDlgProc() for all the windows would almost certainly result in more
+ problems, we'd need to carefully filter messages and pass some of them to
+ DefWindowProc() and some of them to DefDlgProc() which looks dangerous (what
+ if the handling of some message changes in some Windows version?), so doing
+ this ourselves is probably a lesser evil.
+
+ Read the rest to learn everything you ever wanted to know about the default
+ buttons but were afraid to ask.