Sep 13, 2015 at 10:40am UTC
I try to register ctrl+click key and ctrl+numkeys.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
void OnWM_Create(HWND window, CREATESTRUCT * cs)
{
int i;
RegisterHotKey(window,1, MOD_CONTROL | MOD_NOREPEAT, VK_LBUTTON );
for ( i = 48; i<58; i++ )
RegisterHotKey(window,i, MOD_CONTROL | MOD_NOREPEAT, i );
...
}
LRESULT CALLBACK MapWndProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam)
{
LRESULT ret = 0;
int i;
switch (msg)
{
case WM_CREATE:
ret = 0;
OnWM_Create(window, (CREATESTRUCT*)lParam);
break ;
case WM_HOTKEY:
data.ctrlPressed = true ;
data.initiatedCount++;
break ;
// New feature: map selection
case WM_LBUTTONDOWN:
...
it never passes throuth the case WM_CREATE: ... but I can pass case WM_LBUTTONDOWN:.
How to solve this?
Last edited on Sep 13, 2015 at 12:35pm UTC
Sep 13, 2015 at 1:09pm UTC
Thank you, but the message WM_INITDIALOG is never processed. I can run the function from
case WM_CREATE:
...
I believe that is it not important in which part of the code I run the function, but it must be after the window has been created, and it was.
I have found that
1 2 3 4
bool res;
res = RegisterHotKey(window,1, MOD_CONTROL | MOD_NOREPEAT, VK_LBUTTON );
DWORD dw = GetLastError();
result is false, getlasterror returns error code 1008
ERROR_NO_TOKEN
1008 (0x3F0)
An attempt was made to reference a token that does not exist
Last edited on Sep 13, 2015 at 1:12pm UTC
Sep 13, 2015 at 2:49pm UTC
My mistake, the code is
ERROR_INVALID_FLAGS
1004 (0x3EC)
Invalid flags.
Reason found:
Minimum supported client
Windows Vista [desktop apps only]
I have XP
Last edited on Sep 13, 2015 at 2:57pm UTC