The information in this article applies to:
SYMPTOMSA view displayed in a splitter window (CSplitterWnd) loses focus when the splitter bar is clicked. A user would expect the focus to be returned to the active view when the user stops dragging the splitter bar and releases the mouse button. CAUSE
CSplitterWnd::StopTracking() attempts to restore the active view's keyboard
focus by calling SetActiveView(pOldActiveView), where pOldActiveView was
set to the currently active view on entry to the StopTracking() function.
This is supposed to set the keyboard focus to the previously active view. RESOLUTIONMicrosoft has confirmed this to be a problem in the Microsoft Foundation Class (MFC) Libraries version 2.0. This problem has been fixed in the MFC Libraries version 2.5, which is included in Visual C++ version 1.5 for Windows. In the fixed code, CSplitterWnd::StopTracking() (in WINSPLIT.CPP) is modified to explicitly set the focus even after calling SetActiveView(). The code is:
You can include this fix into WINSPLIT.CPP and then rebuild the MFC library
by following the directions in Appendix B of the "Class Libraries User's
Guide" as well as the README.TXT file located in the \MSVC\MFC\SRC
directory.Another workaround for the bug is to save and restore the keyboard focus throughout the splitter window's tracking process. This can be done by handling the WM_LBUTTONDOWN and WM_LBUTTONUP messages in the CSplitterWnd class. The following code demonstrates how to accomplish this:
The code above assumes that the focus is being set to one of the windows in
the splitter window panes before the OnLButtonDown() handler is called.
That is, you probably wouldn't want to set the focus back to some other
window outside of the splitter window when the mouse button is released.
You could write additional code to check to see if the focus is set to a
window in one of the panes by checking the splitter's frame window's
m_pActiveView variable.
STATUSThis problem has been reported in Visual C++ version 1.0 for Windows. This problem has been fixed in Visual C++ version 1.5 for Windows and Visual C++ 2.0 32-bit Edition. MORE INFORMATION
To demonstrate the problem, perform the following steps:
Additional query words: 1.00 2.00 2.10 splitter focus
Keywords : kbMFC KbUIDesign kbVC |
Last Reviewed: July 29, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |