一、duilib 窗口关闭
1、窗口关闭代码
void Window::Close(UINT nRet)
{
if (m_bFakeModal)
{
auto parent_hwnd = GetWindowOwner(m_hWnd);
ASSERT(::IsWindow(parent_hwnd));
::EnableWindow(parent_hwnd, TRUE);
::SetFocus(parent_hwnd);
m_bFakeModal = false;
}
ASSERT(::IsWindow(m_hWnd));
if (!::IsWindow(m_hWnd)) return;
if (m_pRoot && IsWindowsVistaOrGreater()) {
m_pRoot->SetVisible(false);
auto closeCallback = [this, nRet]() {
this->PostMessage(WM_CLOSE, (WPARAM)nRet, 0L);
};
TimerManager::GetInstance()->AddCancelableTimer(m_closeFlag.GetWeakFlag(), closeCallback, 300, 1);
}
else {
PostMessage(WM_CLOSE, (WPARAM)nRet, 0L);
}
}
2、延时关闭
这里重要是这一段
m_pRoot->SetVisible(false);
auto closeCallback = [this, nRet]() {
this->PostMessage(WM_CLOSE, (WPARAM)nRet, 0L);
};
TimerManager::GetInstance()->AddCancelableTimer
|