if (m_bFullScreen)
{
LockWindowUpdate(TRUE);
::SetParent(m_hWnd, m_OldWndParent);
SetWindowPlacement(&m_OldWndPlacement);
::SetForegroundWindow(m_OldWndParent);
::SetFocus(m_OldWndParent);
::SetFocus(m_hWnd);
LockWindowUpdate(FALSE);
}
else
{
GetWindowPlacement(&m_OldWndPlacement);
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
m_OldWndParent = ::GetParent(m_hWnd);
::SetParent(m_hWnd, GetDesktopWindow());
WINDOWPLACEMENT wp1;
ZeroMemory(&wp1, sizeof(WINDOWPLACEMENT));
wp1.length = sizeof(WINDOWPLACEMENT);
wp1.showCmd = SW_SHOWNORMAL;
wp1.rcNormalPosition.left = 0;
wp1.rcNormalPosition.top = 0;
wp1.rcNormalPosition.right = nScreenWidth;
wp1.rcNormalPosition.bottom = nScreenHeight;
SetWindowPlacement(&wp1);
::SetForegroundWindow(GetDesktopWindow());
::SetForegroundWindow(m_hWnd);
}
m_bFullScreen = !m_bFullScreen;
{
LockWindowUpdate(TRUE);
::SetParent(m_hWnd, m_OldWndParent);
SetWindowPlacement(&m_OldWndPlacement);
::SetForegroundWindow(m_OldWndParent);
::SetFocus(m_OldWndParent);
::SetFocus(m_hWnd);
LockWindowUpdate(FALSE);
}
else
{
GetWindowPlacement(&m_OldWndPlacement);
int nScreenWidth = GetSystemMetrics(SM_CXSCREEN);
int nScreenHeight = GetSystemMetrics(SM_CYSCREEN);
m_OldWndParent = ::GetParent(m_hWnd);
::SetParent(m_hWnd, GetDesktopWindow());
WINDOWPLACEMENT wp1;
ZeroMemory(&wp1, sizeof(WINDOWPLACEMENT));
wp1.length = sizeof(WINDOWPLACEMENT);
wp1.showCmd = SW_SHOWNORMAL;
wp1.rcNormalPosition.left = 0;
wp1.rcNormalPosition.top = 0;
wp1.rcNormalPosition.right = nScreenWidth;
wp1.rcNormalPosition.bottom = nScreenHeight;
SetWindowPlacement(&wp1);
::SetForegroundWindow(GetDesktopWindow());
::SetForegroundWindow(m_hWnd);
}
m_bFullScreen = !m_bFullScreen;
上面代码纠正了网上能找到的代码中一个比较明显的焦点切换的问题,纯粹是我多次实验的结果,不要问我为什么这么写。
当然,这段代码也是有问题的,而且相当奇怪,在"ActiveX Control Test Container"中运行一切正常,但是一旦把这个控件嵌入的网页后,全屏,切回,改变IE窗口大小,再试图全屏就不会成功了,而是只有左上角有显示,结果比较诡异:
没有什么头绪,如果有人知道的话,赐教^_^