Export (0) Print
Expand All

IMAGE Sample: Creates an ActiveX Control That Downloads Asynchronously 

Download sample

The IMAGE sample demonstrates how to use MFC to build an ActiveX control that is capable of downloading data asynchronously. The control has a property based on the CDataPathProperty class.

The IMAGE control can display a bitmap image from a BMP file (but does not support BMP files with greater than 8-bit color depth, so files containing more than 256 colors cannot be displayed.) The ImagePath property of the control provides a path to the image. If the image is large and the download takes place over a slow link, the asynchronous support built into the CDataPathProperty object managing the path becomes active and renders the data to the control's painting code without blocking other processing.

The control features a simple property page that gives access to the ImagePath property as well as the AutoSize property. The AutoSize property, if set to TRUE, automatically snaps the size of the control to the size of the image it contains. If the AutoSize property is FALSE, the automatic sizing is disabled.

The image control also implements a read-only Boolean property named ReadyState. ReadyState is TRUE if the control has successfully read and presented all the data in the image stream. ReadyState is FALSE until the control is fully initialized.

See Controls Samples for details on adding a control to the Toolbox, manually registering a control, and using the ActiveX Control Test Container.

NoteNote

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.

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.

See Also

Other Resources

MFC Samples

Community Additions

ADD
Show:
© 2014 Microsoft