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
The Add Method dialog box appears.
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();
}
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.
void, or select it from the drop-down list box.
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();
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.
Refresh at the end of AutoClickDoc.cpp.Leave the dispatch map entry created by ClassWizard:
afx_msg void Refresh( );
There are two more methods to implement: SetAllProps and ShowWindow.