-
HotKey control
HI! I'd like to use Hot key control (HOTKEY_CLASS). I call function SendMessage to obtain hotkey -
Code:
DWORD dw = SendMessage(hHKwnd, HKM_GETHOTKEY, 0, 0);
Then i want to register this hot key -
Code:
RegisterHotKey(hWnd, 0, HIWORD(dw), LOWORD(dw));
And when I receive WM_HOTKEY message nothing happens. I think i don't use correctly dw variable.
Tell me, please, where is my mistake.
Thanks!
-
If you use HKM_GETHOKEY then use HKM_SETHOTKEY and not RegisterHotKey as you have done. In any event, HKM_GETHOTKEY returns a WORD which would require use of LOBYTE and HIBYTE macros to get at the relevant key data.
This msdn page contains more information and specific examples.
-
Thanks a lot! Finally it works!
-
Again problem =(
After i get hotkey, i write it to file.
Code:
w = SendDlgItemMessage(hDlg, id, HKM_GETHOTKEY, 0, 0);
ltoa(w, c2, 10);
WriteFile(hFile, c2, strlen(c2), &dw, NULL);
Next time, when my application sarts, i read data from file, and then transform it back to WORD(to int), and try to put into HotKey control:
Code:
WORD w;
...
ReadFile(hFile, cCont, GetFileSize(hFile, 0), &dw, NULL);
w = atoi(cCont);
SendDlgItemMessage(hDlg, EB_OPEN, HKM_SETHOTKEY, HIWORD(w), LOWORD(w));
After this operations my HotKey control became empty. Where is the problem?
-
The HKM_SETKEYWORD message requires the lParam to be zero. If you refer back to the example page I linked to earlier in this thread, you'll see that you don't have to do anything special with the return value from HKM_GETKEYWORD to use it with HKM_SETKEYWORD, eg:
Code:
SendDlgItemMessage(hDlg, EB_OPEN, HKM_SETHOTKEY, w, 0);