【问题标题】:Is there any way to change the taskbar icon of a browser in windows?有什么办法可以改变windows中浏览器的任务栏图标吗?
【发布时间】:2010-09-26 07:01:51
【问题描述】:

有什么办法可以改变windows中浏览器的任务栏图标吗?

我打开了很多浏览器窗口,我喜欢按窗口对相似的网站(在标签中)进行分组。所以我想知道是否有一种方法可以为它们分配一个任务栏图标,以便您可以更轻松地区分它们。

【问题讨论】:

  • 任何同时打开六个以上网站的人都有严重的注意力障碍问题,选择你最喜欢的。
  • (或者可能只是要做很多事情......):-)

标签: internet-explorer firefox browser add-in taskbar


【解决方案1】:

这是我在不到 5 分钟的时间内整理出来的,用于更改特定窗口上的图标。您可以轻松地使用此代码创建一个 Winform,该 Winform 将枚举当前打开的窗口并允许您为它们分配任意图标。 (下面是C#代码)

[DllImport("user32.dll", CharSet=CharSet.Auto)]
public static extern IntPtr FindWindow(string strClassName, string strWindowName);

[DllImport("user32.dll",CharSet=CharSet.Auto)]  
private static extern int SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam); 

[DllImport("user32.dll")] 
public static extern int DrawMenuBar(int currentWindow);


const int WM_GETICON = 0x7F;
const int WM_SETICON = 0x80;
const int ICON_SMALL = 0; //16
const int ICON_BIG = 1; //32

public static void SetIcon()
{
    //Load an icon. This has to be a *.ico.
    System.Drawing.Icon i = new Icon("path\to\icon");
    //Find the target window. The caption must be entered exactly 
    //as it appears in the title bar
    IntPtr hwnd = FindWindow(null, "Caption of Target Window");
    //Set the icon
    SendMessage(hwnd, WM_SETICON, (IntPtr)ICON_SMALL, (IntPtr)i.Handle);
    //Update the title bar with the new icon. Note: the taskbar will
    //update without this, you only need this if you want the title
    //bar to also display the new icon
    DrawMenuBar((int)hwnd);
}

【讨论】:

  • 哇!以后我得试试!
  • 这非常好,感谢发布。但我只想指出,这段代码为 16x16 的使用提供了一个(大概)32x32 图标,这意味着 Windows 会对其进行下采样。如果可能,最好提供真正的 16x16 图标,以及 Windows 将用于 Alt-Tab 菜单和(对于 Windows 7)任务栏的 32x32 图标。要提供两种图标大小,您需要使用两次 SendMessage。例如,请参见此处:blog.barthe.ph/2009/07/17/wmseticon
【解决方案2】:

我相信任务栏使用嵌入在可执行文件中的图标资源。我尝试为 Internet Explorer 创建多个快捷方式,每个快捷方式都有一个唯一的快捷方式图标,但它们在任务栏上打开时都有相同的图标。

我认为您必须运行浏览器可执行文件的多个实例,并且每个实例都必须具有不同的嵌入式图标资源。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-10
    • 1970-01-01
    • 2013-09-04
    • 1970-01-01
    • 1970-01-01
    • 2017-02-23
    相关资源
    最近更新 更多