PRB: ClassWizard Disables Add Function & Add Variable Buttons (140252)



The information in this article applies to:

  • The ClassWizard, when used with:
    • Microsoft Visual C++, 32-bit Professional Edition 4.0
    • Microsoft Visual C++, 32-bit Learning Edition 4.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 5.0
    • Microsoft Visual C++, 32-bit Professional Edition 5.0
    • Microsoft Visual C++, 32-bit Enterprise Edition 6.0
    • Microsoft Visual C++, 32-bit Professional Edition 6.0
    • Microsoft Visual C++, 32-bit Learning Edition 6.0

This article was previously published under Q140252

SYMPTOMS

If either the header (.h) or implementation (.cpp) file for a class is a read-only file, the following buttons will be grayed out in ClassWizard:
  • Add Function button on the Message Map tab.
  • Add Variable button on Member Variables tab.
  • Add Method and Add Property buttons on the OLE Automation tab.
  • Add Event button on the OLE Event tab.
In Visual C++, versions 5.0 and 6.0, the OLE Automation tab is named Automation, and OLE Event is now ActiveX Events. Also, the following additional buttons will be dimmed:
  • Delete Function button on the Message Map tab.
  • Delete Variable button on Member Variables tab.
Having a project's .odl file tagged as read-only causes the same behavior, and having the .clw file tagged as read-only produces this message:
The ClassWizard database <path to the .clw file> is read-only.
ClassWizard cannot continue.

CAUSE

This is by design. ClassWizard checks the attributes of the header and implementation files for a class when a class is selected from the Class Name combo box. If either file is read-only, ClassWizard can't add a new method, function, or variable to the file, so the buttons are disabled.

If the files are checked-in to a source management system such as Microsoft SourceSafe, they are read-only until they are checked out.

RESOLUTION

A simple workaround is to remove the read-only attribute from those files. If the files are under source management, checking the file out removes the read-only attribute as well.

STATUS

This behavior is by design.

Modification Type:MajorLast Reviewed:12/2/2003
Keywords:kbprb KB140252