BUG: Default Button Style Not Set Correctly in CFormView

Last reviewed: July 22, 1997
Article ID: 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
Technology : kbMfc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.