mirror of
https://github.com/moparisthebest/FireTray
synced 2025-01-07 19:48:03 -05:00
fix NOTIFYICONDATAW, NOTIFYICONDATAW_Vx_SIZE definitions
This commit is contained in:
parent
02e849c602
commit
d358416414
@ -18,7 +18,7 @@ function shell32_defines(lib) {
|
||||
{ "uFlags": win32.UINT },
|
||||
{ "uCallbackMessage": win32.UINT },
|
||||
{ "hIcon": win32.HICON },
|
||||
{ "szTip": ctypes.ArrayType(win32.TCHAR, 64) }, // 128 on win2k+
|
||||
{ "szTip": ctypes.ArrayType(win32.TCHAR, 128) },
|
||||
{ "dwState": win32.DWORD },
|
||||
{ "dwStateMask": win32.DWORD },
|
||||
{ "szInfo": ctypes.ArrayType(win32.TCHAR, 256) },
|
||||
@ -30,9 +30,29 @@ function shell32_defines(lib) {
|
||||
]);
|
||||
this.NOTIFY_VERSION = 3; // 2K+
|
||||
this.NOTIFYICON_VERSION_4 = 4; // Vista+
|
||||
this.NOTIFYICONDATA_V1_SIZE = 88;
|
||||
this.NOTIFYICONDATA_V2_SIZE = 488; // 2K
|
||||
this.NOTIFYICONDATA_V3_SIZE = 504; // XP
|
||||
|
||||
// #define FIELD_OFFSET(t,f) ((LONG)&(((t*)0)->f))
|
||||
function FIELD_OFFSET(aType, aField, aPos) {
|
||||
function addr2nb(a) {
|
||||
return ctypes.cast(a, ctypes.unsigned_long).value;
|
||||
}
|
||||
|
||||
// 'would be nice to use aType.ptr(1) (0 raises null pointer error) but we
|
||||
// can't access fields (or their size) from a StructType.
|
||||
let s = new aType();
|
||||
let addr_base = addr2nb(s.address());
|
||||
let addr_field;
|
||||
if (typeof(aPos) == "undefined") {
|
||||
addr_field = addr2nb(s.addressOfField(aField)); // s[aField].address() also fine
|
||||
} else {
|
||||
addr_field = addr2nb(s[aField].addressOfElement(aPos)); // pfew! nice feature!
|
||||
}
|
||||
return addr_field - addr_base;
|
||||
}
|
||||
|
||||
this.NOTIFYICONDATAW_V1_SIZE = FIELD_OFFSET(this.NOTIFYICONDATAW, 'szTip', 64); // FIELD_OFFSET(NOTIFYICONDATAW, szTip[64])
|
||||
this.NOTIFYICONDATAW_V2_SIZE = FIELD_OFFSET(this.NOTIFYICONDATAW, 'guidItem'); // 2K
|
||||
this.NOTIFYICONDATAW_V3_SIZE = FIELD_OFFSET(this.NOTIFYICONDATAW, 'hBalloonIcon'); // XP
|
||||
|
||||
lib.lazy_bind("Shell_NotifyIconW", win32.BOOL, win32.DWORD, this.NOTIFYICONDATAW.ptr);
|
||||
|
||||
|
@ -118,11 +118,20 @@ firetray.Handler.registerWindow = function(win) {
|
||||
}
|
||||
|
||||
let nid = new shell32.NOTIFYICONDATAW();
|
||||
// FIXME: We should check WINVER for NOTIFYICONDATA_*_SIZE
|
||||
nid.cbSize = shell32.NOTIFYICONDATAW.size;
|
||||
|
||||
/* string is truncate to size of buffer and null-terminated. nid.szTip is
|
||||
initialized automatically by ctypes */
|
||||
if (win32.WINVER >= win32.WIN_VERSIONS["Vista"]) {
|
||||
nid.cbSize = shell32.NOTIFYICONDATAW.size;
|
||||
} else if (win32.WINVER >= win32.WIN_VERSIONS["XP"]) {
|
||||
nid.cbSize = shell32.NOTIFYICONDATAW_V3_SIZE;
|
||||
} else if (win32.WINVER >= win32.WIN_VERSIONS["2K"]) {
|
||||
nid.cbSize = shell32.NOTIFYICONDATAW_V2_SIZE;
|
||||
} else {
|
||||
nid.cbSize = shell32.NOTIFYICONDATAW_V1_SIZE;
|
||||
}
|
||||
log.debug("SIZE="+nid.cbSize);
|
||||
|
||||
// string is truncate to size of buffer and null-terminated. nid.szTip is
|
||||
// initialized automatically by ctypes
|
||||
let nMaxCount = 127;
|
||||
let len = user32.GetWindowTextW(hwnd, nid.szTip, nMaxCount);
|
||||
log.error("errno="+ctypes.errno+" winLastError="+ctypes.winLastError);
|
||||
|
Loading…
Reference in New Issue
Block a user