如何象 FlashGet 一样,在IE的右键菜单中加入一个菜单项?

jeffreyren 2001-07-22 10:28:40
装了IE和FlashGet后,右键弹出的菜单会有一个 “使用网际快车下载连接”,这是如何加上的?
谢谢
...全文
171 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
thaliahujie 2001-07-27
  • 打赏
  • 举报
回复
修改Registry即可
prog_st 2001-07-27
  • 打赏
  • 举报
回复
HOWTO: Adding to the Standard Context Menus of the WebBrowser Control

Q177241


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 5.0

--------------------------------------------------------------------------------


SUMMARY
This article contains information that supplements the "Controlling the Context Menus" section in the "Reusing the Web Browser Control & MSHTML" overview in the Internet Client SDK. Specifically, this article describes optional registry keys to control the context in which added items are shown as well as a description of the context menu event object.



MORE INFORMATION
Here is the full complete text of the section "Adding to the Standard Context Menus":

Adding to the Standard Context Menus
Items can be added to the existing context menus of the WebBrowser control by placing entries in the registry and linking these to URLs that execute script. To add additional items to the standard WebBrowser context menus, create or open the following key:

HKEY_CURRENT_USER
Software
Microsoft
Internet Explorer
MenuExt
Under this key, you create a key (not a value) whose name contains the text you want displayed in the menu. The default value for this key contains the URL that will be executed. The key name can include the "&" character, which will cause the character immediately following the "&" to be underlined. The URL will be loaded inside of a hidden HTML dialog box, all of the inline script will be executed, and the dialog box will be closed. The hidden HTML dialog box's external.menuArguments property contains the window object of the window on which the context menu item was executed.

The following registry entry will add an item with the title "My Menu Item" to the WebBrowser context menu and will execute the inline script contained in the file "c:\myscript.htm."

HKEY_CURRENT_USER
Software
Microsoft
Internet Explorer
MenuExt
My Menu Item = "file://c:\myscript.htm"
The following are the contents of "c:\myscript.htm."

<SCRIPT LANGUAGE="JavaScript" defer>
var parentwin = external.menuArguments;
var doc = parentwin.document;
var sel = doc.selection;
var rng = sel.createRange();
var str = new String(rng.text);
if(str.length == 0)
rng.text = "MY INSERTED TEXT";
else
rng.text = str.toUpperCase();
</SCRIPT>
This script obtains the parent window object from external.menuArguments. The parent window object is the WebBrowser control in which the context menu item was executed. The script then obtains the current selection and, if no selection is present, inserts the text "MY INSERTED TEXT" at the point where the context menu was executed. If there is a selection present, the selected text is changed to uppercase.
Optional Keys
Under the item registry key created earlier, there are a couple of optional values. One of these specifies on which context menus this item will appear. The other specifies that the script should be run as a dialog box.

The "Contexts" DWORD value specifies the context menus in which an item will appear. It is a bit mask consisting of the logical OR of the following values (defined in mshtmhst.h). These values correspond to the constant passed in a IDocHostUIHandler::ShowContextMenu call.

(0x1 << CONTEXT_MENU_DEFAULT) (evaluates to 0x1)
(0x1 << CONTEXT_MENU_IMAGE) (evaluates to 0x2)
(0x1 << CONTEXT_MENU_CONTROL) (evaluates to 0x4)
(0x1 << CONTEXT_MENU_TABLE) (evaluates to 0x8)
(0x1 << CONTEXT_MENU_TEXTSELECT) (evaluates to 0x10)
(0x1 << CONTEXT_MENU_ANCHOR) (evaluates to 0x20)
(0x1 << CONTEXT_MENU_UNKNOWN) (evaluates to 0x40)
So for example, if you wanted your simple extension to appear only in the default menu and the text selection menu, you could create a DWORD value in the registry under the "My Menu Item" key called "Contexts" and set it to 0x11. From C/C++ code, this can be expressed as follows:

(0x1 << CONTEXT_MENU_DEFAULT) | (0x1 << CONTEXT_MENU_TEXTSELECT)
The other optional registry DWORD value is "Flags." There is only one bit (0x1) valid for this registry value, and it is defined as MENUEXT_SHOWDIALOG in Mshtmhst.h. When this bit is set, the script is run just as if it had been called through the ShowModalDialog method. The window that runs the script is not hidden and the dialog boxis not automatically closed after inline and onload script finishes. The external.menuArugments value still contains the window object where the user selected the menu item.
The Context Menu Event
Whenever a context menu extension is triggered, the event object off of the main window (external.menuArguments.event) contains information about where the user clicked and which context menu was shown. The mouse coordinates are valid along with event.srcElement. The event.type value contains one of the following strings, indicating which context menu was shown to the user:
MenuExtDefault


MenuExtImage


MenuExtControl


MenuExtTable


MenuExtTextSelect


MenuExtAnchor


MenuExtUnknown


Another Example
This example will create a new context menu item on just the default menu. This item, called "Show in New Window" will start whatever is clicked on in a new window. So, If something is deeply nested in a frameset, you can easily launch a specific frame in its own window. Here are the contents of a .reg file that can be run to insert the correct registry settings. Call this Example2.reg. Double-clicking on this file in the Explorer will insert the settings in your registry. REGEDIT4


[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt\Show in
&New Window]
@="file://c:\\example2.htm"
"Contexts"=dword:00000001
Here are the contents of "C:\Example2.htm."

<SCRIPT LANGUAGE="JavaScript" defer>
open(external.menuArguments.location.href);
</script>



REFERENCES
Internet Client SDK: Internet Tools & Technologies; Reusing the Web Browser Control and MSHTML; Overview


© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Jason Strayer, Microsoft Corporation


Additional query words:

Keywords : kbIE400 kbIE401 kbGrpInet kbIE500 AXSDKWebBrowser
Issue type : kbhowto
Technology :


Last Reviewed: May 8, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.




--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
panda_w 2001-07-27
  • 打赏
  • 举报
回复
修改注册表可以实现,我从编程沙龙找了一个例子,你去看看吧
http://www.programsalon.com --〉Internet编程
jeffreyren 2001-07-22
  • 打赏
  • 举报
回复
有没有类似的例子,请说详细点,谢谢
我不是大明 2001-07-22
  • 打赏
  • 举报
回复
打到IE的active 的控件!
jeffreyren 2001-07-22
  • 打赏
  • 举报
回复
please
SmartHeart 2001-07-22
  • 打赏
  • 举报
回复
好像是插件吧
jeffreyren 2001-07-22
  • 打赏
  • 举报
回复
please
jeffreyren 2001-07-22
  • 打赏
  • 举报
回复
please
jeffreyren 2001-07-22
  • 打赏
  • 举报
回复
?

16,472

社区成员

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

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

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