Click here to Skip to main content
15,884,628 members
Articles / Desktop Programming / WTL

Windows Media Player Standby Plug-in

Rate me:
Please Sign up or sign in to vote.
4.47/5 (13 votes)
27 May 2005CPOL4 min read 208.9K   7.9K   32  
Media Player plug-in turning computer off when media ends
In this article, you will see my implementation which is similar to the TV's Sleep timer function. You will also see my Media Player plug-in which instead of turning Media Player off after the specified interval of time turns the PC off when the media ends.
/////////////////////////////////////////////////////////////////////////////
// #ifndef __ARMEN_H__
// #define __ARMEN_H__//     
//	   Armen Hakobyan, 2005.
//	   http://www.codeproject.com/script/articles/list_articles.asp?userid=25653
// #endif // __ARMEN_H__
/////////////////////////////////////////////////////////////////////////////

#ifndef __MPST_DIALOGS_H__
#define __MPST_DIALOGS_H__

#if _MSC_VER > 1000
	#pragma once
#endif

/////////////////////////////////////////////////////////////////////////////

#include "atlwin.h"
#include "plugins.h"
#include "controls.h"

/////////////////////////////////////////////////////////////////////////////

class CUIForm : public CDialogImpl< CUIForm >
{
public:
	enum DLGID { IDD = IDD_FORMVIEW };

private:
	CUiPlugin*	m_pUiPlugin;

	HWND		m_hwndLed;
	HBRUSH		m_hbrBack;	
	HFONT		m_hfntLnk;	
	HFONT		m_hfntArr;	

	CWmpHyperLink	m_lnkStartStop;	
	CWmpHyperLink	m_lnkType;
	CWmpHyperLink	m_lnkVolume;
	CWmpHyperLink	m_lnkAbout;	
	
public:
	static LPCTSTR s_smStrings[];

public:
	CUIForm( VOID );

public:
	BEGIN_MSG_MAP( CUIForm )		
		MESSAGE_HANDLER( WM_INITDIALOG,			OnInitDialog	)
		MESSAGE_HANDLER( WM_DESTROY,			OnDestroy		)
		MESSAGE_HANDLER( WM_CTLCOLORDLG,		OnCtlColor		)
		MESSAGE_HANDLER( WM_CTLCOLOREDIT,		OnCtlColor		)
		MESSAGE_HANDLER( WM_CTLCOLORSTATIC,		OnCtlColor		)		
		MESSAGE_HANDLER( WM_TIMER,				OnTimer			)		
		COMMAND_HANDLER( IDC_STARTSTOP, BN_CLICKED, OnCmdStartStop	)		
		COMMAND_HANDLER( IDC_TYPE,		BN_CLICKED, OnCmdType		)
		COMMAND_HANDLER( IDC_VOLUME,	BN_CLICKED, OnCmdVolume		)
		COMMAND_HANDLER( IDC_ABOUT,		BN_CLICKED, OnCmdAbout		)		
	END_MSG_MAP()

public:
	LRESULT OnInitDialog( IN UINT /*uMsg*/, IN WPARAM /*wParam*/, IN LPARAM /*lParam*/, IN OUT BOOL& /*bHandled*/ );
	LRESULT OnDestroy	( IN UINT /*uMsg*/, IN WPARAM /*wParam*/, IN LPARAM /*lParam*/, IN OUT BOOL& /*bHandled*/ );	
	LRESULT OnCtlColor	( IN UINT /*uMsg*/, IN WPARAM /*wParam*/, IN LPARAM /*lParam*/, IN OUT BOOL& /*bHandled*/ );	
	LRESULT OnTimer		( IN UINT /*uMsg*/, IN WPARAM /*wParam*/, IN LPARAM /*lParam*/, IN OUT BOOL& /*bHandled*/ );

	LRESULT OnCmdStartStop	( IN WORD /*wNotifyCode*/, IN WORD /*wID*/, IN HWND /*hWndCtl*/, IN OUT BOOL& /*bHandled*/ );	
	LRESULT OnCmdType		( IN WORD /*wNotifyCode*/, IN WORD /*wID*/, IN HWND /*hWndCtl*/, IN OUT BOOL& /*bHandled*/ );
	LRESULT OnCmdVolume		( IN WORD /*wNotifyCode*/, IN WORD /*wID*/, IN HWND /*hWndCtl*/, IN OUT BOOL& /*bHandled*/ );
	LRESULT OnCmdAbout		( IN WORD /*wNotifyCode*/, IN WORD /*wID*/, IN HWND /*hWndCtl*/, IN OUT BOOL& /*bHandled*/ );

public:

	VOID	CreateAndSetLinksFont ( VOID );
	VOID	CreateAndSetArrowsFont( VOID );
	VOID	SetStaticsFonts( IN LPUINT aIDs, IN HFONT hFont );
	VOID	StartTimer( VOID );
	VOID	StopTimer( VOID );
	VOID	SetTimerLed( VOID );
};

/////////////////////////////////////////////////////////////////////////////
#endif // __MPST_DIALOGS_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)


Written By
Software Developer (Senior) SafeNet Inc
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions