📄 cmediabookmarker.h
字号:
// CMediaBookmarker.h : Declaration of the CMediaBookmarker class
//
// Copyright (c) Microsoft Corporation. All rights reserved. THIS CODE IS MADE AVAILABLE AS
// IS, WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK OF THE USE OR THE RESULTS FROM THE USE
// OF THIS CODE REMAINS WITH THE USER. USE AND REDISTRIBUTION OF THIS CODE, WITH OUR
// WITHOUT MODICATION, IS HEREBY PERMITTED.
//
#include "resource.h"
#include <commdlg.h>
#include "PlayerOCX.h"
#include "events_dispid.h"
#define IDC_PLAYER 1000
#define IDB_PLAY 1001
#define IDB_PAUSE 1002
#define IDB_STOP 1003
#define IDB_FASTREVERSE 1004
#define IDB_FASTFORWARD 1005
#define IDB_MARK 1006
#define IDB_CLEARMARKS 1007
#define IDB_PLAYMARK 1008
#define IDL_BOOKMARKS 1009
#define MAX_MARKLENGTH 256
#define MAX_BOOKMARKS 100
#define MAX_PLAYER_HEIGHT 198
#define STATUS_BAR_HEIGHT 14
/////////////////////////////////////////////////////////////////////////////
// CMediaBookmarker
class CMediaBookmarker :
public CWindowImpl<CMediaBookmarker, CWindow, CWinTraits<WS_VISIBLE, NULL> >,
public CComObjectRootEx<CComSingleThreadModel>,
public _IWMPEvents
{
CAxWindow m_wndView; // The window that hosts the Windows Media Player control
CComPtr<IWMP> m_spWMPPlayer; // A pointer to the Windows Media Player control interface
CComPtr<IConnectionPoint> m_spConnectionPoint; // The connection point through which events are handled
DWORD m_dwAdviseCookie; // A cookie used by the connection point to cease event notifications
DWORD m_nFilterIndex; // An index to the current file name filter
int m_cMarkCount; // The bookmark count
TCHAR* m_szCurrentFile; // The name of the current file (without path information)
BSTR m_bstrFileName[MAX_BOOKMARKS]; // An array that stores bookmarked file names
double m_dMarkPosition[MAX_BOOKMARKS]; // An array that stores bookmarked file positions
public:
BEGIN_COM_MAP(CMediaBookmarker)
COM_INTERFACE_ENTRY_IID(__uuidof(_IWMPEvents), _IWMPEvents)
COM_INTERFACE_ENTRY(IDispatch)
END_COM_MAP()
DECLARE_WND_CLASS(NULL)
BEGIN_MSG_MAP(CMediaBookmarker)
MESSAGE_HANDLER( WM_CREATE, OnCreate)
MESSAGE_HANDLER( WM_DESTROY, OnDestroy)
COMMAND_ID_HANDLER( IDOK, OnOK)
COMMAND_ID_HANDLER( ID_FILE_OPEN, OnFileOpen)
COMMAND_ID_HANDLER( ID_FILE_EXIT, OnFileExit)
COMMAND_ID_HANDLER( IDB_MARK, OnMark)
COMMAND_ID_HANDLER( IDB_CLEARMARKS, OnClearMarks)
COMMAND_ID_HANDLER( IDB_PLAYMARK, OnPlayMark)
COMMAND_ID_HANDLER( IDB_PLAY, OnPlay)
COMMAND_ID_HANDLER( IDB_PAUSE, OnPause)
COMMAND_ID_HANDLER( IDB_STOP, OnStop)
COMMAND_ID_HANDLER( IDB_FASTFORWARD, OnFastForward)
COMMAND_ID_HANDLER( IDB_FASTREVERSE, OnFastReverse)
END_MSG_MAP()
// CMediaBookmarker methods:
CMediaBookmarker();
~CMediaBookmarker();
BOOL Bookmark(TCHAR *szBookmarkText);
BOOL PlayMedia(TCHAR *szFile, double dPosition);
// Window methods:
LRESULT OnCreate( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
LRESULT OnDestroy( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
// User-interface methods:
LRESULT OnOK( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnFileOpen( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnFileExit( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnMark( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnClearMarks( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnPlayMark( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnPlay( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnPause( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnStop( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnFastForward( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
LRESULT OnFastReverse( WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled);
// IDispatch methods:
STDMETHOD(GetIDsOfNames)( REFIID riid,
OLECHAR FAR *FAR *rgszNames,
unsigned int cNames,
LCID lcid,
DISPID FAR *rgDispId )
{ return( E_NOTIMPL ); };
STDMETHOD(GetTypeInfo)( unsigned int iTInfo,
LCID lcid,
ITypeInfo FAR *FAR *ppTInfo )
{ return( E_NOTIMPL ); };
STDMETHOD(GetTypeInfoCount)(unsigned int FAR *pctinfo )
{ return( E_NOTIMPL ); };
STDMETHOD(Invoke)( DISPID dispIdMember,
REFIID riid,
LCID lcid,
WORD wFlags,
DISPPARAMS FAR *pDispParams,
VARIANT FAR *pVarResult,
EXCEPINFO FAR *pExcepInfo,
unsigned int FAR *puArgErr );
// Windows Media Player Control event methods:
void OnPlayStateChange(long NewState);
};
typedef CComObject<CMediaBookmarker> CComMediaBookmarker;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -