我写了一个基于CHtmlView的程序,怎样完整实现window.open呢?
我写了一个基于CHtmlView的程序,怎样完整实现对window.open的脚本支持呢?
window.open()的一版使用方式为window.open(url,targetName,features,replace)
通常用前三个参数(我还没用过第四个),features里指定了窗口的大小,是否现实菜单,地址栏等特性,如:
window.open("http://www.csdn.net","somewindow","width=400,height=450,menubar=no,status=no");
我重载了OnNewWindow2
-------------------------------
void CWebClientView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* Cancel)
{
// Get a pointer to the application object.
CWinApp* pApp = AfxGetApp();
// Get the correct document template.
POSITION pos = pApp->GetFirstDocTemplatePosition();
CDocTemplate* pDocTemplate = pApp->GetNextDocTemplate( pos );
// Create a new frame.
CFrameWnd* pFrame = pDocTemplate->CreateNewFrame(
GetDocument(),
(CFrameWnd*)AfxGetMainWnd() );
// Activate the frame.
pDocTemplate->InitialUpdateFrame( pFrame, NULL );
CWebClientView* pView = (CWebClientView*)pFrame->GetActiveView();
// Pass pointer of WebBrowser object.
pView->SetRegisterAsBrowser( TRUE );
*ppDisp = pView->GetApplication();
}
以上代码实现了新打开的窗口用我的程序中打开,但是没办法获得窗口特性的参数,也不知道把窗口调整成什么样子。