如何在加载页面之前隐藏CDHTMLDialog?

时间:2010-12-23 08:37:59

标签: mfc visual-c++

调用DoModal方法后,将立即显示该对话框。但我需要在页面加载之前使其不可见。那可能吗?

感谢 XX

3 个答案:

答案 0 :(得分:0)

您好,您可以在

开头隐藏它
OnInitDialog()
   DWORD dwStyle = GetWindowLong(GetSafeHwnd(), GWL_STYLE);
   dwStyle -= WS_VISIBLE;
   SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle);

然后在OnNavigateComplete中让它可见。 但是,如果您的页面加载速度很慢,那么您的应用程序就会挂起

答案 1 :(得分:0)

//CYourDialog.cpp

void CYourDialog::OnWindowPosChanging(WINDOWPOS* lpwndpos)
{
     //allow to hide dialog at the startup of dialog,
     //delay the show of dialog until m_bVisible is set
     if(!m_bVisible)
     {
         lpwndpos->flags &= ~SWP_SHOWWINDOW;
     }

     CDialog::OnWindowPosChanging(lpwndpos);
}

//CYourHtmlView.cpp

void CYourHtmlView::OnDocumentComplete()
{
    m_pYourDlg->m_bVisible=TRUE;
    m_pYourDlg->ShowWindow(SW_SHOW);
}

答案 2 :(得分:0)

BOOL CYourDialog::OnInitDialog()
{
    DWORD dwStyle = GetWindowLong(GetSafeHwnd(), GWL_STYLE);
    dwStyle -= WS_VISIBLE;
    SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle);
    Invalidate();
    CDHtmlDialog::OnInitDialog();
...
    Navigate(_T("www.google.com"));
    return TRUE;  // return TRUE  unless you set the focus to a control
}

void CYourDialog::OnNavigateComplete(LPDISPATCH pDisp, LPCTSTR szUrl)
{   
    DWORD dwStyle = GetWindowLong(GetSafeHwnd(), GWL_STYLE);
    dwStyle += WS_VISIBLE;
    SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle);   
    Invalidate();
}