We have some code to populate a CMFCPropertyGridCtrl grid with controls that is based on copied samples. We are currently using Visual Studio 2012 but intend to upgrade to VS2015 soon. A typical excerpt is:void CPropGridProps::AddPropertiesJoint(const bool bIsDataEditable, const CJointDefault& ent){    CMFCPropertyGridProperty* pProp;    {   // entity        std::auto_ptr<CMFCPropertyGridProperty> apEnt(new CMFCPropertyGridProperty(_T(Joint)));        {   // master            pProp = new CMFCPropertyGridProperty(_T(Master node), (_variant_t) (long) ent.Master, _T(Joint master node), JOINT_MASTER);            pProp->AllowEdit(bIsDataEditable);      pProp->Enable(bIsDataEditable);            apEnt->AddSubItem(pProp);        }        {   // direction            CString csDir[6] = { Lx,Ly,Lz,Lxx,Lyy,Lzz };            for (int j=0; j<6; ++j)            {                CMFCPropertyGridProperty* pBoolProp = new CMFCPropertyGridProperty(_T(Direction  + csDir[j]), COleVariant(), _T(Joint direction  + csDir[j]), JOINT_DIRECTION_X + j);                pBoolProp->AllowEdit(bIsDataEditable);  pBoolProp->Enable(bIsDataEditable);                apEnt->AddSubItem(pBoolProp);            }        }        m_pPropGrid->AddProperty(apEnt.release(), FALSE, FALSE);    }}The routines AddProperty and AddSubItem, which both take ownership of the pointers, take either auto_ptr or simple pointers.The smart pointers are auto_ptr where unique_ptr may be better.There is an awkward double cast (_variant_t) (long).The code makes no checks for AddProperty and AddSubItem failing, not even a call of VERIFY().
Populating a property grid in MFC
c++;windows