⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 osdwin.h

📁 Windows CE 下的机顶盒应用实例
💻 H
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//

#ifndef _osdwin_h_
#define _osdwin_h_

//commands CWinOSD will provide feedback for
enum CPlayerCommand
{
	NoCmd,
	Stop,
	Play,
	NextTrack,
	PrevTrack,
	FF,
	FREV,
	Pause,
	Menu,
	Resume,
	RewindTrack,
	Loading,
	NoDisk,
	SlowRev,
	SlowFwd,
	Step,
	End
};

//forward declaration
class CPaintCtxtOSD;

//
//	class CWinOSD implements "pink window subclassing"
//	ir REPLACES WM_PAINT procedure and assimes that color key is painted 
//  as a background.
//
//
class CWinOSD
{
	static LONG m_pOldWinProc;
	HWND m_hWnd;
	HINSTANCE m_hInst;
	CPlayerCommand m_activeCmd;
	CPaintCtxtOSD *m_pActivePaintCtxt;
	UINT m_activeTimer;

	static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

public:
	CWinOSD() : m_activeCmd(NoCmd), m_pActivePaintCtxt(0), m_activeTimer(0)
	{}

	HRESULT SetWindow(HWND hWin, HINSTANCE hInst);
	void ProvideFeedback(CPlayerCommand cmd, HRESULT cmdResult = S_OK);

protected:
	void Timer(WPARAM id);
	void Paint(HWND hwin, HDC hdc, PAINTSTRUCT *pps);
	void AdvancePaintCtxt();
	void InitInstance();
	void InitializePaintContext(CPlayerCommand cmd, HRESULT cmdResult);
};

///////////////////////////////////////////////////////////////////////
//
//	class CPaintCtxtOSD - any paintable item that can be timer driven
//
///////////////////////////////////////////////////////////////////////
class CPaintCtxtOSD
{
protected:
	UINT m_timeout;
public:
	virtual UINT SetNextPaintTimer(HWND hWnd);
	virtual CPaintCtxtOSD * Advance(HWND hwin);
	virtual void Reset(HWND hwin);
	virtual void Paint(HWND hwin, HDC hdc, PAINTSTRUCT *pps) {}

	CPaintCtxtOSD(UINT tmo) : m_timeout(tmo)
	{}
	virtual ~CPaintCtxtOSD(){}
};



///////////////////////////////////////////////////////////////////////
//
//	class CPaintStringOSD - places string
//	into the top right corner of tv screen and removes it after timer expiration
//
///////////////////////////////////////////////////////////////////////
class CPaintStringOSD : public CPaintCtxtOSD
{
protected:
	LPCTSTR m_string;

public:
	CPaintStringOSD(LPCTSTR string, UINT timeout = 1000) : CPaintCtxtOSD(timeout),
		m_string(string)
	{}

	virtual void Paint(HWND hwin, HDC hdc, PAINTSTRUCT *pps);
};





///////////////////////////////////////////////////////////////////////
//
//	class CPaintBitmapOSD - places scaled bitmap (transparency based on pixel(0,0))
//	into the top right corner of tv screen and removes it after timer expiration
//
///////////////////////////////////////////////////////////////////////
class CPaintBitmapOSD : public CPaintCtxtOSD
{
protected:
	HBITMAP m_hBmp;

public:
	CPaintBitmapOSD(HINSTANCE hInst, UINT bmpId, UINT timeout = 1000) : CPaintCtxtOSD(timeout)
	{
		m_hBmp = LoadBitmap(hInst, MAKEINTRESOURCE(bmpId));
	}

	~CPaintBitmapOSD()
	{
		if (m_hBmp != NULL)
			DeleteObject((HGDIOBJ)m_hBmp);
	}
	virtual void Paint(HWND hwin, HDC hdc, PAINTSTRUCT *pps);
};




///////////////////////////////////////////////////////////////////////
//
//	class CBlinkerOSD - blinker based on "on" and "off" PaintContexts
//
///////////////////////////////////////////////////////////////////////
class CBlinkerOSD : public CPaintCtxtOSD
{
protected:
	CPaintCtxtOSD *m_pBlinkingCtxtOn, *m_pBlinkingCtxtOff;
	UINT m_timeOn, m_timeOff;
	int m_blinkLimit, m_blinkCounter;

public:
	CBlinkerOSD(CPaintCtxtOSD *pBlinkingCtxtOn, int iLimit = -1, UINT tmOn = 500, UINT tmOff = 500,
		CPaintCtxtOSD *pBlinkingCtxtOff = 0) : CPaintCtxtOSD(tmOn),
		m_pBlinkingCtxtOn(pBlinkingCtxtOn), m_timeOn(tmOn), m_timeOff(tmOff), m_blinkLimit(iLimit), m_blinkCounter(0),
		m_pBlinkingCtxtOff(pBlinkingCtxtOff)
	{}

	void Paint(HWND hwin, HDC hdc, PAINTSTRUCT *pps);
	CPaintCtxtOSD *Advance(HWND hwin);
	UINT SetNextPaintTimer(HWND hWnd);
	void Reset(HWND hwin);
};


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -