views:

694

answers:

2

Is there any way to change the taskbar icon of a browser in windows?

I open alot of browser windows, and I like to group similar websites (in tabs) by window. So I was wondering if there was a way to assign a taskbar icon to them so that you can more easily differentiate between them.

+1  A: 

I believe the taskbar uses the icon resource embedded in the executable. I tried creating multiple shortcuts to Internet Explorer, each with a unique shortcut icon, but they all had the same icon when opened on the taskbar.

I think you'd have to run multiple instances of the browser executable, and each would have to have a different embedded icon resource.

Grant Wagner
+2  A: 

Here's something I put together in under 5 minutes to change the icon on a specific window. You could easily use this code to create a winform that would enumerate the currently open windows and allow you to assign arbitrary icons to them. (C# code below)

[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);
}
w4g3n3r
Wow! I'll have to try that later!
leeand00