Here is some sample MFC code that would accomplish this task in a dialog- based application:
void CYourDlg::OnNewWindow2(LPDISPATCH FAR* ppDisp, BOOL FAR* Cancel)
{
m_dlgNewWB = new CYourDlg;
m_dlgNewWB->Create(IDD_WBDLG_DIALOG);
*ppDisp = m_dlgNewWB->m_webBrowser.GetApplication();
}
Here is some sample MFC code that would accomplish this task in an SDI or MDI application. This code creates a new frame that contains a WebBrowser control. In an SDI application, this frame would appear to the user to look like another instance of the application. In an MDI application, this frame is the same as if the user had chosen to open a new child window.
void CYourView::OnNewWindow2(LPDISPATCH FAR* ppDisp,
BOOL FAR* 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);