HI! I'd like to use Hot key control (HOTKEY_CLASS). I call function SendMessage to obtain hotkey -
Then i want to register this hot key -
DWORD dw = SendMessage(hHKwnd, HKM_GETHOTKEY, 0, 0);
And when I receive WM_HOTKEY message nothing happens. I think i don't use correctly dw variable.
RegisterHotKey(hWnd, 0, HIWORD(dw), LOWORD(dw));
Tell me, please, where is my mistake.
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.
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:
w = SendDlgItemMessage(hDlg, id, HKM_GETHOTKEY, 0, 0);
ltoa(w, c2, 10);
WriteFile(hFile, c2, strlen(c2), &dw, NULL);
After this operations my HotKey control became empty. Where is the problem?
ReadFile(hFile, cCont, GetFileSize(hFile, 0), &dw, NULL);
w = atoi(cCont);
SendDlgItemMessage(hDlg, EB_OPEN, HKM_SETHOTKEY, HIWORD(w), LOWORD(w));
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:
SendDlgItemMessage(hDlg, EB_OPEN, HKM_SETHOTKEY, w, 0);