源代码:
// AltLink.h : Declaration of the CAltLink#ifndef __ALTLINK_H_
#define __ALTLINK_H_#include "resource.h"       // main symbols
#include <atlctl.h>
/////////////////////////////////////////////////////////////////////////////
// CAltLink
class ATL_NO_VTABLE CAltLink : 
public CComObjectRootEx<CComSingleThreadModel>,
public IDispatchImpl<IAltLink, &IID_IAltLink, &LIBID_LINKLib>,
public CComCompositeControl<CAltLink>,
public IPersistStreamInitImpl<CAltLink>,
public IOleControlImpl<CAltLink>,
public IOleObjectImpl<CAltLink>,
public IOleInPlaceActiveObjectImpl<CAltLink>,
public IViewObjectExImpl<CAltLink>,
public IOleInPlaceObjectWindowlessImpl<CAltLink>,
public ISupportErrorInfo,
public IConnectionPointContainerImpl<CAltLink>,
public IPersistStorageImpl<CAltLink>,
public ISpecifyPropertyPagesImpl<CAltLink>,
public IQuickActivateImpl<CAltLink>,
public IDataObjectImpl<CAltLink>,
public IProvideClassInfo2Impl<&CLSID_AltLink, &DIID__IAltLinkEvents, &LIBID_LINKLib>,
public IPropertyNotifySinkCP<CAltLink>,
public CComCoClass<CAltLink, &CLSID_AltLink>
{
public:
CAltLink()
{
m_bWindowOnly = TRUE;
CalcExtent(m_sizeExtent);
}DECLARE_REGISTRY_RESOURCEID(IDR_ALTLINK)DECLARE_PROTECT_FINAL_CONSTRUCT()BEGIN_COM_MAP(CAltLink)
COM_INTERFACE_ENTRY(IAltLink)
COM_INTERFACE_ENTRY(IDispatch)
COM_INTERFACE_ENTRY(IViewObjectEx)
COM_INTERFACE_ENTRY(IViewObject2)
COM_INTERFACE_ENTRY(IViewObject)
COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceObject)
COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
COM_INTERFACE_ENTRY(IOleControl)
COM_INTERFACE_ENTRY(IOleObject)
COM_INTERFACE_ENTRY(IPersistStreamInit)
COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
COM_INTERFACE_ENTRY(IQuickActivate)
COM_INTERFACE_ENTRY(IPersistStorage)
COM_INTERFACE_ENTRY(IDataObject)
COM_INTERFACE_ENTRY(IProvideClassInfo)
COM_INTERFACE_ENTRY(IProvideClassInfo2)
END_COM_MAP()BEGIN_PROP_MAP(CAltLink)
PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
// Example entries
// PROP_ENTRY("Property Description", dispid, clsid)
// PROP_PAGE(CLSID_StockColorPage)
END_PROP_MAP()BEGIN_CONNECTION_POINT_MAP(CAltLink)
CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
END_CONNECTION_POINT_MAP()BEGIN_MSG_MAP(CAltLink)
CHAIN_MSG_MAP(CComCompositeControl<CAltLink>)
MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
END_MSG_MAP()
// Handler prototypes:
//  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
//  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
//  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);BEGIN_SINK_MAP(CAltLink)
//Make sure the Event Handlers have __stdcall calling convention
END_SINK_MAP() STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
{
if (dispid == DISPID_AMBIENT_BACKCOLOR)
{
SetBackgroundColorFromAmbient();
FireViewChange();
}
return IOleControlImpl<CAltLink>::OnAmbientPropertyChange(dispid);
}// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
{
static const IID* arr[] = 
{
&IID_IAltLink,
};
for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
{
if (InlineIsEqualGUID(*arr[i], riid))
return S_OK;
}
return S_FALSE;
}// IViewObjectEx
DECLARE_VIEW_STATUS(0)// IAltLink
public: enum { IDD = IDD_ALTLINK }; LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
// TODO : Add Code for message handler. Call DefWindowProc if necessary.
return 0;
}
private:   
CAxWindow  *m_pView;               // IE control to hold WMP OCX
CComPtr<IAxWinHostWindow>       spHost;
    CComPtr<IWMPPlayer4>            m_spPlayer;       // Player
    CComPtr<IWMPMediaCollection>    m_spMC;           // MediaCollection object
    CComPtr<IWMPPlaylistCollection> m_spPC;           // PlaylistCollection object
    CComPtr<IWMPPlaylist>           m_spSavedPlaylist;    
};#endif //__ALTLINK_H_编译时提示:
ompiling resources...
Compiling...
StdAfx.cpp
Compiling...
Link.cpp
e:\newmovie\link\altlink.h(135) : error C2065: 'IWMPPlayer1' : undeclared identifier
e:\newmovie\link\altlink.h(135) : error C2955: 'CComPtr' : use of class template requires template argument list
        e:\program files\microsoft visual studio\vc98\atl\include\atlbase.h(563) : see declaration of 'CComPtr'
e:\newmovie\link\altlink.h(135) : fatal error C1903: unable to recover from previous error(s); stopping compilation
AltLink.cpp
e:\newmovie\link\altlink.h(135) : error C2065: 'IWMPPlayer1' : undeclared identifier
e:\newmovie\link\altlink.h(135) : error C2955: 'CComPtr' : use of class template requires template argument list
        e:\program files\microsoft visual studio\vc98\atl\include\atlbase.h(563) : see declaration of 'CComPtr'
e:\newmovie\link\altlink.h(135) : fatal error C1903: unable to recover from previous error(s); stopping compilation
Generating Code...
Error executing cl.exe.Link.dll - 6 error(s), 0 warning(s)