设置Windows问题图标(WinXP和Win7) [英] Setting Icon of Windows Issues (WinXP and Win7)

查看:240
本文介绍了设置Windows问题图标(WinXP和Win7)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用js-ctypes制作一个firefox插件,并使用user32.dll函数设置配置文件所有窗口的图标。



我计划



因此,我设置的图标如下:


如果窗口集中到一个组(因为任务栏溢出)和所有图标都被更改,集中组图标仍然不是已更改的组图标。如图所示:


我想你没有运气了。 XP将采取任何图标是 .exe IIRC中的主要资源图标。



XP已经死了。


Win 7上的问题


IIRC,您必须使用 System.AppUserModel.RelaunchIcon ...



编辑
其实我对于XP分组。最后搞砸了图标在win32前一段时间。 GCLP_HICON

$ 可以工作。


I'm making a firefox addon with js-ctypes and was using user32.dll functions to set the icons of all windows of a profile.

I plan to do this for Mac OS and Linux but trying to knock out Windows right now first.

So I'm setting the icons like this: GitHub - Gist :: Noitidart / _ff-addon-snippet-ChangeWindowIcon.js - Rev2

That code is simplified. This code I use to apply to 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();

So the issues are:

  • Issues On WinXP
    • When press Alt + Tab the icon is the normal one
    • If windows are lumped into one group (because of taskbar overflow) and ALL icons are changed, the lumped group icon is still not the changed one. As seen in image here:
  • Issues On Win7
    • If the application IS PINNED and even if all windows icons are changed to be the same, it still does not changed the pin icon
    • If the application is NOT PINNED then if change the icon for all windows it will change the icon on the taskbar HOWEVER if you right click on the icon in the taskbar it reverts to what it was normally and running the snippet above again won't set it back, to get it back to icon you set you have to pin and unpin

Thanks Noit

解决方案

You really shouldn't put so much questions into a single question...

When press Alt + Tab the icon is the normal one

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

If windows are lumped into one group (because of taskbar overflow) and ALL icons are changed, the lumped group icon is still not the changed one. As seen in image here:

I think you're out of luck for this one. XP will take whatever icon is the main resource icon in the .exe IIRC.

XP is dead anyway...

Issues On Win 7

IIRC you'll have to work with System.AppUserModel.RelaunchIcon...

Edit Actually I might be wrong regarding the XP grouping stuff. Last messed around with icons on win32 quite a while ago. GCLP_HICON/GCLP_HICONSM might work.

这篇关于设置Windows问题图标(WinXP和Win7)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆