The win32 api help file says this of the int id param of RegisterHotKey:
"To avoid conflicts with hot-key identifiers defined by other shared DLLs, a DLL should use the GlobalAddAtom function to obtain the hot-key identifier."
So this code should look something like the following right?
invoke GlobalAddAtom,addr string
mov atom,ax
invoke RegisterHotKey,hWin,atom,MOD_ALT or MOD_CONTROL,4Dh
The code works fine when I use a static hotkey id such as 1234h, but when I use GlobalAddAtom to calculate the hotkey id the RegisterHotKey call fails. Can anyone tell me what's wrong with the above code?
"To avoid conflicts with hot-key identifiers defined by other shared DLLs, a DLL should use the GlobalAddAtom function to obtain the hot-key identifier."
So this code should look something like the following right?
invoke GlobalAddAtom,addr string
mov atom,ax
invoke RegisterHotKey,hWin,atom,MOD_ALT or MOD_CONTROL,4Dh
The code works fine when I use a static hotkey id such as 1234h, but when I use GlobalAddAtom to calculate the hotkey id the RegisterHotKey call fails. Can anyone tell me what's wrong with the above code?
atom is DWORD? Yes
Try:
atom dword ?
invoke GlobalAddAtom,addr string
mov atom,eax
invoke RegisterHotKey,hWin,atom,MOD_ALT or MOD_CONTROL,4Dh
Try:
atom dword ?
invoke GlobalAddAtom,addr string
mov atom,eax
invoke RegisterHotKey,hWin,atom,MOD_ALT or MOD_CONTROL,4Dh
heya bdjames,
I think I've already tried both ways. What confused me was this:
"GlobalAddAtom returns a string atom whose value is in the range 0xC000 through 0xFFFF."
That's why I did it with a word value instead of dword.
Another thing that's confusing me is this (in GlobalAddAtom description):
"If the lpString parameter has the form "#1234", GlobalAddAtom returns an integer atom whose value is the 16-bit representation of the decimal number specified in the string (0x04D2, in this example)."
So, does the string have to be like that....i.e. comprised of numbers only?
I think I've already tried both ways. What confused me was this:
"GlobalAddAtom returns a string atom whose value is in the range 0xC000 through 0xFFFF."
That's why I did it with a word value instead of dword.
Another thing that's confusing me is this (in GlobalAddAtom description):
"If the lpString parameter has the form "#1234", GlobalAddAtom returns an integer atom whose value is the 16-bit representation of the decimal number specified in the string (0x04D2, in this example)."
So, does the string have to be like that....i.e. comprised of numbers only?
:(
I have never used GlobalAddAtom(), but I think this should work:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
string db "MyHotKey", 0
hotkeyatom dword ?
invoke GlobalAddAtom,addr string
invoke RegisterHotKey,hWin,eax,MOD_ALT or MOD_CONTROL,4Dh
mov hotkeyatom,eax
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I am not sure it is even necessary to get a atom id, I do not use it for socket programming. The ascii number thing seems to be only if you want to specify a certain number, not necessary. (for COM maybe?)
It feels similar to creating a window class.
I have never used GlobalAddAtom(), but I think this should work:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
string db "MyHotKey", 0
hotkeyatom dword ?
invoke GlobalAddAtom,addr string
invoke RegisterHotKey,hWin,eax,MOD_ALT or MOD_CONTROL,4Dh
mov hotkeyatom,eax
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
I am not sure it is even necessary to get a atom id, I do not use it for socket programming. The ascii number thing seems to be only if you want to specify a certain number, not necessary. (for COM maybe?)
It feels similar to creating a window class.
thanks for your help :)
I was having a bit of the old brain farts last night (damned St. Patrick's day weekend). It just seemed that GlobalAddAtom had to return a word. There were a couple other things in my code that weren't kosher as well so it looks like I wasted a few hours chasing imaginary bugs last night. :(
Ah well.... Everything's working properly now. Thanks again.
(edited to wonder aloud why I never thought to check that function's definition in kernel32.inc)
I was having a bit of the old brain farts last night (damned St. Patrick's day weekend). It just seemed that GlobalAddAtom had to return a word. There were a couple other things in my code that weren't kosher as well so it looks like I wasted a few hours chasing imaginary bugs last night. :(
Ah well.... Everything's working properly now. Thanks again.
(edited to wonder aloud why I never thought to check that function's definition in kernel32.inc)