PW V8i SDK - AAHOOK_CHANGE_DOCUMENT_FILE not working as expected

We have custom modules built for V8 2004 that we are now porting to V8i. The code works fine in V8 2004, and when recompiled in V8i doesn't report any error, but we've lost some functionality for no readily apparent reason.

Specifically, we have a hook function that is added via

aaApi_AddHook (AAHOOK_CHANGE_DOCUMENT_FILE, AAPREHOOK, HookAddDeleteChangeDocumentFile_Pre)

What is supposed to (used to) happen is that HookAddDeleteChangeDocumentFile_Pre() checks aParam2 for AAOPER_DOC_CHANGE_FILE operation. If that operation occurs (such as renaming a file), it does some other checks, and if they pass, returns AAHOOK_SUCCESS and allows the user action (rename in this example), otherwise, throws an error message and AAHOOK_ERROR returned, preventing the file rename.

In debugging this, it appears that a file rename event handled through the document Properties dialog is no longer hooked to AAHOOK_CHANGE_DOCUMENT_FILE, as was the case in V8 2004. The hook function is never called.

Is there another hook/operation to use instead? Or is this no longer possible in V8i? Thanks.

 

  • Thank you Michael and Gray. I was able to create a new hook using the information provided, and now it works perfectly.

    Jeff

    Please note that I post here on a voluntary basis and am not a Bentley employee. 

  • aaApi_ModifyDocument2 will be called when you rename a document in the document name section in document properties dialog, or when you rename a file in the Rename file dialog in Advanced dropdown.

    Gray

     

  • You can check the ulMask for AADOCMODM_FILE_NAME.
    I attached a sample that will show this, I hope this helps.

    Mike

    case AAHOOK_MODIFY_DOCUMENT:
    {
    AADOC_PARAM* param = (AADOC_PARAM*)aParam1;

    if ((param->ulMask & AADOCMODM_FILE_NAME))
    message = "MODIFY DOCUMENT EVENT - Rename DOC";
    else
    message = "MODIFY DOCUMENT EVENT";

    //Display data
    MessageBox (NULL, message, _T("AAHOOK_MODIFY_DOCUMENT"), MB_OK);

    status = AAHOOK_CALL_DEFAULT;
    }
    break;



  • Thanks so much for the information. This helps, but I still have some questions.

    Is there a way to single out a file rename action in AAHOOK_MODIFY_DOCUMENT? According to the documentation. aaApi_ModifyDocument ( ) takes several parameters that can be changed, one of which is the file name. Do I just need to look at the AADOC_PARAM structure passed in aParam1 to see if lpctstrFileName has changed (and is it NULL if it went unchanged)?

    Also, can you tell me what API function is called in PWE when you rename a file by selecting the document Properties dialog for a document, and then in the File section (on the General tab) click on the Advanced button and select Rename, which pops a Rename file dialog. Is it one of the aaApi_ChangeDocumentFile functions, aaApi_ModifyDocument, or an internal PWE function not available in the API?

    Jeff

    Please note that I post here on a voluntary basis and am not a Bentley employee. 

  • AAHOOK_CHANGE_DOCUMENT_FILE hook is activated by aaApi_ChangeDocumentFile, aaApi_ChangeDocumentFile2 or aaApi_ChangeDocumentFile3 functions. The propose of these functions is to add or replace file of a document. Also, aaApi_ChangeDocumentFile3 can be used to change file name only, exactly this situation was handled by your hook function.


    However, aaApi_ChangeDocumentFile3 is not single way to change filename. aaApi_ModifyDocument or aaApi_ModifyDocument2 are more common functions for modifying document properties, including file name.
    What has happened in V8i implementation is that in some cases aaApi_ChangeDocumentFile3 was replaced by aaApi_ModifyDocument function.


    You need to implement another hook for aaApi_ModifyDocument , so that will cover both scenarios. It is AAHOOK_MODIFY_DOCUMENT hook , and aParam2 must be AAOPER_DOC_MODIFY.

     

    Dalius