目前我正在使用一个应用程序,在WebBrowser控件中播放PPT和Flash。
在WebBrowser中,我可以通过使用以下方法隐藏上下文菜单:
this.IsWebBrowserContextMenuEnabled = false;
使用以下方法捕获关键事件:
this.PreviewKeyDown += new PreviewKeyDownEventHandler(IWebBrowser_PreviewKeyDown);
但是在播放
ppt
时,上下文菜单和按键事件均无法正常工作,即我可以看到上下文菜单和箭头键强制 ppt
更改幻灯片。再次,在播放 Flash 时,上下文菜单可见,我可以处理按键事件。是否有其他设置,可以使其对于在 webBrowser 中播放的任何 (
HTML
, PPT
, Flash
, PDF
) 都相同?
编辑:1
这是我的现有代码。class IWebBrowser : WebBrowser
public IWebBrowser(RegionOptions options)
{
try
{
this.Width = 600;
this.Height = 400;
this.IsWebBrowserContextMenuEnabled = false;
this.ScrollBarsEnabled = false;
this.ScriptErrorsSuppressed = true;
this.WebBrowserShortcutsEnabled = false;
this.AllowNavigation = true;
CreateContextMenu();
this.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(IWebBrowser_DocumentCompleted);
this.PreviewKeyDown += new PreviewKeyDownEventHandler(IWebBrowser_PreviewKeyDown);
}
catch (Exception ex)
{
log.Error("IWebBrowser - ctor ", ex);
}
}
private void CreateContextMenu()
{
ContextMenuStrip myContextMenu = new ContextMenuStrip();
this.ContextMenuStrip = myContextMenu;
ToolStripMenuItem myFirstTooltip = new ToolStripMenuItem();
ToolStripMenuItem mySecondTooltip = new ToolStripMenuItem();
ToolStripMenuItem myThirdTooltip = new ToolStripMenuItem();
myFirstTooltip.Text = "Item One";
mySecondTooltip.Text = "Item Two";
myThirdTooltip.Text = "Item Three";
myContextMenu.Items.Add(myFirstTooltip);
myContextMenu.Items.Add(mySecondTooltip);
myContextMenu.Items.Add(myThirdTooltip);
}
为不同控件播放在Web浏览器中的上下文菜单图像
显示网页..................
在Web浏览器中播放Flash.................
在Web浏览器中播放PPT.....................