c++canvasfirefox-addoniconsjsctypes

Get window icon, put it on canvas, overlay image, save as ico (WinXP and Win7)


Right now I change the icon of a window with this code.

What I want to do though is get the current icon in use by a window. Then put it on a canvas. Then put another image on that (a badge) then save it as ico.


Solution

  • Never tried that, however the follow should work in general (with a lot of fiddling)

    1. WM_GETICON to get the big and small icon.
    2. Convert the icon to something the loader can understand (aka. either a BITMAP or ICO). E.g. How can I save HICON to an .ico file?
    3. Load the image. E.g. Javascript: Render PNG stored as Uint8Array onto Canvas element without Data URI
    4. canvas.drawImage
    5. canvas.mozGetAsFile (Blob) or canvas.mozFetchAsStream (nsIInputStream) using the image/vnd.microsoft.icon mime.
    6. Take the resulting data and reconstruct an icon.
    7. LookupIconIdFromDirectoryEx and CreateIconFromResourceEx
    8. WM_SETICON