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

📄 stfullscreen.cpp

📁 evc下全屏代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	CWnd objParentWindow;
	strParentClass = AfxRegisterWndClass(0);
	objParentWindow.CreateEx(0, strParentClass, ::AfxGetAppName(), WS_VISIBLE, -1, -1, 0, 0, 0, 0);

	// can be constructed with a resource template or InitModalIndirect
	ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
		m_lpDialogTemplate != NULL);

	// load resource as necessary
	LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
	HGLOBAL hDialogTemplate = m_hDialogTemplate;
	HINSTANCE hInst = AfxGetResourceHandle();
	if (m_lpszTemplateName != NULL)
	{
		hInst = AfxFindResourceHandle(m_lpszTemplateName, RT_DIALOG);
		HRSRC hResource = ::FindResource(hInst, m_lpszTemplateName, RT_DIALOG);
		hDialogTemplate = LoadResource(hInst, hResource);
	}
	if (hDialogTemplate != NULL)
		lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);

	// return -1 in case of failure to load the dialog template resource
	if (lpDialogTemplate == NULL)
		return -1;

	// disable parent (before creating dialog)
	HWND hWndParent = PreModal();

//	This line should not be commented but I cannot compile otherwise
//	AfxUnhookWindowCreate();
	BOOL bEnableParent = FALSE;
	if (hWndParent != NULL && ::IsWindowEnabled(hWndParent))
	{
		::EnableWindow(hWndParent, FALSE);
		bEnableParent = TRUE;
	}

	TRY
	{
		// create modeless dialog
//		This line should not be commented but I cannot compile otherwise
//		AfxHookWindowCreate(this);
		if (CreateDlgIndirect(lpDialogTemplate,
						&objParentWindow, hInst))
		{
			if (m_nFlags & WF_CONTINUEMODAL)
			{
				// enter modal loop
				DWORD dwFlags = MLF_SHOWONIDLE;
				if (GetStyle() & DS_NOIDLEMSG)
					dwFlags |= MLF_NOIDLEMSG;
				VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
			}

			// hide the window before enabling the parent, etc.
			if (m_hWnd != NULL)
				SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
					SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
		}
	}
	CATCH_ALL(e)
	{
//		This line should not be commented but I cannot compile otherwise
//		DELETE_EXCEPTION(e);
		m_nModalResult = -1;
	}
	END_CATCH_ALL

#if defined(_WIN32_WCE_PSPC) && (_WIN32_WCE >= 300)
	if(m_pWndEmptyCB != NULL)
	{
		m_pWndEmptyCB->DestroyWindow();
		delete m_pWndEmptyCB;
		m_pWndEmptyCB = NULL;
	}
#endif // _WIN32_WCE_PSPC
	if (bEnableParent)
		::EnableWindow(hWndParent, TRUE);
	if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
		::SetActiveWindow(hWndParent);

	// destroy modal window
	DestroyWindow();
	PostModal();

	// unlock/free resources as necessary
	if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
		UnlockResource(hDialogTemplate);
	if (m_lpszTemplateName != NULL)
		FreeResource(hDialogTemplate);

	return m_nModalResult;
}

//////////////////////////////////////////////////////////////////////
// CSTFullScreenViewLite
//////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNCREATE(CSTFullScreenViewLite, CView)

CSTFullScreenViewLite::CSTFullScreenViewLite()
	: m_dwFullScreenMode(FSF_FULLSCREEN),
	  m_bInFullSceenState(TRUE)
{
}

CSTFullScreenViewLite::~CSTFullScreenViewLite()
{
}

BEGIN_MESSAGE_MAP(CSTFullScreenViewLite, CView)
	//{{AFX_MSG_MAP(CSTFullScreenViewLite)
	ON_MESSAGE(WM_USER_REFRESH_FULLSCREEN, OnFullScreenRefresh)
	ON_COMMAND(ID_SWITCH_FULLSCREEN, OnFullScreenSwitch)
	ON_WM_CREATE()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CSTFullScreenViewLite::OnDraw(CDC* pDC)
{
}

BOOL CSTFullScreenViewLite::RefreshFullScreen()
{
	return CSTFullScreen::RefreshFullScreen(this, GetParentFrame()->m_hCommandBar, m_dwFullScreenMode, m_bInFullSceenState);
}

void CSTFullScreenViewLite::OnDestroy()
{
	m_bInFullSceenState = FALSE;
	RefreshFullScreen();
	CView::OnDestroy();
}


void CSTFullScreenViewLite::OnFullScreenSwitch() 
{
	SwitchFullScreenState();	
}

void CSTFullScreenViewLite::OnFullScreenRefresh(WPARAM wParam, LPARAM lParam)
{
	RefreshFullScreen();
}

void CSTFullScreenViewLite::SwitchFullScreenState()
{
	m_bInFullSceenState = !m_bInFullSceenState;
	RefreshFullScreen();
}

void CSTFullScreenViewLite::SetFullScreenState(BOOL bFullScreen)
{
	m_bInFullSceenState = bFullScreen;
}

BOOL CSTFullScreenViewLite::GetFullScreenState()
{
	return m_bInFullSceenState;
}

void CSTFullScreenViewLite::SetFullScreenMode(DWORD dwFullScreenMode)
{
	m_dwFullScreenMode = dwFullScreenMode;
}

DWORD CSTFullScreenViewLite::GetFullScreenMode()
{
	return m_dwFullScreenMode;
}

int CSTFullScreenViewLite::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;

	PostMessage(WM_USER_REFRESH_FULLSCREEN);		
	return 0;
}

void CSTFullScreenViewLite::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
{
	if (bActivate) {
		PostMessage(WM_USER_REFRESH_FULLSCREEN);	
	}
	CView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}


//////////////////////////////////////////////////////////////////////
// CSTFullScreenDialog
//////////////////////////////////////////////////////////////////////

CSTFullScreenDialog::CSTFullScreenDialog(UINT nIDTemplate, CWnd* pParentWnd /*= NULL*/)
	: CSTFullScreenDialogLite(nIDTemplate, pParentWnd),
	  m_nFullScreenIconPosition(FSI_BOTTOMLEFT),
	  m_bFullScreenIconVisible(TRUE)
{
}

BEGIN_MESSAGE_MAP(CSTFullScreenDialog, CSTFullScreenDialogLite)
	//{{AFX_MSG_MAP(CSTFullScreenDialog)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

BOOL CSTFullScreenDialog::RefreshFullScreen()
{
	BOOL bResult = CSTFullScreenDialogLite::RefreshFullScreen();

	m_FullScreenIcon.InsertIconInDialogToolbar((CCeCommandBar*)m_pWndEmptyCB);
	m_FullScreenIcon.SetIconPosition(m_nFullScreenIconPosition, m_dwFullScreenMode, m_bInFullSceenState);

	if (m_bInFullSceenState && (m_dwFullScreenMode & FSF_HIDECOMMANDBAR) && m_bFullScreenIconVisible) {
		m_FullScreenIcon.ShowWindow(SW_SHOW);
	} else {
		m_FullScreenIcon.ShowWindow(SW_HIDE);
	}

	return bResult;
}

BOOL CSTFullScreenDialog::OnInitDialog() 
{
	CSTFullScreenDialogLite::OnInitDialog();
	m_FullScreenIcon.SetIcon(GetIcon(FALSE));
	m_FullScreenIcon.Create(NULL, _T("FullScreenSwitchIcon"), WS_CHILD | WS_VISIBLE, FSI_BOTTOMLEFT, this, 45);	
	return TRUE;
}

CSTFullScreenIcon *CSTFullScreenDialog::GetFullScreenIcon()
{
	return &m_FullScreenIcon;
}

void CSTFullScreenDialog::SetFullScreenIcon(HICON hIcon)
{
	m_FullScreenIcon.SetIcon(hIcon);
}

void CSTFullScreenDialog::SetFullScreenIconPosition(UINT nFullScreenIconPosition)
{
	m_nFullScreenIconPosition = nFullScreenIconPosition;
	m_FullScreenIcon.SetIconPosition(nFullScreenIconPosition, m_dwFullScreenMode, m_bInFullSceenState);
}

void CSTFullScreenDialog::SetFullScreenIconVisible(BOOL bFullScreenIconVisible)
{
	m_bFullScreenIconVisible = bFullScreenIconVisible;

	if (m_bInFullSceenState && (m_dwFullScreenMode & FSF_HIDECOMMANDBAR) && m_bFullScreenIconVisible) {
		m_FullScreenIcon.ShowWindow(SW_SHOW);
	} else {
		m_FullScreenIcon.ShowWindow(SW_HIDE);
	}
}

BOOL CSTFullScreenDialog::GetFullScreenIconVisible()
{
	return m_bFullScreenIconVisible;
}


//////////////////////////////////////////////////////////////////////
// CSTFullScreenView
//////////////////////////////////////////////////////////////////////

IMPLEMENT_DYNCREATE(CSTFullScreenView, CSTFullScreenViewLite)

CSTFullScreenView::CSTFullScreenView()
	: m_nFullScreenIconPosition(FSI_BOTTOMLEFT)
{
}

CSTFullScreenView::~CSTFullScreenView()
{
}

BEGIN_MESSAGE_MAP(CSTFullScreenView, CSTFullScreenViewLite)
	//{{AFX_MSG_MAP(CSTFullScreenView)
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

void CSTFullScreenView::OnDraw(CDC* pDC)
{
}

BOOL CSTFullScreenView::RefreshFullScreen()
{
	BOOL bResult = CSTFullScreenViewLite::RefreshFullScreen();

	CCeCommandBar *pCb = (CCeCommandBar*)CCeCommandBar::FromHandle(GetParentFrame()->m_hCommandBar);
	m_FullScreenIcon.InsertIconInDialogToolbar(pCb);
	m_FullScreenIcon.SetIconPosition(m_nFullScreenIconPosition, m_dwFullScreenMode, m_bInFullSceenState);

	if (m_bInFullSceenState && (m_dwFullScreenMode & FSF_HIDECOMMANDBAR) && m_bFullScreenIconVisible) {
		m_FullScreenIcon.ShowWindow(SW_SHOW);
	} else {
		m_FullScreenIcon.ShowWindow(SW_HIDE);
	}

	return bResult;
}

int CSTFullScreenView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CSTFullScreenViewLite::OnCreate(lpCreateStruct) == -1)
		return -1;

	m_FullScreenIcon.SetIcon(GetIcon(FALSE));
	m_FullScreenIcon.Create(NULL, _T("FullScreenSwitchIcon"), WS_CHILD | WS_VISIBLE, FSI_BOTTOMLEFT, this, 45);	

	return 0;
}


CSTFullScreenIcon *CSTFullScreenView::GetFullScreenIcon()
{
	return &m_FullScreenIcon;
}

void CSTFullScreenView::SetFullScreenIcon(HICON hIcon)
{
	m_FullScreenIcon.SetIcon(hIcon);
}

void CSTFullScreenView::SetFullScreenIconPosition(UINT nFullScreenIconPosition)
{
	m_nFullScreenIconPosition = nFullScreenIconPosition;
	m_FullScreenIcon.SetIconPosition(nFullScreenIconPosition, m_dwFullScreenMode, m_bInFullSceenState);
}

void CSTFullScreenView::SetFullScreenIconVisible(BOOL bFullScreenIconVisible)
{
	m_bFullScreenIconVisible = bFullScreenIconVisible;

	if (m_bInFullSceenState && (m_dwFullScreenMode & FSF_HIDECOMMANDBAR) && m_bFullScreenIconVisible) {
		m_FullScreenIcon.ShowWindow(SW_SHOW);
	} else {
		m_FullScreenIcon.ShowWindow(SW_HIDE);
	}
}

BOOL CSTFullScreenView::GetFullScreenIconVisible()
{
	return m_bFullScreenIconVisible;
}

⌨️ 快捷键说明

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