PRB: Error Setting CanGetFocus to False in Custom ActiveX Contro

Last reviewed: February 4, 1998
Article ID: Q180216
The information in this article applies to:
  • Microsoft Visual Basic Learning and Professional Editions for Windows, version 5.0

SYMPTOMS

When creating a custom ActiveX control using Microsoft Visual Basic 5.0, you get the following error when setting the CanGetFocus of the UserControl object to False:

  Can't have child controls capable of receiving focus on a UserControl
  whose CanGetFocus property is False.

RESOLUTION

To work around this behavior, do one of the following:

  • Remove all controls that can receive focus.

    -or-

  • Set the UserControl's Enabled property to False instead of setting the CanGetFocus property.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Microsoft Visual Basic 5.0, create a new ActiveX Control project.

  2. Add a Textbox to the form.

  3. Click on the background of the UserControl to select it, and then change the CanGetFocus property from True to False. The following message will be displayed:

          Can't have child controls capable of receiving focus on a UserControl
          whose CanGetFocus property is False.
    

    NOTE: If you try step 3 prior to step 2, all controls in the ToolBox capable of receiving focus will be disabled so you will be unable to add the textbox.

Keywords          : vb5all kberrmsg
Version           : WINDOWS:5.0
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbnofix


================================================================================


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: February 4, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.