| |
// AtlDLG.cpp : implémentation de CAtlDLG "this is an Atl class inserted in an MFC project
#include "stdafx.h"
#include "AtlDLG.h"
#include "Shlobj.h"
LRESULT CBrowse::OnAdd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
LRESULT hr;
IWorkspaceFactoryPtr ipShapeFileFactory(CLSID_ShapefileWorkspaceFactory);
IWorkspacePtr ipWorkspace;
ipShapeFileFactory->OpenFromFile(bstrWorkspacePath, 0, &ipWorkspace);
IFeatureWorkspacePtr ipFeatureWksp(ipWorkspace);
IFeatureClass *ipFeatureClass;
ipFeatureWksp->OpenFeatureClass(bstrFeatureClassName, &ipFeatureClass);
////////////****** Find Field index ***********
IFieldsPtr ipFields;
ipFeatureClass->get_Fields(&ipFields);
long ind;
ipFields->FindField(L"GenVor", &ind);
//////////// ******** Put value at field(index) of all features ******* ///////
long ipNumFeatures;
IFeature *ipFeature;
ipFeatureClass->FeatureCount(0,&ipNumFeatures);
for(long i=0; i< ipNumFeatures; i++)
{
ipFeatureClass->GetFeature(i,&ipFeature);
VARIANT ipValue;
::VariantInit(&ipValue);
ipValue.vt=VT_BSTR;
CComBSTR Data= L"MyData";
ipValue.bstrVal = Data;
hr= ipFeature->put_Value(ind, ipValue);
hr = ipFeature->Store();
}
return hr;
} |