Compartir a través de


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 intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To get samples and instructions for installing them:

To access samples from Visual Studio

  • On the Help menu, click Samples.

    By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.

  • For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.

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