CDINFO Attributes Sample: Plays and Displays Information About CD Audio Tracks

The CDINFO attributes sample uses the Media Control Interface (MCI) APIs to retrieve the length of the audio tracks on the CD currently in your CD-ROM drive. CDINFO then draws a piechart to display track length. CDINFO also demonstrates how to use the ToolTip common control to implement a tool tip. This tool tip displays the audio track length corresponding to the cursor's location in the piechart.

Note

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.

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 and Running the Sample

To build and run this sample

  1. Open the solution file CDInfo.sln.

  2. From the Build menu, click Build.

  3. After the sample builds, open CDInfo.htm in your Web browser and follow its instructions.

Properties and Methods

The control implements the following methods:

Read   Reads the track length information from the CD currently in the drive and displays the information in the form of a piechart.

Redraw   Redraws the piechart for the current CD.

Play   Starts playing the CD at the specified track number. The control also rotates the piechart so that the track playing is at the top.

The following properties are available:

Tracks   The number of tracks on the CD

Length   The length of the specified track number in seconds

TotalLength   The total length of the CD in seconds

Attributes

This sample uses the following attributes:

coclass, default, dispinterface, dual, emitidl, event_source, helpstring, id, implements_category, in, module, object, out, pointer_default, progid, propget, propput, registration_script, retval, threading, uuid, version, vi_progid

Keywords

This sample uses the following keywords:

BEGIN_COM_MAP; BEGIN_CONNECTION_POINT_MAP; BEGIN_MSG_MAP; BEGIN_OBJECT_MAP; BEGIN_PROPERTY_MAP; CComCoClass; CComControl; CComObjectRoot; COM_INTERFACE_ENTRY; COM_INTERFACE_ENTRY_IMPL; CONNECTION_POINT_ENTRY; CProxyCDEvents; CreateBrushIndirect; CreateRectRgn; DECLARE_REGISTRY_RESOURCEID; DeleteDC; DeleteObject; DrawCD; Ellipse; END_COM_MAP; END_CONNECTION_POINT_MAP; END_MSG_MAP; END_OBJECT_MAP; END_PROPERTY_MAP; IConnectionPointContainerImpl; IConnectionPointImpl; IDataObjectImpl; IDispatchImpl; IOleControlImpl; IOleInPlaceActiveObjectImpl; IOleInPlaceObjectWindowlessImpl; IOleLinkImpl; IOleObjectImpl; IPerPropertyBrowsingImpl; IPersistStorageImpl; IPersistStreamInitImpl; IPropertyNotifySinkCP; IProvideClassInfo2Impl; IQuickActivateImpl; IRunnableObjectImpl; IViewObjectExImpl; LineTo; mciSendCommand; MESSAGE_HANDLER; MoveToEx; OBJECT_ENTRY; ReduceRect; RelayEvent; SelectClipRgn; SelectObject; VariantInit; ZeroMemory

See Also

Other Resources

ATL Attributes Samples