0

首先,我是 Visual Studio 编程的真正新手。话虽如此,我创建了一个弹出 Internet Explorer 窗口的小程序;我现在想用项目的图标替换左上角的 Internet Explorer 图标。

目前,我在 C# 中打开窗口,使用ShDocVw对象:

    static void Main(string[] args)
    {
        SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer
        {      
                AddressBar = false,
                MenuBar = false,
                StatusBar = false,
                ToolBar = 0,
                Visible = true,
                Height = 768
            };

            IE.Navigate2("http://someURL/page.aspx");

        }

我要替换的是左上角的 IE 图标(参见包含的图片)。该图标作为资源在我的项目中,并出现在 .exe 上。

IE 标头的屏幕截图

有没有办法在这里更改浏览器图标?

4

1 回答 1

1

检查SHDocVw InternetExplorer Interface并在我这边测试后,似乎无法通过SHDocVw库更改左侧的IE窗口图标。

根据您的描述,我建议您可以尝试创建 WPF 或 Windows 窗体应用程序,然后使用WebViewWebView2控件来显示 Web 内容。在这种情况下,您可以为 WPF 或 Windows 窗体窗口添加自定义图标。像这样的截图:

在此处输入图像描述

关于如何设置窗口图标,请参考以下方法:

  • 对于 WPF 应用程序,尝试使用以下代码(设置 Icon 属性):

    <Window x:Class="WpfApp1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:WpfApp1"
            mc:Ignorable="d"
            Icon="favicon.ico"
            Title="MainWindow" Height="450" Width="800">
        <Grid>
    
        </Grid>
    </Window>
    

    更多详细信息,请查看在 WPF 中设置应用程序图标

  • 到 Windows 窗体应用程序。

    右键单击Form,在Properties中,它包含 Icon 属性,单击...按钮选择图标。

    在此处输入图像描述

于 2020-01-18T07:16:37.633 回答