MFC/win32 API: Giving a CFormView's first widget in tab order focus even after modal dialog has been spawned by other widget
-
Hello, I have an MFC "windows explorer style" application, which consists of a slitter window, the right pane of which displays a CFrameWnd that may display one of several CFormViews. I've noticed a particular behaviour that this application exhibits - if someone could explain this to me, or at least tell me what the name of this phenomenon is, perhaps I could solve a particular subtle though annoying usability issue. I fake being able to tab between views (panes of a splitter window) by calling SetFocus on a pointer to the view in the right pane from the left view, and the view in the left frame from the right view. Whenever I spawn a modal dialog, whatever widget happens to have focus in the CFormView at that time will subsequently get the focus *first* when the entire CFormView goes out of focus and subsequently goes back into focus through a call to SetFocus(), even though it may not be the first in the tab order. If, for example, a row of a CListCtrl is focused, when I SetFocus to the other view, focus won't go back to the CListCtrl when I once again give focus to the CListCtrl's parent (the row will remain grey) - it will go to the first widget of the tab order. If, however, I spawn a modal dialog while the row of the CListCtrl is focused, and subsequently SetFocus somewhere else, when I once again give the CListCtrl's parent view focus(also through SetFocus() ), focus immediately goes to the CListCtrl, bypassing all the other widgets that are earlier in the tab order. I think that there is some other concept related to, but distinct from focus in play here - the widget that has focus at the time of the modal dialog's spawning gets "Activation" or something like that, causing focus to return to it rather than the first widget in the tab order of the parent View. There is a blog post that I think touches on these issues: http://blogs.msdn.com/oldnewthing/archive/2004/08/02/205624.aspx[^] The solution the author proposes (for modeless dialogs rather than CFormViews) is to send the WM_NEXTDLGCTL message. CFormView doesn't have a handler for this message, so this doesn't apply here. What is the name of this "Activation" I have described? How can I prevent this "Activation" from occuring, so that focus always goes to the first widget in the tab order? If one of you could offer help, that would cert