Skip to content

Latest commit

 

History

History
 
 

ASYNC

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

<html><head><title>ASYNC Attributes Sample: Downloads Data Asynchronously</title></head><body><h1>ASYNC Attributes Sample: Downloads Data Asynchronously</h1><div id="mainSection"><div id="mainBody"><div id="allHistory" class="saveHistory" onsave="saveAll()" onload="loadAll()"></div><p /><p>The ASYNC attributes sample creates a control that downloads data asynchronously from a URL. The control implements the <b>IBindStatusCallback</b> interface. Typically, you asynchronously download large binary objects or properties. This allows the control's user interface to remain unblocked during potentially lengthy network operations. The use of asynchronous downloading also gives the user a chance to abort the download. ATL uses WinInet functions internally to implement asynchronous downloading.</p><p>The ASYNC 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 and run this sample</h4><div class="subSection"><ol><li><p>Open the solution file async.sln.</p></li><li><p>From the <b>Build</b> menu, click <b>Build Solution</b>.</p></li><li><p>After the sample builds, open ATLAsync.htm in your Web browser and follow the instructions. This sets the ASYNC control's <b>URL</b> property and starts the download. As data is downloaded, you will see it displayed in the ASYNC control.</p></li></ol></div><p>You can test the control in the ActiveX Control Test Container. For details on accessing Test Container and using it to test a control, see <MSHelp:link keywords="626867CF-FE53-4C30-8973-55BB93EF3917" tabindex="0" >Testing Properties and Events with Test Container</MSHelp:link>.</p></div><h1 class="heading">How the Sample Works</h1><div id="sectionSection1" class="seeAlsoNoToggleSection"><p>ASYNC creates a subclassed edit control with one property called <b>URL</b>. The <b>URL</b> property is a <b>BSTR</b> that represents a URL that points to data. The ASYNC sample uses the ATL <b>CBindStatusCallback</b> class to implement asynchronous downloading. When the control user sets the URL property, ASYNC creates a <b>CBindStatusCallback</b> object. The <b>CBindStatusCallback::StartAsyncDownload</b> method is then called and passed both the URL and a pointer to a callback function. This function, <b>CAtlAsync::OnData</b>, is called by the <b>CBindStatusCallback</b> object and is passed the binary data from the URL as it is received. <b>CAtlAsync::OnData</b> simply sends the received data to the subclassed edit control, where it is displayed.</p><p>For an example of how to superclass Windows controls using ATL, see the ATL SubEdit sample.</p></div><h1 class="heading">Attributes</h1><div id="sectionSection2" class="seeAlsoNoToggleSection"><p>This sample uses the following attributes:</p><p>coclass, default, dual, helpstring, id, implements_category, in, module, object, out, pointer_default, progid, propget, propput, registration_script, retval, threading, uuid, version, vi_progid</p></div><h1 class="heading">Keywords</h1><div id="sectionSection3" class="seeAlsoNoToggleSection"><p>This sample uses the following keywords:</p><p>ALT_MSG_MAP; ATLTRACE ; BEGIN_COM_MAP; BEGIN_MSG_MAP; BEGIN_OBJECT_MAP; BEGIN_PROPERTY_MAP; CBindStatusCallback::Download; CComBSTR::Append; CComCoClass; CComControl; CComModule::GetClassObject; CComModule::GetLockCount; CComModule::Init; CComModule::RegisterServer; CComModule::Term; CComModule::UnregisterServer; CComObjectRoot; COM_INTERFACE_ENTRY; COM_INTERFACE_ENTRY_IMPL; DECLARE_REGISTRY_RESOURCEID; DisableThreadLibraryCalls; DLL_PROCESS_ATTACH; DLL_PROCESS_DETACH; DllMain; END_COM_MAP; END_MSG_MAP; END_OBJECT_MAP; END_PROPERTY_MAP; IDataObjectImpl; IDispatchImpl; IObjectSafetyImpl; IOleControlImpl; IOleInPlaceActiveObjectImpl; IOleInPlaceObjectWindowlessImpl; IOleInPlaceObjectWindowlessImpl::SetObjectRects; IOleObjectImpl; IPerPropertyBrowsingImpl; IPersistPropertyBagImpl; IPersistStorageImpl; IPersistStreamInitImpl; IProvideClassInfo2Impl; IQuickActivateImpl; IsWindow; IViewObjectExImpl; MESSAGE_HANDLER; OBJECT_ENTRY; PROP_ENTRY; SendMessage; 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 :ASYNC Attributes Sample: Downloads Data Asynchronously">comments</a> about this topic to Microsoft.
      </div></div></body></html>