正好今天网速较快,我在msdn online查了一下,找到了,无需再下载新版internet sdk,不用处理OnBeforeNavigate2.文档如下:
Using MFC, you may wish to do this in one of three types of applications:
Dialog-based
Single document interface (SDI)
Multiple document interface (MDI)
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);
我本来的意思是设置cancle=true后,再设立一个标记,然后在OnBeforeNavigate2中进行处理,今天查阅msdn,发现msdn上讲错了,cancle=true后,不再产生BeforeNavigate2 event,不过据DOC: Setting Cancel to TRUE in NewWindow2 Stops Navigation这篇文档讲述:m$的online internet sdk改正了这个错误。如果这样就可以在OnBeforeNavigate2中取得url地址了。
不知旧版internet sdk还有没有其他的方法?各位高手关注一下。
Hi olo and SoftDIY
Your answers to question 3) is very useful
but I can only give 50 dot to share between you
because you are not answering my 1) question(the most important).
seemly there is not function like SetMenuItemIcon(...) in API.
still great thanks to you all.