gpt4 book ai didi

c++ - 如何恢复默认图标? (WinXP 和 Win7)

转载 作者:行者123 更新时间:2023-11-28 06:50:35 26 4
gpt4 key购买 nike

http://msdn.microsoft.com/en-us/library/windows/desktop/ms648045%28v=vs.85%29.aspx

告诉我:

If the hinst parameter is NULL and the fuLoad parameter omits the LR_LOADFROMFILE value, the lpszName specifies the OEM image to load. The OEM image identifiers are defined in Winuser.h and have the following prefixes.

但我很难弄明白。

我正在尝试这个,但它会在 var hIconBig = LoadImage... 上抛出各种错误和 var hIconSmall = LoadImage...行。

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;

var basewindow = window.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(null, 'C:\\Documents and Settings\\SONY VAIO\\My Documents\\Downloads\\puzzle.ico', IMAGE_ICON, 256, 256);
var hIconSmall = LoadImage(null, 'C:\\Documents and Settings\\SONY VAIO\\My Documents\\Downloads\\puzzle.ico', IMAGE_ICON, 16, 16);

var successSmall = SendMessage(targetWindow_handle, 0x0080 /** WM_SETICON **/ , 0 /** ICON_SMALL **/ , hIconSmall);
var successBig = SendMessage(targetWindow_handle, 0x0080 /** WM_SETICON **/ , 1 /** ICON_BIG **/ , hIconBig);

var me = Services.wm.getMostRecentWindow(null);
me.alert(successSmall);
me.alert(successBig);

user32.close();

最佳答案

要恢复正确 图标,您必须先WM_GETICON HICON,然后再设置您自己的图标并保留它们。然后,当您想要恢复图标时,WM_SETICON 使用那些已保存的图标。

GCLP_HICON 相同.

旁白:nsIBaseWindow 现在有一个可编写脚本的 nativeHandle 了吗?耶!我还不知道。是时候扔掉我在没有 nativeHandle 时的旧 title-hack 了。

关于c++ - 如何恢复默认图标? (WinXP 和 Win7),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24029824/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com