[?] Toggle display of PlusWnd taskbar button... - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4) +---- Forum: Scripting (/forumdisplay.php?fid=39) +----- Thread: [?] Toggle display of PlusWnd taskbar button... (/showthread.php?tid=97759) [?] Toggle display of PlusWnd taskbar button... by whiz on 06-05-2011 at 04:35 PM
js code: Error: unknown (code: -2147467259) at highlighted line. MSDN says the GetWindowLong function returns a LONG type result - is this the problem? RE: [?] Toggle display of PlusWnd taskbar button... by Eljay on 06-05-2011 at 04:44 PM *cough* GetWindowLongW *cough* RE: [?] Toggle display of PlusWnd taskbar button... by whiz on 06-07-2011 at 07:56 AM
Gah, thought I was missing something simple... RE: [?] Toggle display of PlusWnd taskbar button... by CookieRevised on 06-07-2011 at 10:24 AM
'W' stands for Wide character version, 'A' for ansi version. The difference is in how they handle strings (note that this can be an internal thing though, like with the GetWindowLong API; it doesn't nessecairly mean the API needs string parameters). js code:You should never ever do the above to toggle a flag setting! It will never work properly. You should use boolean arithmetics with the bitmask of the flags you whish to set/remove, not normal arithmetics!!! Otherwise, if the style flags already included the specific flag you whish to set, you will calculate the wrong value when you add the value of the bit in question using normal arithmetics. The same for when you whish to remove a flag when you simply substract the bitvalue instead of doing a boolean operation. Say the initial value of the styles is 15 (binary 1111), and you whish to set the 3rd bit (which is already set, but you don't know that). If you do A = A + 4 the result will actually be 19 (binary 10011), not 15 (binary 1111). So, instead you should do A = A OR 4 (4 in binary is 0100) ...which will result in 15 (binary 1111) if the initial value was already 15 (binary 1111). ...which will result in 6 (binary 0110) if the initial value was 2 (binary 0010). Vice versa, if you whish to remove the 3rd bit and your inital value has already the 3rd bit removed, for example value 10 (binary 1010): If you do A = A - 4 the result will actually be 6 (binary 0110), not the expected 10 (binary 1010). Instead you should do A = A AND 11 (11 is the mask where all bits are set except the ones you want to remove, in binary it is 1011, thus the inverse of 4, see above) ...which will result in 10 (binary 1010), if the initial value was already 10 (binary 1010). ...which will result in 9 (binary 1001), if the initial value was 13 (binary 1101). Thus if you want to set a specific flag: Result = Original OR flagvalue If you want to remove a specific flag: Result = Original AND (NOT flagvalue) So, instead you should use an AND or OR operation. eg: To set a flag (in this case WS_EX_APPWINDOW) use 'OR' with the flag's value: Get = Get | 0x40000 To remove a flag (in this case WS_EX_APPWINDOW) use 'AND' with a bitmask of the bits you whish to keep (otherwise known as the inverse of the flag value): Get = Get & ~0x40000 or Get = Get & 0xFFFBFFFF EDIT: typo fixed (! should be ~) RE: [?] Toggle display of PlusWnd taskbar button... by Matti on 06-07-2011 at 01:21 PM
One correction for Cookie: to do a bitwise NOT operation, you need to use "~" as opposed to "!", as in: js code:The boolean not will not give the wanted results:
I'm sure it was just a typo on Cookie's side but I thought it'd be better to properly explain what's wrong with it. Bitwise arithmetic is frequently used in the Windows API and more developers should be aware of it. RE: [?] Toggle display of PlusWnd taskbar button... by CookieRevised on 06-07-2011 at 02:50 PM
yeah, it was a typo... RE: [?] Toggle display of PlusWnd taskbar button... by whiz on 06-08-2011 at 07:44 PM
Yeah, I got it now. js code:It's going to be part of my DevPlus tool, so it hides the taskbar button when topmost. |