PRB: ATL Full Control Needs Enabled Stock Property for Access 97
ID: Q197490
|
The information in this article applies to:
-
Microsoft Visual C++, 32-bit Editions, versions 5.0, 6.0
-
Microsoft Access 97
SYMPTOMS
When opening a form that was saved in Access 97 and contains ActiveX
controls developed with ATL, you might get a message box stating the
following:
There is no object in this control.
CAUSE
This error can be caused when the control does not support the stock
property for Enabled.
RESOLUTION
If you are developing a control using ATL and plan to use it in Microsoft
Access, be sure to support the Enabled stock property. The ATL COM Object
Wizard can add the needed code if you select Enabled from the list of
available stock properties on the last property page when inserting the
full control.
If you already have a control project that does not have the Enabled stock
property selected, you can add support for it using the steps outlined
here.
- Determine whether or not your control has support for ANY stock
properties. If not, modify the header file for the control to include
support for ATL's default stock property support and comment out the
IDispatchImpl derived class. For example:
class ATL_NO_VTABLE CATLAccessKBControl :
public CComObjectRootEx<CComSingleThreadModel>,
//public IDispatchImpl<IATLAccessKBControl, &IID_IATLAccessKBControl,
\ //&LIBID_ATLACCESSCONTROLLib>,
public CStockPropImpl<CATLAccessKBControl, IATLAccessKBControl, \
&IID_IATLAccessKBControl, &LIBID_ATLACCESSCONTROLLib>,
//rest of interfaces that are derived....
- Modify the IDL file by adding support for propget/propput methods for
DISPID_ENABLED. For example:
[
object,
uuid(91A905D0-8B9F-11D2-8F10-00C04F94089E),
dual,
pointer_default(unique)
]
interface IATLAccessKBControl : IDispatch
{
[propput, id(DISPID_ENABLED)] HRESULT Enabled([in]VARIANT_BOOL
vbool);
[propget, id(DISPID_ENABLED)] HRESULT Enabled([out,retval] \
VARIANT_BOOL*pbool);
};
- Add a member variable to the control's header file, which will have the
enabled stock property value. For example:
class ATL_NO_VTABLE CATLAccessKBControl :
public CComObjectRootEx<CComSingleThreadModel>,
//rest of interfaces that are derived...
{
public:
BOOL m_bEnabled;
//rest of class definition
};
Be sure to name the property "m_bEnabled" so ATL framework correctly
sets it.
STATUS
This behavior is by design.
MORE INFORMATION
You do not get this problem with controls created with MFC or Visual
Basic. Both of these products provide the Enabled stock property by
default.
Steps to Reproduce Behavior
- Create a new ATL COM AppWizard.
- Select Dynamic Link Library (DLL) as the Server Type and accept the
remaining defaults.
- On the Insert menu, click New ATL Object.
- Select controls from the category list on the left.
- Select Full Control.
- Give the control a name and accept the remaining defaults.
- Build the control.
- Start Access97 and open a database.
- Insert a new form.
- Insert the control and place it on the form.
- Save the form and close it.
- Attempt to re-open the form, and note that you receive a message box stating
"There is no object in this control."
REFERENCES
For additional information, please click the article number below
to view the article in the Microsoft Knowledge Base:
Q177105 ACC97: "No Object in This Control" Inserting Web Browser
Additional query words:
Keywords : kbnokeyword kbAccess97 kbATL210 kbCOMt kbContainer kbCtrlCreate kbVC500 kbVC600 kbATL300 kbDSupport kbGrpMFCATL
Version : WINDOWS:97; winnt:5.0,6.0
Platform : WINDOWS winnt
Issue type : kbprb