FIX: Combo Box in Toolbar Leaves Drop-Down Portion BehindID: Q113587
|
In an MDI application, with a toolbar that contains a combo box, if the mainframe is moved while the drop-down portion of the combo box is showing, the frame moves but the drop-down box remains in its original position on the screen. The combo box must have either the CBS_DROPDOWN or CBS_DROPDOWNLIST style in order for this to occur.
The problem occurs because the CMDIFrameWnd::PreTranslateMessage member
function does not call its base class version of PreTranslateMessage.
CFrameWnd is the base class of CMDIFrameWnd. CFrameWnd::PreTranslateMessage
calls the _AfxCancelModes function, which determines whether the drop-down
portion of a combo box is showing and closes it if it is.
CMDIFrameWnd::PreTranslateMessage does not call _AfxCancelModes, and
therefore the drop-down portion is never closed.
To workaround this problem, the application should override
PreTranslateMessage in the mainframe class. The override should check for
either the WM_LBUTTONDOWN or WM_NCLBUTTONDOWN message and call
_AfxCancelModes. The override should then call the base class version of
PreTranslateMessage, CMDIFrameWnd::PreTranslateMessage.
Perform the following five steps to accomplish this:
#include "auxdata.h"
BOOL CMainFrame::PreTranslateMessage( MSG* pMsg )
{
if( pMsg->message == WM_LBUTTONDOWN ||
pMsg->message == WM_NCLBUTTONDOWN )
_AfxCancelModes( pMsg->hwnd );
return CMDIFrameWnd::PreTranslateMessage( pMsg );
}
virtual BOOL PreTranslateMessage(MSG* pMsg);
Microsoft has confirmed this to be a problem in the Microsoft Foundation classes (MFC) version 2.0. This problem was corrected in the Microsoft Foundation classes version 2.5.
Additional query words: 1.00 2.00 combobox painting dropdown
Keywords : kb16bitonly kbMFC KbUIDesign kbVC
Version : 1.00
Platform : WINDOWS
Issue type :
Last Reviewed: July 26, 1999