Click here to Skip to main content
Click here to Skip to main content
 
Add your own
alternative version

Using screensavers inside the Windows Media Player

, 15 Jul 2011
Wrapping a screensaver inside a WMP visualization plug-in.
sheepwmp_demo.zip
sheepwmp_src.zip
SheepWMP
SheepWMP.NET
Properties
SheepWMP.NET.csproj.user
SheepWMP.Setup
SheepWMP.Setup.vdproj
SheepWMP.def
SheepWMP.rgs
SheepWMP.vcxproj.filters
SheepWMP.vcxproj.user
//------------------------------------------------------------------------------

#ifndef __SHEEPWMP_H_
#define __SHEEPWMP_H_

//------------------------------------------------------------------------------

#include "resource.h"
#include "effects.h"
#include "SheepWMP_h.h"

//------------------------------------------------------------------------------

class ATL_NO_VTABLE CSheepWMP : 
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CSheepWMP, &CLSID_SheepWMP>,
    public IDispatchImpl<ISheepWMP, &IID_ISheepWMP, &LIBID_SHEEPWMPLib>,
    public IWMPEffects2
{
private:
    COLORREF    m_clrForeground;    // foreground color
    LONG        m_nPreset;          // current preset

    HRESULT WzToColor(const WCHAR *pwszColor, COLORREF *pcrColor);
    HRESULT ColorToWz( BSTR* pbstrColor, COLORREF crColor);
    DWORD SwapBytes(DWORD dwRet);

public:
    CSheepWMP();
    ~CSheepWMP();

DECLARE_REGISTRY_RESOURCEID(IDR_SHEEPWMP)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CSheepWMP)
    COM_INTERFACE_ENTRY(ISheepWMP)
    COM_INTERFACE_ENTRY(IDispatch)
    COM_INTERFACE_ENTRY(IWMPEffects)
    COM_INTERFACE_ENTRY(IWMPEffects2)
END_COM_MAP()

public:

    // CComCoClass Overrides
    HRESULT FinalConstruct();
    void FinalRelease();

    // ISheepWMP
    STDMETHOD(get_foregroundColor)(/*[out, retval]*/ BSTR *pVal);
    STDMETHOD(put_foregroundColor)(/*[in]*/ BSTR newVal);

    // IWMPEffects
    STDMETHOD(Render)(TimedLevel *pLevels, HDC hdc, RECT *rc);
    STDMETHOD(MediaInfo)(LONG lChannelCount, LONG lSampleRate, BSTR bstrTitle);
    STDMETHOD(GetCapabilities)(DWORD * pdwCapabilities);
    STDMETHOD(GoFullscreen)(BOOL fFullScreen) { return E_NOTIMPL; };
    STDMETHOD(RenderFullScreen)(TimedLevel *pLevels) { return E_NOTIMPL; };
    STDMETHOD(DisplayPropertyPage)(HWND hwndOwner) { return E_NOTIMPL; };
    STDMETHOD(GetTitle)(BSTR *bstrTitle);
    STDMETHOD(GetPresetTitle)(LONG nPreset, BSTR *bstrPresetTitle);
    STDMETHOD(GetPresetCount)(LONG *pnPresetCount);
    STDMETHOD(SetCurrentPreset)(LONG nPreset);
    STDMETHOD(GetCurrentPreset)(LONG *pnPreset);

    // IWMPEffects2
    STDMETHOD(SetCore)(IWMPCore * pCore);
    STDMETHOD(Create)(HWND hwndParent);
    STDMETHOD(Destroy)();
    STDMETHOD(NotifyNewMedia)(IWMPMedia *pMedia);
    STDMETHOD(OnWindowMessage)(UINT msg, WPARAM WParam, LPARAM LParam, LRESULT *plResultParam );
    STDMETHOD(RenderWindowed)(TimedLevel *pLevels, BOOL fRequiredRender );

private:
    void         ReleaseCore();

	CAtlString   GetScrName ( CAtlString aScr ) ;
	LPCTSTR      ActiveScr () ;
	HWND		 FindScreenSaverWnd ( HWND aParent ) ;

    HWND                        m_hwndParent;
    CComPtr<IWMPCore>           m_spCore;
	std::vector<CAtlString>     m_Scrs ;
};

//------------------------------------------------------------------------------

#endif //__SHEEPWMP_H_

//------------------------------------------------------------------------------

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Justin Hallet
Web Developer
Australia Australia
Developing windows applications for over 15 years now starting on Win 3.1 with Object Oriented Pascal, progressed to C++ and OWL, in 1996 switch to MFC and never looked back, now focusing on .NET/Mono.

| Advertise | Privacy | Mobile
Web02 | 2.8.140814.1 | Last Updated 15 Jul 2011
Article Copyright 2006 by Justin Hallet
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid