Modifying the Add-In Sample Application

The Add-In sample application can be easily modified to gain a better understanding of the capabilities of the ExpressAddin. This section explains how to go about making modifications to the sample application source code.

NOTE The Sample Add-In files are installed on the system as read-only. Developers should set the file permissions to writable prior to editing.

  1. In the file AddInSampleAppDlg.cpp, modify the applicationName, useUnifiedLogin, and applicationMimeTypes settings of the Startup method to meet your application requirements:
  2. ...
       _bstr_t AddinSampleDlg::ComposeStartupXml()
       {
          // Specify the startup XML for the ApplicationName,  
          // the ApplicationID, and the array of Application Mimetypes.
          _bstr_t startupXml = _T( "" );
          startupXml +=   _T("<?xml version=\"1.0\" ?>");
          startupXml +=   _T("<object key=\"addInConfiguration\" version=\"1.0\">");
          startupXml +=      _T("<setting key=\"applicationName\">AddinSampleApp</setting>");
          startupXml +=      _T("<setting key=\"useUnifiedLogin\">true</setting>");
          startupXml +=      _T("<array key=\"applicationMimeTypes\">");
          startupXml +=         _T("<value>text/xml</value>");
          startupXml +=         _T("<value>text/html</value>");
          startupXml +=         _T("<value>text/txt</value>");
          startupXml +=         _T("<value>text/plain</value>");
          startupXml +=         _T("<value>application/msword</value>");
          startupXml +=      _T("</array>");
          startupXml +=   _T("</object>");
          return startupXml;
       }
    ...
  3. In the file Eventhandler.cpp, modify each event handler that is required by the commands you intend to support in your application. For example, if you intend to support the Insert > Insert a a Hyperlink command, you would need to customize the following event handler methods:
  4. ...
    // --- Event handler implementations ---
    HRESULT __stdcall CEventHandler::OnAppBeginWaitCursor()
    {
    	// Display the application's wait cursor.
    	AfxGetMainWnd()->BeginWaitCursor();
    	return S_OK;
    }
    HRESULT __stdcall CEventHandler::OnAppEndWaitCursor()
    {
    	// End the application's wait cursor.
    	AfxGetMainWnd()->EndWaitCursor();
    	return S_OK;
    }
    HRESULT __stdcall CEventHandler::OnAppExistsActiveDocument( VARIANT_BOOL *pExistsActiveDocument )
    {
    	// Query the document object to determine if there is an active document.
    	if( m_pDocument->ExistsActiveDocument() )
    	{
    		*pExistsActiveDocument = VARIANT_TRUE;
    	}
    	else
    	{
    		*pExistsActiveDocument = VARIANT_FALSE;
    	}
    	return S_OK;
    }
    HRESULT __stdcall CEventHandler::OnAppInsertHyperlink( BSTR urlName 
    {
       m_pDocument->InsertHyperlink( urlName );
       return S_OK;
    }
    ...
  5. In the file stdafx.h, modify the path in the #import statement to point to the correct location of the FnAppIntExpressAddin.dll file.
  6. Build the modified sample application code.
  7. Run the modified sample application.