Microsoft KB Archive/135759

{|
 * width="100%"|

BUG: Default Button Style Not Set Correctly in CFormView

 * }

Q135759

1.50 1.51 1.52 1.52b WINDOWS kbprg kbcode kbbuglist - The information in this article applies to: - The Microsoft Fundation Classes (MFC) included with: Microsoft Visual C++ for Windows, versions 1.5, 1.51, 1.52, 1.52b - SYMPTOMS ======== In a 16-bit MFC application that includes command buttons in a form view, if you click a button other than the default button, the current button gets the focus but does not have the default button style. That is, the button is not surrounded by a heavy border. However, if you use the TAB key to move from one control to another, the default button style is moved to the button that has the focus. NOTE: This occurs only in appliations developed by using the Microsoft products listed at the beginning of this article. It does not occur in applications developed using Visual C++ version 1.0 for Windows or Visual C++ 32-bit editions. CAUSE ===== Only the keyboard messages are passed to the dialog manager but the mouse messages are filtered out in the CFormView::PreTranslateMessage. RESOLUTION ========== Override CFormView::PreTranslateMessage in your CFormView-derived class. Call CFormView's PreTranslateMessage to process the keyboard messages. If CFormView::PreTranslateMessage returns FALSE, you should check to see if the messages are mouse messages and handle them if they are. You can use something similar to the following code to work around the problem: BOOL CMyFormView::PreTranslateMessage( MSG *pMsg ) { BOOL processed = CFormView::PreTranslateMessage( pMsg ); if ( !processed && pMsg->message >= WM_MOUSEFIRST && pMsg->message <= WM_MOUSELAST ) return ::IsDialogMessage( m_hWnd, pMsg ); return processed; } STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available. MORE INFORMATION ================ Code to Reproduce Problem - BOOL CFormView::PreTranslateMessage(MSG* pMsg) { ... if (pMsg->message >= WM_KEYFIRST && pMsg->message <= WM_KEYLAST) return ::IsDialogMessage(m_hWnd, pMsg); return FALSE; } Additional reference words: 1.50 1.00 KBCategory: kbprg kbcode kbbuglist KBSubCategory: MfcUI

Keywords : kb16bitonly

Issue type :

Technology :