PRB: MFC Has Tabstop Property On by Default for VBX Controls

Last reviewed: July 22, 1997
Article ID: Q113060
1.00 1.50 WINDOWS kbprg kbprb

The information in this article applies to:

  • The Microsoft Foundation Classes (MFC) included with:

        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

SYMPTOMS

If a VBX control does not make the Tabstop property available for modification at design time using App Studio then the Tabstop property will be turned on when the control is created. Under App Studio, the properties are shown for Tabstop as OFF (not checked) and DISABLED (grayed).

MORE INFORMATION

App Studio is behaving properly because the setting is not modifiable (thus, DISABLED). MFC sets the Tabstop property when the VBX is created. There is a WS_TABSTOP setting in the .RC file in the list of styles for the control, but removing this has no effect. These settings are ignored for VBX controls.

This problem is apparent when using controls for which you wouldn't normally expect to have a Tabstop property set. For example, the Frame 3D control that shipped with the Visual Control Pack is intended as a frame, and you normally wouldn't want to be able to tab to it directly. Following is a list of controls included in the Visual Control Pack that will be affected by this behavior:

   Frame3D     Panel3D     Group3D     SpinButton     VBSQL

RESOLUTION

Sheridan Software has an updated version of THREED.VBX that will fix the problem for Frame3D, Panel3D, and Group3D. This update is available to registered users and can be obtained from:

   Sheridan Software Systems, Inc.
   65 Maxess Road
   Melville, NY  11747

   Phone: (516) 753-0985
   Fax:   (516) 293-4155
   BBS:   (516) 753-5452 (2400 baud) or
          (516) 753-6510 (9600 baud)

You will need the THREED.VBX file dated 7/16/93 or later.

The third-party product included here is manufactured by a vendor independent of Microsoft; we make no warranty, implied or otherwise, regarding this product's performance or reliability.

For other VBX controls, the problem can be resolved by explicitly removing the Tabstop property from the control after it has been created. This can be done in the initialization phase of your CDialog or CFormView class. Assume your class is called CMyDialog or CMyForm and the ID of the VBX control for which you do NOT want the Tabstop property set is IDC_VBX1.

For CMyDialog, follow these steps:

  1. Use ClassWizard to create a member function to handle the WM_INITDIALOG message. ClassWizard will create a function called OnInitDialog.

  2. Modify the function to change the style for the window of the VBX control:

    CMyDialog::OnInitDialog() {

         CDialog::OnInitDialog()
         HWND hwndVBX = GetDlgItem(IDC_VBX1)->GetSafeHwnd();
         LONG dwStyle = GetWindowLong(hwndVBX,GWL_STYLE);
         dwStyle &= ~((LONG) WS_TABSTOP);
         SetWindowLong(hwndVBX,GWL_STYLE,dwStyle);
    

         // The rest of your initialization code goes here
         // ...
        }
    

For CMyForm, the procedure is the same but the changes are performed in the OnInitialUpdate() function:

  1. If you don't already have an override for the OnInitialUpdate() function in your CMyForm class then create one.

  2. Modify the OnInitialUpdate() function as follows:

        CMyForm::OnInitialUpdate()
        {
         CFormView::OnInitialUpdate()
         HWND hwndVBX = GetDlgItem(IDC_VBX1)->GetSafeHwnd();
         LONG dwStyle = GetWindowLong(hwndVBX,GWL_STYLE);
         dwStyle &= ~((LONG) WS_TABSTOP);
         SetWindowLong(hwndVBX,GWL_STYLE,dwStyle);
    

         // The rest of your initialization code goes here
         // ...
        }
    

If you want to permanently change the behavior of MFC so that it leaves the Tabstop property OFF by default, then you can modify the necessary MFC source files and rebuild the libraries. The line of code you must change is in the file VBCTRL.CPP. Change the following section in CVBControl::Create:

Change the following

   if (dwStyle == NULL)    // NULL means use default
         dwStyle = GetModelStyles() | WS_CHILD | WS_TABSTOP;
   else
         dwStyle |= WS_CHILD;    // Guarantee WS_CHILD is set

to the following:

   if (dwStyle == NULL)    // NULL means use default
         dwStyle = GetModelStyles() | WS_CHILD ;
   else
         dwStyle |= WS_CHILD;    // Guarantee WS_CHILD is set

Once the change has been made, then rebuild the MFC libraries. For more information on building these library files, refer to one of the following resources:
  • Appendix B of the online "Class Library User's Guide"
  • The README.TXT file in the MSVC\MFC\SRC directory.


Additional reference words: 1.00 1.50 2.00 2.50 SpinButton SSFrame SSPanel
SSRibbon Spin grey tab stop
KBCategory: kbprg kbprb
KBSubcategory: MfcVBX
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.