void nt_wrapper_render_wnd::FullScreenSwitch()
{
if ( !::IsWindow(m_hWnd) )
return;
if (player_handle_ != nullptr)
{
player_api_.SetRenderARGBLogo(player_handle_, nullptr, 0, 0, 0, 0, 0, 0, 0);
}
if ( !IsFullScreen() )
{
if ( !IsCanFullScreen() )
return;
auto old_wnd = GetParent();
if ( old_wnd == NULL )
return;
old_parent_wnd_ = old_wnd->m_hWnd;
ASSERT(::IsWindow(old_parent_wnd_));
GetWindowRect(&old_rect_);
old_wnd->ScreenToClient(old_rect_);
HMONITOR hMonitor = ::MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
if (hMonitor == NULL)
return;
MONITORINFOEX mi;
mi.cbSize = sizeof(mi);
if ( !GetMonitorInfo(hMonitor, &mi) )
return;
::SetParent(m_hWnd, NULL);
auto wnd_styles = GetWindowLongPtr(m_hWnd, GWL_STYLE);
wnd_styles = wnd_styles & (~WS_CHILD);
wnd_styles |= WS_POPUP;
::SetWindowLongPtr(m_hWnd, GWL_STYLE, wnd_styles);
// 隐藏老窗口
::ShowWindow(old_parent_wnd_, SW_HIDE);
is_full_screen_ = true;
::SetWindowPos(m_hWnd, HWND_TOP, mi.rcMonitor.left,
mi.rcMonitor.top,
mi.rcMonitor.right - mi.rcMonitor.left,
mi.rcMonitor.bottom - mi.rcMonitor.top,
SWP_FRAMECHANGED);
::SetForegroundWindow(m_hWnd);
::RedrawWindow(m_hWnd, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW
| RDW_ERASE);
::RedrawWindow(NULL, NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW
| RDW_ERASE);
}
else
{
::ShowWindow(old_parent_wnd_, SW_SHOW);
auto wnd_styles = GetWindowLongPtr(m_hWnd, GWL_STYLE);
wnd_styles = wnd_styles & (~WS_POPUP);
wnd_styles |= WS_CHILD;
auto ret = SetWindowLongPtr(m_hWnd, GWL_STYLE, wnd_styles);
::SetParent(m_hWnd, old_parent_wnd_);
is_full_screen_ = false;
MoveWindow(old_rect_, TRUE);
}
}