title: Can't Call Methods in MFC ActiveX
body: <p>I create a MFC ActiveX control with some interface methods in VS2012, and these methods work well.
  When I add some new methods to the ActiveX today , <strong>i can see the new methods</strong> in "activex control test container", but <strong>i can't call them</strong>(call methods and nothing happened). This also happened in IE11 when i trying to call the method with JS. The breakpoints in these new methods will never be reached.
  The old methods behave normally, and i add the new methods in the same manner. I don't know how to figure it, can anyone help me? Thanks a lot.
  Here is the implementation of a new method.</p>
  
  <pre><code>LONG CDCMonitorControllerClientCtrl::Init(LPCTSTR config)
  {
      AFX_MANAGE_STATE(AfxGetStaticModuleState());
  
      MessageBox(_T("Call Init"));
      return 0;
  }
  </code></pre>
  
  <p>/<strong>***********************************************************************</strong>/</p>
  
  <p>I just fixed the problem.</p>
  
  <p><strong>The statement in dispatch map must appear in the same order as their dispatch IDs in the header file.</strong></p>
  
  <p>I added some events after i added the old methods. When I add a new method, VS add the dispatch statement to the end of BEGIN_DISPATCH_MAP section, which was placed after the events dispatch statements. I moved the new method's dispatch statement to the next of the last dispatch statement of old methods, everything works well.
  Here is the dispatch and events id(<strong>Init</strong> and <strong>StopListen</strong> are new methods):</p>
  
  <pre><code>enum {
      dispidStopListen = 11L,
      dispidInit = 10L,
      dispidTsapiDisconnected = 20L,
      dispidInterceptEnded = 19L,
      dispidInsertEnded = 18L,
      dispidListenEnded = 17L,
      dispidForceReleaseFailed = 16L,
      dispidForceReleseSuccess = 15L,
      dispidInterceptFailed = 14L,
      dispidInterceptSuccess = 13L,
      dispidStopInsertFailed = 12L,
      dispidStopInsertSuccess = 11L,
      dispidInsertFailed = 10L,
      dispidInsertSuccess = 9L,
      dispidStopListenFailed = 8L,
      dispidStopListenSuccess = 7L,
      dispidListenFailed = 6L,
      dispidListenSuccess = 5L,
      dispidLogoutFailed = 4L,
      dispidLogoutSuccess = 3L,
      dispidLoginFailed = 2L,
      dispidLoginSuccess = 1L,
      dispidForceLogout = 9L,
      dispidForceBusy = 8L,
      dispidForceFree = 7L,
      dispidIntercept = 6L,
      dispidForceRelease = 5L,
      dispidInsert = 4L,
      dispidListen = 3L,
      dispidMonitorLogout = 2L,
      dispidMonitorLogon = 1L
  };
  </code></pre>
  
  <p>and here is the new <strong>BEGIN_DISPATCH_MAP</strong> section:</p>
  
  <pre><code>BEGIN_DISPATCH_MAP(CDCMonitorControllerClientCtrl, COleControl)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "MonitorLogon", dispidMonitorLogon, MonitorLogon, VT_I4, VTS_BSTR VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "MonitorLogout", dispidMonitorLogout, MonitorLogout, VT_I4, VTS_BSTR VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "Listen", dispidListen, Listen, VT_I4, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "Insert", dispidInsert, Insert, VT_I4, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "ForceRelease", dispidForceRelease, ForceRelease, VT_I4, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "Intercept", dispidIntercept, Intercept, VT_I4, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "ForceFree", dispidForceFree, ForceFree, VT_I4, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "ForceBusy", dispidForceBusy, ForceBusy, VT_I4, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "ForceLogout", dispidForceLogout, ForceLogout, VT_I4, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "Init", dispidInit, Init, VT_I4, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "StopListen", dispidStopListen, StopListen, VT_I4, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "LoginSuccess", dispidLoginSuccess, LoginSuccess, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "LoginFailed", dispidLoginFailed, LoginFailed, VT_EMPTY, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "LogoutSuccess", dispidLogoutSuccess, LogoutSuccess, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "LogoutFailed", dispidLogoutFailed, LogoutFailed, VT_EMPTY, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "ListenSuccess", dispidListenSuccess, ListenSuccess, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "ListenFailed", dispidListenFailed, ListenFailed, VT_EMPTY, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "StopListenSuccess", dispidStopListenSuccess, StopListenSuccess, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "StopListenFailed", dispidStopListenFailed, StopListenFailed, VT_EMPTY, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "InsertSuccess", dispidInsertSuccess, InsertSuccess, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "InsertFailed", dispidInsertFailed, InsertFailed, VT_EMPTY, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "StopInsertSuccess", dispidStopInsertSuccess, StopInsertSuccess, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "StopInsertFailed", dispidStopInsertFailed, StopInsertFailed, VT_EMPTY, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "InterceptSuccess", dispidInterceptSuccess, InterceptSuccess, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "InterceptFailed", dispidInterceptFailed, InterceptFailed, VT_EMPTY, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "ForceReleseSuccess", dispidForceReleseSuccess, ForceReleseSuccess, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "ForceReleaseFailed", dispidForceReleaseFailed, ForceReleaseFailed, VT_EMPTY, VTS_BSTR)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "ListenEnded", dispidListenEnded, ListenEnded, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "InsertEnded", dispidInsertEnded, InsertEnded, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "InterceptEnded", dispidInterceptEnded, InterceptEnded, VT_EMPTY, VTS_NONE)
      DISP_FUNCTION_ID(CDCMonitorControllerClientCtrl, "TsapiDisconnected", dispidTsapiDisconnected, TsapiDisconnected, VT_EMPTY, VTS_NONE)
  END_DISPATCH_MAP()
  </code></pre>
  
  <p>I changed the location of <strong>Init</strong> and <strong>StopListen</strong>.</p>