Windows Settings Icon (WinXP and Win7)

I am creating a firefox addon with js-ctypes and have used the user32.dll functions to set the icons of all profile windows.

I plan to do this for Mac OS and Linux, but first try to knock out Windows.

So, I set the icons as follows: GitHub - Gist :: Noitidart / _ff-addon-snippet-ChangeWindowIcon.js - Rev2

This code is simplified. This code that I use for all windows:

Cu.import('resource://gre/modules/ctypes.jsm'); var user32 = ctypes.open('user32.dll'); var SendMessage = user32.declare('SendMessageW', ctypes.winapi_abi, ctypes.uintptr_t, ctypes.int32_t, ctypes.unsigned_int, ctypes.int32_t, ctypes.voidptr_t ); var LoadImage = user32.declare('LoadImageA', ctypes.winapi_abi, ctypes.voidptr_t, ctypes.int, ctypes.char.ptr, ctypes.unsigned_int, ctypes.int, ctypes.int, ctypes.unsigned_int ); var IMAGE_BITMAP = 0; var IMAGE_ICON = 1; var LR_LOADFROMFILE = 16; // RUNNING STUFF BELOW - ABVOE WAS JUST DEFINING STUFF var DOMWindows = Services.wm.getEnumerator(null); while (DOMWindows.hasMoreElements()) { var aDOMWindow = DOMWindows.getNext(); var basewindow = aDOMWindow.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsIWebNavigation) .QueryInterface(Ci.nsIDocShellTreeItem) .treeOwner .QueryInterface(Ci.nsIInterfaceRequestor) .nsIBaseWindow; var nativeHandle = basewindow.nativeHandle; var targetWindow_handle = parseInt(nativeHandle); var hIconBig = LoadImage(targetWindow_handle, 'C:\\Documents and Settings\\SONY VAIO\\My Documents\\Downloads\\puzzle.ico', IMAGE_ICON, 256, 256, LR_LOADFROMFILE); //MUST BE A FILEPATH TO A ICO!!! var hIconSmall = LoadImage(targetWindow_handle, 'C:\\Documents and Settings\\SONY VAIO\\My Documents\\Downloads\\puzzle.ico', IMAGE_ICON, 16, 16, LR_LOADFROMFILE); //MUST BE A FILEPATH TO A ICO!!! var successSmall = SendMessage(targetWindow_handle, 0x0080 /** WM_SETICON **/ , 0 /** ICON_SMALL **/ , hIconSmall); //if it was success it will return 0? im not sure. on first time running it, and it was succesful it returns 0 for some reason var successBig = SendMessage(targetWindow_handle, 0x0080 /** WM_SETICON **/ , 1 /** ICON_BIG **/ , hIconBig); //if it was success it will return 0? im not sure. on first time running it, and it was succesful it returns 0 for some reason } user32.close(); 

Therefore, the following problems arise:

  • Problems with WinXP
    • When you press Alt + Tab icon is normal.
    • If the windows are grouped into one group (due to the overflow of the taskbar) and ALL the icons are changed, the concentrated group icon is still not changed. As seen in the figure: _ff-addon-snippet-ChangeWindowIcon.js - Rev1 - WinXP lumped icon issue.PNG
  • Problems with Win7
    • If the application is PINNED and even if all the window icons are changed to be the same, it still did not change the icon icon
    • If the application is not PINNED, then if you change the icon for all windows, it will change the icon on the taskbar. If you right-click on the icon on the taskbar, it will go back to what was common and launched the snapshot above, don't set it back to return it to the icon you set, you need to attach and cancel

Thanks Noit

0
c ++ firefox-addon icons user32 jsctypes
source share
1 answer

You really should not pose so many questions in one question ...

When you press Alt + Tab, the icon is normal.

You are trying to download and install 256x256 icons. XP does not support such icons. You really have to add some error checking;) IIRC you have to set 32x32 icons for the big one. Or more precisely SM_CXICON and / or SM_CXSMICON

If the windows are grouped into one group (due to the overflow of the taskbar) and ALL the icons are changed, the concentrated group icon is still not changed. As seen in the figure:

I think you're out of luck. XP will take any icon - the main resource icon in .exe IIRC.

Anyway, XP is dead ...

Problems with Win 7

IIRC you will have to work with System.AppUserModel.RelaunchIcon ...

Edit Actually, I could be wrong about XP grouping. Recently, using the icons on win32 for a long time. GCLP_HICON / GCLP_HICONSM can work.

+1
source share

All Articles