Analyzing the Dispatch Interface Name

The document template string resource is where MFC expects to find  information about an application or a particular application’s documents, such as default filename extensions. If the application is an Automation server, MFC also expects to find information specific to Automation.

The name of the dispatch interface is a literal string that Automation clients use to access the Automation server application. If you open the application’s string resource, you can look at, or change, this string.

To examine the document template string resource

The ID for the string resource that contains the name of the dispatch interface is IDR_<Doc Type Name>TYPE, created by AppWizard, which is registered in the application’s InitInstance member function. The Doc Type Name appears in the Advanced Options dialog box (which you open by clicking Advanced in the MFC AppWizard – Step 4 of 6 dialog box). For AutoClik, the string ID is IDR_ACLICKTYPE.

To view the strings for a particular resource, open the String Properties dialog box.

To open the string properties page

You can see the strings for IDR_ACLICKTYPE in the Caption area as illustrated in the figure below.

IDR_ACLICKTYPE in the String Editor

This string resource consists of several strings separated by newline characters (\n). It contains the following strings:

\nAClick\nAClick\nAutoClick Files (*.ack)\n.ACK\nAutoClick.Document\nAClick Document

The string "AutoClick.Document" is the name, provided by AppWizard, (and modified by you) of the Automation object, or dispatch interface. You modified this value in the Advanced Options dialog box (which you open by clicking Advanced in the MFC AppWizard – Step 4 of 6 dialog box). Autodriv refers to this object name in the OnCreate function of the dialog class:

int CAutoDrivDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
   if (CDialog::OnCreate(lpCreateStruct) == -1)
      return -1;   // fail
   
   if (!m_autoClikObject.CreateDispatch(_T("AutoClick.Document")))
   {
      AfxMessageBox(IDP_CANNOT_CREATE_AUTOCLICK);
      return -1;   // fail
   }
   m_autoClikObject.ShowWindow();

   return 0;   // success
}

Note   An Automation server can have more than one Automation object. AutoClik will have two Automation objects. The initial AppWizard-created application has only one Automation object, which is the one identified in the document template string resource described above.