From: Leo V. on
I have an MFC application that incorporates a browser in one of its views
using CHTMLView.

We have a company website that this view navigates to. On this website,
people log in and download stuff (at least in IE they do). When they login,
a session gets associated with their process. If they click on a link to
download a file, the HTML is such that it causes another window to open up
(IE in this case). Because IE is a different process, the session isn't
valid for him, so he gets an error that the page isn't available.

I found that if I override OnNewWindow2 and perform the following:

void CTestHTMLViewView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel)
{
CHtmlView::OnNewWindow2(ppDisp, Cancel);

// Get a pointer to the application object
CWinApp* pApp = AfxGetApp();

// Get the correct document template
CDocTemplate* pDocTemplate;
POSITION pos = pApp->GetFirstDocTemplatePosition();
pDocTemplate = pApp->GetNextDocTemplate(pos);
ASSERT(pDocTemplate);

// Create the new frame
CFrameWnd* pNewFrame = pDocTemplate->CreateNewFrame(GetDocument(),
(CFrameWnd*)AfxGetMainWnd());
ASSERT(pNewFrame);

// Activate the frame and set its active view
pDocTemplate->InitialUpdateFrame(pNewFrame, NULL);

CTestHTMLViewView* pvw = (CTestHTMLViewView*)pNewFrame->GetActiveView();
ASSERT(pvw);
pvw->SetRegisterAsBrowser(TRUE);
*ppDisp = pvw->GetApplication();
}

This succeeds in keeping the "Your download should begin any moment" page
from opening in IE in a different process. Now, it opens in another frame
window in my own process and it works correctly (Downloads and saves the
file).

What I'd really like is to not have to open another window, but use the
current view. Is this possible? If not, I think I'd like an alternative to
CFrameWnd because it shows a window with toolbars and menus on it, I'd
prefer something that looks a bit more like an IE popup window (just
titlebar and page).

Leo V.


From: Leo V. on
Perhaps one option is to use a modeless CDHTMLDialog.

"Leo V." <lviolette.SpamMeNot(a)orrtax.com> wrote in message
news:OACnnOwGHHA.1804(a)TK2MSFTNGP02.phx.gbl...
>I have an MFC application that incorporates a browser in one of its views
>using CHTMLView.
>
> We have a company website that this view navigates to. On this website,
> people log in and download stuff (at least in IE they do). When they
> login, a session gets associated with their process. If they click on a
> link to download a file, the HTML is such that it causes another window to
> open up (IE in this case). Because IE is a different process, the session
> isn't valid for him, so he gets an error that the page isn't available.
>
> I found that if I override OnNewWindow2 and perform the following:
>
> void CTestHTMLViewView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel)
> {
> CHtmlView::OnNewWindow2(ppDisp, Cancel);
>
> // Get a pointer to the application object
> CWinApp* pApp = AfxGetApp();
>
> // Get the correct document template
> CDocTemplate* pDocTemplate;
> POSITION pos = pApp->GetFirstDocTemplatePosition();
> pDocTemplate = pApp->GetNextDocTemplate(pos);
> ASSERT(pDocTemplate);
>
> // Create the new frame
> CFrameWnd* pNewFrame = pDocTemplate->CreateNewFrame(GetDocument(),
> (CFrameWnd*)AfxGetMainWnd());
> ASSERT(pNewFrame);
>
> // Activate the frame and set its active view
> pDocTemplate->InitialUpdateFrame(pNewFrame, NULL);
>
> CTestHTMLViewView* pvw =
> (CTestHTMLViewView*)pNewFrame->GetActiveView();
> ASSERT(pvw);
> pvw->SetRegisterAsBrowser(TRUE);
> *ppDisp = pvw->GetApplication();
> }
>
> This succeeds in keeping the "Your download should begin any moment" page
> from opening in IE in a different process. Now, it opens in another frame
> window in my own process and it works correctly (Downloads and saves the
> file).
>
> What I'd really like is to not have to open another window, but use the
> current view. Is this possible? If not, I think I'd like an alternative
> to CFrameWnd because it shows a window with toolbars and menus on it, I'd
> prefer something that looks a bit more like an IE popup window (just
> titlebar and page).
>
> Leo V.
>