Article ID: 185671
Article Last Modified on 11/21/2006
[id(DISPID_CAPTION)] BSTR Caption;
to the following:
[id(2)] BSTR Caption;
enum {
//{{AFX_DISP_ID(CPersistctrlCtrl)
// ... more dispid enumeration goes here
dispidCaption = 2L // ADD THIS!!! - same DISPID as in step 1
//}}AFX_DISP_ID
};
DISP_PROPERTY_EX_ID(CMyActiveXCtrl, "Caption", DISPID_CAPTION,
GetCaption, SetCaption, VT_BSTR)
to the following:
DISP_PROPERTY_EX(CMyActiveXCtrl, "Caption",
GetCaption, SetCaption, VT_BSTR)
Change the following
BoundPropertyChanged(DISPID_CAPTION);
to the following:
BoundPropertyChanged(dispidCaption);
// The following lines are added to your control's .h file:
afx_msg BSTR GetCaption();
afx_msg void SetCaption(LPCTSTR lpszNewValue);
// The following line is added to dispatch map of your control's .cpp
// file:
DISP_PROPERTY_EX_ID(CMyActiveXCtrl, "Caption", DISPID_CAPTION,
GetCaption, SetCaption, VT_BSTR)
// The following methods are added to your control's .cpp file:
BSTR CMyActiveXCtrl::GetCaption()
{
CString strResult;
// TODO: Add your property handler here.
return strResult.AllocSysString();
}
void CMyActiveXCtrl::SetCaption(LPCTSTR lpszNewValue)
{
// TODO: Add your property handler here.
SetModifiedFlag();
}
// The following line is added to your control's Object
// Description (.ODL) file:
[id(DISPID_CAPTION)] BSTR Caption;
void CMyActiveXCtrl::DoPropExchange(CPropExchange* pPX)
{
ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
COleControl::DoPropExchange(pPX);
PX_String(pPX, _T("Caption"), m_Caption, _T("Caption"));
}
BSTR CMyActiveXCtrl::GetCaption()
{
CString strResult;
strResult=m_Caption;
return strResult.AllocSysString();
}
void CMyActiveXCtrl::SetCaption(LPCTSTR lpszNewValue)
{
SetModifiedFlag();
m_Caption=lpszNewValue;
BoundPropertyChanged(DISPID_CAPTION);
}
Keywords: kbbug kbctrl kbfix kbintl kbintldev kbnoupdate kbvc600fix kbvs600fix kbwizard KB185671