【问题标题】:c# internet explorer control , make style none as if wpf window style none and allowtransparency时间:2018-10-10 标签:c#internet explorer control,make style none as if wpf window style none and allowtransparency
【发布时间】:2014-04-04 12:07:27
【问题描述】:

我想知道,有没有办法让 Internet Explorer 风格像 wpf 应用程序一样没有窗口。

谢谢,

代码:

public static void test()
        {

            System.Type oType = System.Type.GetTypeFromProgID("InternetExplorer.Application");

            SHDocVw.InternetExplorer ie = Activator.CreateInstance(oType) as SHDocVw.InternetExplorer;

            ie.MenuBar = false;
            ie.ToolBar = 0;
            ie.StatusBar = false;
            ie.AddressBar = false;

            ie.Width = 800;
            ie.Height = 600;

            ie.Visible = true;
            ie.Navigate("http://m.naver.com");

        }

【问题讨论】:

  • 你尝试了什么?您显示的代码没有尝试设置任何样式。
  • 我想删除 Internet Explorer 框架,例如边框、字幕。它就像 wpf 应用程序中的无样式窗口。

标签: c# wpf internet-explorer


【解决方案1】:

我不知道有什么方法可以用 SHDocVw.InternetExplorer 实现这一点,但是你可以使用 System.Windows.Controls.WebBrowser:

Window window = new Window();
window.WindowStyle = WindowStyle.None;
window.ResizeMode = ResizeMode.NoResize;
window.Width = 800;
window.Height = 600;

WebBrowser webBrowser = new WebBrowser();
webBrowser.Navigate("http://m.naver.com");

window.Content = webBrowser;
window.Show();

如果您不希望发生内存泄漏,请记住在使用完 WebBrowser 对象后将其释放。

【讨论】:

  • 感谢您的回复。如果我使用 webbrowser,由于原始网站(如“m.naver.com”)或任何使用 javascript 的网站的 javascript 文件会发生一些错误。所以我需要找到其他解决方案。
  • 如果这是唯一的问题,您可以supress 或fix JavaScript 错误。
  • 哦..谢谢你的解释。没有你,我从来没有意识到使用抑制方法。谢谢!!我希望有一天你能从别人那里得到更多的好处,因为你做了好事。
猜你喜欢
  • 1970-01-01
  • 2019-04-16
  • 1970-01-01
  • 1970-01-01
  • 2016-02-16
  • 1970-01-01
  • 2023-03-11
  • 1970-01-01
  • 2014-11-13
相关资源
最近更新 更多