Message 1 of 3
OnFileDirty event
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
Some files () should not be modified by user explicitly. To handle this in the addin we have handled FileAccessEvents.OnFileDirty event and in this we show an error message to the user that the file can not be modifie.
However the problem is this event is firing for all the other reasons like references change whereas we only want to handle the event when user explicitly performs some action (modify geometry)
We have tried the below code and that does not seem to work. Any suggestions?
STDMETHODIMP CInventorEvents::OnFileDirty(BSTR RelativeFileName,BSTR LibraryName,SAFEARRAY * * CustomLogicalName,BSTR FullFileName,struct Document * DocumentObject,enum EventTimingEnum BeforeOrAfter,struct NameValueMap * Context,enum HandlingCodeEnum * HandlingCode) { _bstr_t bstrFullFileName = DocumentObject->FullFileName; /*public enum CommandTypesEnum { kShapeEditCmdType = 1, kQueryOnlyCmdType = 2, kFileOperationsCmdType = 4, kFilePropertyEditCmdType = 8, kUpdateWithReferencesCmdType = 16, kNonShapeEditCmdType = 32, kEditMaskCmdType = 57, kReferencesChangeCmdType = 64, kSchemaChangeCmdType = 128, }*/ _variant_t val = Context->GetItem(_variant_t(L"ReasonsForChange")); logFile.Writeln(val.iVal); if( ((val.iVal & 16) == 16) || ((val.iVal & 64) == 64)) { //"Reference change. Ignore"; *HandlingCode = kEventNotHandled; return S_OK; } if( strFullFileName.IsEmpty() ) { *HandlingCode = kEventNotHandled; return S_OK; } switch( BeforeOrAfter ) { case kBefore: { // show a message to the user that file can not be modified. *HandlingCode = kEventHandled; } break; case kAfter: break; } return S_OK; }
Thank You,
Rakesh