Duilib学习笔记
+ -

Duilib模式对话框DoModal实现

2023-05-22 8 0

其原理就是通过禁用该窗口的拥有者,便能该窗口。
执行完成后,在该DoModal函数中建立消息循环(因为主消息循环已经卡死)。

UINT CWindowWnd::ShowModal()
{
    ASSERT(::IsWindow(m_hWnd));
    UINT nRet = 0;
    HWND hWndParent = GetWindowOwner(m_hWnd);
    ::ShowWindow(m_hWnd, SW_SHOWNORMAL);
    ::EnableWindow(hWndParent, FALSE);
    MSG msg = { 0 };
    while( ::IsWindow(m_hWnd) && ::GetMessage(&msg, NULL, 0, 0) ) {
        if( msg.message == WM_CLOSE && msg.hwnd == m_hWnd ) {
            nRet = msg.wParam;
            ::EnableWindow(hWndParent, TRUE);
            ::SetFocus(hWndParent);
        }
        if( !CPaintManagerUI::TranslateMessage(&msg) ) {
            ::TranslateMessage(&msg);
            ::DispatchMessage(&msg);
        }
        if( msg.message == WM_QUIT ) break;
    }
    ::EnableWindow(hWndParent, TRUE);
    ::SetFocus(hWndParent);
    if( msg.message == WM_QUIT ) ::PostQuitMessage(msg.wParam);
    return nRet;
}

0 篇笔记 写笔记

Duilib模式对话框DoModal实现
其原理就是通过禁用该窗口的拥有者,便能该窗口。执行完成后,在该DoModal函数中建立消息循环(因为主消息循环已经卡死)。UINT CWindowWnd::ShowModal(){ ASSERT(::IsWindow(m_hWnd)); UINT nRet = 0; HW......
作者信息
我爱内核
Windows驱动开发,网站开发
好好学习,天天向上。
取消
感谢您的支持,我会继续努力的!
扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

您的支持,是我们前进的动力!