2

Windows でブラウザのタスクバー アイコンを変更する方法はありますか?

私は多くのブラウザー ウィンドウを開き、ウィンドウごとに (タブで) 類似した Web サイトをグループ化するのが好きです。そのため、それらをより簡単に区別できるように、それらにタスクバー アイコンを割り当てる方法があるかどうか疑問に思っていました。

4

2 に答える 2

5

これは、特定のウィンドウのアイコンを変更するために 5 分以内にまとめたものです。このコードを使用して、現在開いているウィンドウを列挙し、それらに任意のアイコンを割り当てることができる 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);
}
于 2008-12-10T19:04:49.020 に答える
1

タスクバーは、実行可能ファイルに埋め込まれたアイコン リソースを使用していると思います。Internet Explorer への複数のショートカットを作成しようとしましたが、それぞれに固有のショートカット アイコンが付いていましたが、タスク バーで開いたときにすべて同じアイコンが表示されました。

ブラウザー実行可能ファイルの複数のインスタンスを実行する必要があり、それぞれに異なる埋め込みアイコン リソースが必要になると思います。

于 2008-12-10T17:48:24.507 に答える