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

📄 stfullscreen.h

📁 evc下全屏代码
💻 H
字号:
/////////////////////////////////////////////////////////////////////////////
// File name:      STFullScreen.h
// Author:         Vassili Philippov (vasja@spbteam.com)
// Created:        May 2001
// Last changed:   10 August 2001
// Version:        1.4
// Description:    Classes for organizing full screen applications

#if !defined(AFX_STFULLSCREEN_H__61332875_BE69_4783_AB30_CB75D099EB1C__INCLUDED_)
#define AFX_STFULLSCREEN_H__61332875_BE69_4783_AB30_CB75D099EB1C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


/////////////////////////////////////////////////////////////////////////////
// Commands that are handled by full screen view and dialog

// This command is sent to full screen dialog or view to switch full screen
// state (on/off)
#define ID_SWITCH_FULLSCREEN 24545


/////////////////////////////////////////////////////////////////////////////
// Full screen related messages

// This message is sent to full screen dialog or view to refresh full screen
// state and mode. It's necessary because this operation cannot be done during
// initialization and should be postponed.
#define WM_USER_REFRESH_FULLSCREEN (WM_USER+1)


/////////////////////////////////////////////////////////////////////////////
// Full screen mode flags

// All elements are shown. This mode corresponds to standard applications.
#define FSF_NORMAL 0x0000

// Command bar is hidden.
#define FSF_HIDECOMMANDBAR 0x0001

// Task bar is hidden.
#define FSF_HIDETASKBAR 0x0002

// SIP button is hidden.
#define FSF_HIDESIPBUTTON 0x0004

// Start icon is hidded.
#define FSF_HIDESTARTICON 0x0008

// All elements (command bar, task bar, SIP button and start icon) and hidden.
// This mode corresponds to full screen application.
#define FSF_FULLSCREEN 0x000F


/////////////////////////////////////////////////////////////////////////////
// Full screen icon positions

// Full screen icon in the top left corner.
#define FSI_TOPLEFT 1

// Full screen icon in the top right corner.
#define FSI_TOPRIGHT 2

// Full screen icon in the bottom left corner.
#define FSI_BOTTOMLEFT 3

// Full screen icon in the bottom right corner.
#define FSI_BOTTOMRIGHT 4


/////////////////////////////////////////////////////////////////////////////
// CSTFullScreen class that provides basic functionality for organizing 
// full screen behaviour. This class provides static functions and should
// not be instantiated.

class CSTFullScreen  
{
public:
	// Returns size of the device screen. For Pocket PC this size should
	// be 240x320;
	static CSize GetScreenSize();

	// Returns bounds rectangle of the window by full screen mode and 
	// state. If state is "full screen" (TRUE) and mode is FSF_FULLSCREEN 
	// then window size is equal to screen size. If some additional elements
	// should be shown (for example if mode hides only task bar but 
	// doesn't hide command bar) then window size is less then screen size
	// for the height of these elements.
	static CRect GetFullScreenWindowRect(DWORD dwFullScreenMode, BOOL bInFullSceenState);

	// Refreshes window "fullscreennees" depending on full screen mode 
	// and state.
	static BOOL RefreshFullScreen(CWnd *pWnd, HWND hCommandBar, DWORD dwFullScreenMode, BOOL bInFullSceenState);
};


/////////////////////////////////////////////////////////////////////////////
// CSTFullScreenIcon window that is a convinient button to switch full screen
// mode on/off.

class CSTFullScreenIcon : public CWnd
{
public:
	CSTFullScreenIcon();

public:
	virtual ~CSTFullScreenIcon();
	virtual BOOL Create (LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, UINT nPosition, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); 

	// Inserts the icon into the given command bar. If the icon is already inserted
	// it will not be inserted again
	virtual void InsertIconInDialogToolbar(CCeCommandBar *pCb);

	// Sets icon position index. nIconPosition parameter should be on of
	// FSI_TOPLEFT, FSI_TOPRIGHT, FSI_BOTTOMLEFT or FSI_BOTTOMRIGHT.
	// Icon position depends on full screen mode and state of the parent
	// window.
	void SetIconPosition(UINT nIconPosition, DWORD dwFullScreenMode, BOOL bInFullSceenState);

	// Sets icon that will be shown in the full screen mode and will be inserted
	// into the parent command bar.
	void SetIcon(HICON hIcon);

protected:
	// Calculates bounding rectangle of the icon depending on m_nIconPosition
	virtual CRect GetIconRectangle(DWORD dwFullScreenMode, BOOL bInFullSceenState);

	//Index of icon position on the screen. Could be FSI_TOPLEFT, FSI_TOPRIGHT, FSI_BOTTOMLEFT or FSI_BOTTOMRIGHT 
	UINT m_nIconPosition;

	// Flag that shows whether the icon is added into the parent's toolbar or not
	BOOL m_bIsToolbarIconSet;

	// Icon that will be shown in the full screen mode and will be inserted
	// into the parent command bar
	HICON m_hIcon;

	// Image list of the command bar. Is used to change the icon if the icon changed.
	CCeCommandBar *m_pCommandBar;

	//{{AFX_MSG(CSTFullScreenIcon)
	afx_msg void OnPaint();
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
// CSTFullScreenDialogLite dialog is a base class for full screen dialogs that
// provides basic functionality to organize full screen dialog.

class CSTFullScreenDialogLite : public CDialog
{
// Construction
public:
	CSTFullScreenDialogLite(UINT nIDTemplate, CWnd* pParentWnd = NULL);

//Full screen related methods
public:
	// Switches full screen state. If the dialog was in full screen
	// state it changes to normal state and back. 
	// In normal state all additional elements are shown. In full screen 
	// state additional elements depends on full screen mode property.
	void SwitchFullScreenState();

	// Sets full screen state property. If bFullScreen is TRUE then
	// the dialog will be in full screen state. If FALSE in normal state.
	// In normal state all additional elements are shown. In full screen 
	// state additional elements depends on full screen mode property.
	// Call RefreshFullScreen to apply changes in the state. 
	void SetFullScreenState(BOOL bFullScreen);

	// Returns TRUE if the dialog is in the full screen state. Returns
	// FALSE if the dialog is in the normal state.
	BOOL GetFullScreenState();

	// Sets full screen mode. This property affects dialog appearance 
	// only in the full screen state. Full screen mode could be a
	// combination of FSF_NORMAL, FSF_HIDECOMMANDBAR, FSF_HIDETASKBAR, 
	// FSF_HIDESIPBUTTON and FSF_HIDESTARTICON constants.
	// Call RefreshFullScreen to apply changes in the mode. 
	void SetFullScreenMode(DWORD dwFullScreenMode);

	// Returns full screen mode.
	DWORD GetFullScreenMode();

	// This function is rewritten to fix "Today" bug. 
	// "Today" bugs: dialog based application is shown when you try to
	// call standard Today program.
	virtual int DoModal();

// Implementation
protected:
	virtual BOOL RefreshFullScreen();

	DWORD m_dwFullScreenMode;
	BOOL m_bInFullSceenState;

	// Generated message map functions
	//{{AFX_MSG(CSTFullScreenDialogLite)
	virtual BOOL OnInitDialog();
	afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
	afx_msg void OnFullScreenRefresh(WPARAM wParam, LPARAM lParam);
	afx_msg void OnFullScreenSwitch();
	afx_msg void OnDestroy();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
// CSTFullScreenViewLite window is a base class for full screen views that
// provides basic functionality to organize full screen dialog.

class CSTFullScreenViewLite : public CView
{
protected:
	CSTFullScreenViewLite();
	DECLARE_DYNCREATE(CSTFullScreenViewLite)

//Full screen related methods
public:
	// Switches full screen state. If the view was in full screen
	// state it changes to normal state and back. 
	// In normal state all additional elements are shown. In full screen 
	// state additional elements depends on full screen mode property.
	void SwitchFullScreenState();

	// Sets full screen state property. If bFullScreen is TRUE then
	// the view will be in full screen state. If FALSE in normal state.
	// In normal state all additional elements are shown. In full screen 
	// state additional elements depends on full screen mode property.
	// Call RefreshFullScreen to apply changes in the state 
	void SetFullScreenState(BOOL bFullScreen);

	// Returns TRUE if the view is in the full screen state. Returns
	// FALSE if the view is in the normal state.
	BOOL GetFullScreenState();

	// Sets full screen mode. This property affects view appearance 
	// only in the full screen state. Full screen mode could be a
	// combination of FSF_NORMAL, FSF_HIDECOMMANDBAR, FSF_HIDETASKBAR, 
	// FSF_HIDESIPBUTTON and FSF_HIDESTARTICON constants.
	// Call RefreshFullScreen to apply changes in the mode. 
	void SetFullScreenMode(DWORD dwFullScreenMode);

	// Returns full screen mode.
	DWORD GetFullScreenMode();

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CSTFullScreenViewLite)
	protected:
	virtual void OnDraw(CDC* pDC);
	virtual void OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView);
	//}}AFX_VIRTUAL

protected:
	virtual ~CSTFullScreenViewLite();
	virtual BOOL RefreshFullScreen();

	DWORD m_dwFullScreenMode;
	BOOL m_bInFullSceenState;

	//{{AFX_MSG(CSTFullScreenViewLite)
	afx_msg void OnFullScreenRefresh(WPARAM wParam, LPARAM lParam);
	afx_msg void OnFullScreenSwitch();
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnDestroy();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
// CSTFullScreenDialog dialog is a good base class to organize full function
// full screen dialog with full screen mode switch on/off icon.

class CSTFullScreenDialog : public CSTFullScreenDialogLite
{
public:
	CSTFullScreenDialog(UINT nIDTemplate, CWnd* pParentWnd = NULL);   // standard constructor

//Full screen related methods
public:
	// Sets icon image that will be shown on the full scren icon control
	void SetFullScreenIcon(HICON hIcon);

	// Sets position where full screen icon will be shown. Could be one of
	// FSI_TOPLEFT, FSI_TOPRIGHT, FSI_BOTTOMLEFT and FSI_BOTTOMRIGHT.
	void SetFullScreenIconPosition(UINT nFullScreenIconPosition);

	// Returns full screen icon control.
	CSTFullScreenIcon *GetFullScreenIcon();

	// Shows or hides the full screen icon in the full screen mode.
	void SetFullScreenIconVisible(BOOL bFullScreenIconVisible);

	// Returns TRUE if the full screen icon is visible in the full screen mode.
	// Returns FALSE if the full screen icon is hidden even in the full screen mode.
	BOOL GetFullScreenIconVisible();

// Implementation
protected:
	virtual BOOL RefreshFullScreen();
	CSTFullScreenIcon m_FullScreenIcon;
	UINT m_nFullScreenIconPosition;
	BOOL m_bFullScreenIconVisible;

	// Generated message map functions
	//{{AFX_MSG(CSTFullScreenDialog)
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
// CSTFullScreenview window is a good base class to organize full function
// full screen view with full screen mode switch on/off icon.

class CSTFullScreenView : public CSTFullScreenViewLite
{
protected:
	CSTFullScreenView();
	DECLARE_DYNCREATE(CSTFullScreenView)

// Operations
public:
	// Sets icon image that will be shown on the full scren icon control
	void SetFullScreenIcon(HICON hIcon);

	// Sets position where full screen icon will be shown. Could be one of
	// FSI_TOPLEFT, FSI_TOPRIGHT, FSI_BOTTOMLEFT and FSI_BOTTOMRIGHT.
	void SetFullScreenIconPosition(UINT nFullScreenIconPosition);

	// Returns full screen icon control.
	CSTFullScreenIcon *GetFullScreenIcon();

	// Shows or hides the full screen icon in the full screen mode.
	void SetFullScreenIconVisible(BOOL bFullScreenIconVisible);

	// Returns TRUE if the full screen icon is visible in the full screen mode.
	// Returns FALSE if the full screen icon is hidden even in the full screen mode.
	BOOL GetFullScreenIconVisible();

	//{{AFX_VIRTUAL(CSTFullScreenView)
	protected:
	virtual void OnDraw(CDC* pDC);
	//}}AFX_VIRTUAL

protected:
	virtual ~CSTFullScreenView();
	virtual BOOL RefreshFullScreen();
	CSTFullScreenIcon m_FullScreenIcon;
	UINT m_nFullScreenIconPosition;
	BOOL m_bFullScreenIconVisible;

	//{{AFX_MSG(CSTFullScreenView)
	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};


//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STFULLSCREEN_H__61332875_BE69_4783_AB30_CB75D099EB1C__INCLUDED_)

⌨️ 快捷键说明

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