Pregunta

¿Hay alguna forma de cambiar el icono de la barra de tareas de un navegador en Windows?

abro un montón de ventanas del navegador, y me gusta sitios web similares de grupo (con pestañas) por la ventana. Así que me preguntaba si había una manera de asignar un icono de la barra de tareas a ellos de modo que se puede diferenciar más fácilmente entre ellos.

¿Fue útil?

Solución

Aquí hay algo que arme en menos de 5 minutos para cambiar el icono en una ventana específica. Se podría utilizar fácilmente este código para crear un WinForm que enumerar las ventanas abiertas actualmente y permitirá asignar iconos arbitrarias a ellos. (C # código de abajo)

[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);
}

Otros consejos

Creo que la barra de tareas utiliza el recurso icono incrustado en el ejecutable. He intentado crear varios accesos directos a Internet Explorer, cada uno con un icono de acceso directo único, pero todos tenían el mismo icono cuando se abre la barra de tareas.

Creo que tendría que ejecutar varias instancias del ejecutable del navegador, y cada uno tendría que tener un recurso icono incrustado diferente.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top