开发者

How to make CDHTMLDialog hidden until the page is loaded?

after calling the DoModal method the dialog will be shown immediately. bu开发者_开发知识库t i need to make it invisible until the page is loaded. is that possible?

thanks xx


Hi you can make it hidden at start in

OnInitDialog()
   DWORD dwStyle = GetWindowLong(GetSafeHwnd(), GWL_STYLE);
   dwStyle -= WS_VISIBLE;
   SetWindowLong(GetSafeHwnd(), GWL_STYLE, dwStyle);

and then in OnNavigateComplete make it visible. But if your page will load slow it will seems like your app hangup


//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);
}


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();
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜