AUTOCLIK Sample: Automation Server Application

The AUTOCLIK sample is a simple Automation (formerly OLE Automation) server application. The autoclik solution consists of two distinct projects: the autoclik project, representing the implementation of the automation server, and the autodriv project, representing the client side that drives the sample.

AUTOCLIK illustrates the following:

  • Automation starter code created by the application wizard.

  • Option for creating automation-enabled CCmdTarget-derived classes and for adding automation properties and methods.

  • Exposing existing class members and functions to other applications using Automation.

  • Multiple dispatch interfaces in a single Microsoft Foundation Class Library (MFC) application.

Security noteSecurity Note:

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

To get samples and instructions for installing them:

  • On the Visual Studio Help menu, click Samples.

    For more information, see Visual Studio Samples.

  • The most recent version and complete list of samples is available online from the Visual Studio 2008 Samples page.

  • You can also locate samples on your computer's hard disk. By default, samples and a Readme file are copied into a folder under \Program Files\Visual Studio 9.0\Samples\. For Express editions of Visual Studio, all samples are located online.

Building the Sample

To build the AUTOCLIK sample

  1. Open the solution autoclik.sln.

  2. On the Build menu, click Build.

Running the Sample

After registering the AUTOCLIK application, you are ready to run the AUTODRIV application. Building the solution from the IDE will perform the AUTODRIV registration automatically before AUTODRIV is run. Run the AUTODRIV application. It automatically launches the AUTOCLIK application and creates a document. To test the capabilities of this sample, manipulate the document using the interface provided by the AUTODRIV application.

The AUTODRIV sample is a simple Automation client application that drives the AUTOCLIK sample. The AUTODRIV sample is a good demonstration of writing an automation driver application. It uses the COleDispatchDriver::SetProperty and COleDispatchDriver::GetProperty to manipulate the controls through automation.

For details on how to use AUTOCLIK and AUTODRIV together using Remote Automation, see Running Remote Automation Using AUTOCLIK and AUTODRIV.

Keywords

The AUTOCLIK automation server sample demonstrates the following keywords:

AfxMessageBox; AfxOleInit; AfxOleLockApp; AfxOleUnlockApp; CCmdTarget::EnableAutomation; CCmdTarget::FromIDispatch; CCmdTarget::GetIDispatch; CCmdTarget::OnFinalRelease; CControlBar::EnableDocking; CControlBar::GetBarStyle; CControlBar::SetBarStyle; CDialog::DoModal; CDocument::GetFirstViewPosition; CDocument::GetNextView; CDocument::OnNewDocument; CDocument::SetModifiedFlag; CDocument::UpdateAllViews; CFrameWnd::ActivateFrame; CFrameWnd::DockControlBar; CFrameWnd::EnableDocking; CFrameWnd::LoadFrame; CObject::AssertValid; CObject::Dump; CObject::IsKindOf; CObject::Serialize; COleTemplateServer::ConnectTemplate; COleTemplateServer::UpdateRegistry; CStatusBar::Create; CStatusBar::SetIndicators; CToolBar::Create; CView::DoPreparePrinting; CView::GetDocument; CView::OnBeginPrinting; CView::OnDraw; CView::OnEndPrinting; CView::OnPreparePrinting; CWinApp::AddDocTemplate; CWinApp::EnableShellOpen; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWinApp::RegisterShellFileTypes; CWnd::DoDataExchange; CWnd::GetParentFrame; CWnd::OnCreate; CWnd::OnLButtonDown; CWnd::PreCreateWindow; CWnd::ShowWindow; CWnd::UpdateWindow; DragAcceptFiles; ShowWindow; TextOut

The AUTODRIV Automation Client sample demonstrates the following keywords:

AfxGetApp; AfxMessageBox; AfxOleInit; CDC::DrawIcon; CDC::GetSafeHdc; CDialog::DoModal; CDialog::EndDialog; COleDispatchDriver::AttachDispatch; COleDispatchDriver::GetProperty; COleDispatchDriver::InvokeHelper; COleDispatchDriver::SetProperty; CRect::Height; CRect::Width; CWinApp::InitInstance; CWinApp::LoadStdProfileSettings; CWnd::DoDataExchange; CWnd::GetClientRect; CWnd::IsIconic; CWnd::OnClose; CWnd::OnCreate; CWnd::OnPaint; CWnd::OnQueryDragIcon; CWnd::SendMessage; CWnd::ShowWindow; CWnd::UpdateData; GetSystemMetrics; LoadIcon; ShowWindow

Note

Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.

See Also

Other Resources

MFC Samples