如何在 NewWindow2 中打开另一个窗口(另有其他几个问题)

solomon 2000-01-19 10:22:00
1。 微软的WebBrowser控件的NewWindow2 Event 只能打开Explorer.
有没有办法打开我的程序,或另一个MDI子窗口?
2。 不使用 ownerdraw是否可以作出左边有图标的菜单?
3。 不是用访问注册表的方法,是否可以取得系统特殊目录的路径(比如:我的文档,发送到,收藏家。。。)

...全文
429 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
SoftDIY 2000-03-09
  • 打赏
  • 举报
回复
http://www.microsoft.com/msdn/sdk/inetsdk/help/
article:how to use NewWindow2 event.
solomon 2000-03-09
  • 打赏
  • 举报
回复
Thank you SoftDIY我没有试过,不过这个问题提的时间久了,那就先把
分数给了你吧。能不能告诉我你是如何找到的?
URL=? Key = ?
SoftDIY 2000-03-07
  • 打赏
  • 举报
回复
正好今天网速较快,我在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);

CYourView* pWBVw = (CYourView*)pNewFrame->GetActiveView();
ASSERT(pWBVw);

*ppDisp = pWBVw->m_webBrowser.GetApplication();
}
solomon 2000-03-06
  • 打赏
  • 举报
回复
SoftDIY: 能不能详细点?
SoftDIY 2000-03-06
  • 打赏
  • 举报
回复
我本来的意思是设置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还有没有其他的方法?各位高手关注一下。
solomon 2000-01-24
  • 打赏
  • 举报
回复
请问,如何得知 NewWindow2时,用户想要去的 URL
SoftDIY 2000-01-21
  • 打赏
  • 举报
回复
if Cancel = TRUE,I guess new window就没有ie打开了。
你用CHtmlView应该好办了,不过我还没有试过,你可以传递参数到你的application再调用你的application.
solomon 2000-01-21
  • 打赏
  • 举报
回复
SoftDIY:
MFC 中的代码:
void CHtmlView::OnNewWindow2(LPDISPATCH* ppDisp, BOOL* bCancel)
{
// default to continuing
bCancel = FALSE;

// user will override to handle this notification
UNUSED_ALWAYS(ppDisp);
}

如果Cancel = TRUE, ppDisp = ?

solomon 2000-01-20
  • 打赏
  • 举报
回复
Hi SoftDIY:
如何 重写虚函数OnNewWindow2?
SoftDIY 2000-01-20
  • 打赏
  • 举报
回复
如果你用CHTMLView,就有virtual function OnNewWindow2.
可能你用的是CWebBrowser2,不知何故没有了这个函数。
olo 2000-01-19
  • 打赏
  • 举报
回复
直接SHGetSpecialFolderPath也可以。
olo 2000-01-19
  • 打赏
  • 举报
回复
2。 不使用 ownerdraw是否可以作出左边有图标的菜单?
SetMenuItemBitmap

3。 不是用访问注册表的方法,是否可以取得系统特殊目录的路径(比如:我的文档,发送到,收藏家。。。)

先SHGetSpecialFolderLocation
再SHGetPathFromIDList
kxy 2000-01-19
  • 打赏
  • 举报
回复
3)IShellFolder请看window的帮助.
littletao 2000-01-19
  • 打赏
  • 举报
回复
1webbrowser当然只能打开ie,你要打开其他程序,为什么不用createprocess呢?
3估计没有,呵呵,为什么不访问注册表呢?
SoftDIY 2000-01-19
  • 打赏
  • 举报
回复
to 1:自己重写虚函数OnNewWindow2,应该可以.
solomon 2000-01-19
  • 打赏
  • 举报
回复
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.
SoftDIY 2000-01-19
  • 打赏
  • 举报
回复
2.可以到mfc.363.net下载一个coolmenu,mdi、sdi的menu封装
3.LPITEMIDLIST FolderID;
SHGetSpecialFolderLocation(0, CSIDL_STARTMENU, &FolderID);//开始菜单
SHGetPathFromIDList(FolderID, StartDir);
其他具体查阅shell api帮助

16,466

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧