Skip to content

Latest commit

 

History

History
 
 

AtlDuck

<!--TO READ THIS HELP FILE, RIGHT-CLICK ON THE FILE NAME IN THE
    SOLUTION EXPLORER PANE AND SELECT "VIEW IN BROWSER"-->

<html><head><title>ATLDuck Attributes Sample: Uses Connection Points with ATL</title></head><body><h1>ATLDuck Attributes Sample: Uses Connection Points with ATL</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"></div><p /><p>The ATLDuck attributes sample consists of two projects: atlduck and duck. The duck project creates an instance of an object that implements the <code>IDuckInt</code> interface. This interface includes four member functions: <code>Flap</code>, <code>Paddle</code>, <code>Quack</code>, and <code>Walk</code>.</p><p>The second project, atlduck, has a connection point for the <code>IDuckInt</code> interface (that is, it knows how to use the interface but does not implement it). Only a single instance of this object will be created. Once the connection is established between the two applications, atlduck will call the functions in the <code>IDuckInt</code> interface for sinks that have called <b>IConnectionPoint::Advise</b>.</p><p>Various IDL, COM, and compiler attributes are demonstrated in ATLDuck, including aggregatable, event_source, and event_receiver. The <code>DuckInt</code> class is made unaggregratable by specifying the aggregratable("never") attribute. The <code>DuckDoer</code> class is set up as a com event_source, and the <code>DuckInt</code> class as a com event_receiver, without layout dependent=true.</p><p>The ATLDuck sample is the nonattributed version of this sample.</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Security Note </th></tr><tr><td><p>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.</p></td></tr></table></div><h1 class="heading">Building and Running the Sample</h1><div id="sectionSection0" class="seeAlsoNoToggleSection"><h4 class="subHeading">To build this sample</h4><div class="subSection"><ol><li><p>Open the solution file atlduck.sln.</p></li><li><p>From the <b>Build</b> menu, click <b>Build Solution</b>. This will build both projects and perform the necessary registration. The following files will be created: </p><ul><li><p>atlduck.exe, an EXE server</p></li><li><p>duck.exe, an EXE client</p></li></ul></li></ol></div><h4 class="subHeading">To run this sample</h4><div class="subSection"><ol><li><p>From the <b>Debug</b> menu, click <b>Start Without Debugging</b>. This will start the atlduck server and one instance of the duck client. To run more than one client, navigate to the directory where duck.exe is located and run it manually from the command prompt.</p></li><li><p>A dialog box appears. In the dialog box, click the button <b>Create DoDuck Object</b>. When you click this button, the application creates an instance of an object with class <code>ID CLSID_DuckDoer</code>, running atlduck. </p></li><li><p>A new dialog box, issued by atlduck.exe, appears. This dialog box shows a button for each function in the <code>IDuckInt</code> interface, as well as a list box with the connections to active sinks and their cookies. From the duck dialog boxes, you can either <b>Advise</b> or <b>Unadvise</b> the connection point. Depending on your choice, you will receive or not receive notifications from the sources. The notification, when you receive it, will show in the status edit field. Additionally, ATLDuck demonstrates the value of the cookie supplied by the connection point when the connection is advised.</p></li></ol></div></div><h1 class="heading">Attributes</h1><div id="sectionSection1" class="seeAlsoNoToggleSection"><p>This sample uses the following attributes:  </p><ul><li><p><b>ATLDuck</b>   aggregatable, coclass, dispinterface, event_source, exe, helpstring, id, module, name, progid, uuid, vi_progid</p></li><li><p><b>ATLDuck/Duck</b>   aggregatable, coclass, default, dispinterface, event_receiver, exe, helpstring, id, iid_is, in, module, name, object, out, progid, unique, uuid, version, vi_progid</p></li></ul></div><h1 class="heading">Classes and Keywords</h1><div id="sectionSection2" class="seeAlsoNoToggleSection"><p>The sample use the following classes:</p><p>CDialog (MFC), CComObject (ATL), IConnectionPointImpl&lt;CDuckDoer&gt; (ATL)</p><p>This sample uses the following keywords:</p><p>_ASSERTE; _tcslen; _VERIFY; AddRef; Advise; BEGIN_COM_MAP; BEGIN_CONNECTION_POINT_MAP; BEGIN_MSG_MAP; BEGIN_OBJECT_MAP; CComCoClass; CComModule::Unlock; CComObjectRootEx; CDialogImpl; CenterWindow; CoInitialize; COM_INTERFACE_ENTRY; COM_INTERFACE_ENTRY_IMPL; COMMAND_HANDLER; COMMAND_ID_HANDLER; CONNECTION_POINT_ENTRY; CoSuspendClassObjects; CoUninitialize; Create; DECLARE_CLASSFACTORY_SINGLETON; DECLARE_NOT_AGGREGATABLE; DECLARE_REGISTRY_RESOURCEID; DestroyWindow; DispatchMessage; EnableWindow; END_COM_MAP; END_CONNECTION_POINT_MAP; END_MSG_MAP; END_OBJECT_MAP; ExitProcess; FindConnectionPoint; GetCommandLine; GetDC; GetDlgItem; GetMessage; GetTextExtentPoint32; IConnectionPointContainerImpl; IConnectionPointImpl; Init; IsWindowVisible; MESSAGE_HANDLER; MessageBox; OBJECT_ENTRY; OleInitializeCoCreateInstance; OnCancel; OnFlap; OnInitDialog; OnOK; OnPaddle; OnWalk OnQuack; PostThreadMessage; QueryInterface; RecalcListboxExtent; RegisterClassObjects; RegisterServer; reinterpret_cast; ReleaseDC; RevokeClassObjects; SendMessage; SetOwner; SetWindowText; ShowStatus; ShowWindow; Unadvise; UnregisterServer; UNUSED_ALWAYS; UpdateRegistryFromResource; UpdateWindow; USES_CONVERSION</p><div class="alert"><table width="100%" cellspacing="0" cellpadding="0"><tr><th align="left">Note </th></tr><tr><td><p>Some of the 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. </p></td></tr></table></div></div></div><div id="footer"><div class="footerLine"></div>
          © Microsoft Corporation. All rights reserved.  Send <a href="mailto:DevDocs@microsoft.com?subject=Documentation Feedback :ATLDuck Attributes Sample: Uses Connection Points with ATL">comments</a> about this topic to Microsoft.
      </div></div></body></html>