Implementing Autoclik’s RefreshWindow

In the following procedure, you'll implement RefreshWindow as a method. RefreshWindow updates the view according to the current values of m_pt and m_str. The RefreshWindow method is the Refresh member function originally implemented in Step 1. Here you directly expose the Refresh member function, just as you directly exposed the m_str member variable of CAutoClickDocument.

To directly expose the Refresh member function in the dispatch interface

  1. From the View menu, click ClassWizard.

  2. Click the Automation tab.

  3. In the Class name box, select CAutoClickDoc, if it is not already selected.

  4. Click Add Method.

    The Add Method dialog box appears.

  5. In the External name box, type RefreshWindow.

    This is the name that the Automation client, Autodriv, uses to refer to the method, as in the following code:

    void CAutoDrivDlg::OnRefresh() 
    {
    m_autoClikObject.RefreshWindow();
    }
    
  6. In the Internal name box, replace the proposed RefreshWindow with Refresh.

    Refresh is the name of the member function you implemented in Step 1. You do not need to make the Internal name the same as the External name, even though ClassWizard proposes that you do so.

  7. In the Return type box, type void, or select it from the drop-down list box.

  8. Click OK.

    This returns you to the Automation tab. The new method, RefreshWindow, is shown in the Name list. The gray glyph with an “M” in it indicates that this is a method. The Implementation box shows:

    void Refresh();
    
  9. Click the Edit Code button.

    Because Refresh was selected in the Automation tab, ClassWizard takes you to the implementation of Refresh in AutoClickDoc.cpp:

    void CAutoClickDoc::Refresh()
    {
    UpdateAllView(NULL);
    SetModifiedFlag();
    }
    

    However, you implemented the Refresh member function in Step 1; ClassWizard was not aware of that, so it implemented a second stub member function at the end of AutoClickDoc.cpp.

    You will need to remove this second stub implementation. This is similar to how you removed the redundant declaration of m_str earlier.

  10. Remove ClassWizard’s redundant (and empty) implementation of Refresh at the end of AutoClickDoc.cpp.

  11. Remove the redundant declaration in the public Implementation section of AutoClickDoc.h.

    Leave the dispatch map entry created by ClassWizard:

    afx_msg void Refresh( );
    

There are two more methods to implement: SetAllProps and ShowWindow.