About IShellLink::SetHotkey 
Author Message
 About IShellLink::SetHotkey

Hi,all:
 I call SetHotkey(HOTKEYF_ALT | HOTKEYF_CONTROL | VK_P);It produces error
C2065: 'VK_P' : undeclared identifier.Could you offer a sample for passing
on the parameter(WORD wHotKey)?


Thu, 03 Mar 2005 17:45:29 GMT  
 About IShellLink::SetHotkey

Quote:

> Hi,all:
>  I call SetHotkey(HOTKEYF_ALT | HOTKEYF_CONTROL | VK_P);It produces error
> C2065: 'VK_P' : undeclared identifier.Could you offer a sample for passing
> on the parameter(WORD wHotKey)?

Yup, VK_P isn't #defined by the windows headers. The file 'WinUser.h' contains the following...

    /*
     * VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
     * 0x40 : unassigned
     * VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
     */

...so you need to just use 'P' instead. I think too that you'll need to manually shift your modifier
flags into the HIBYTE as they are #defined in the LOBYTE range (1, 2, 4). So something like this...

    #define MAKEHOTKEY(mod, key) ((WORD)((WORD)(BYTE)mod << 8) | (BYTE)key)
    pisl->SetHotkey(MAKEHOTKEY((HOTKEYF_ALT | HOTKEYF_CONTROL), 'P'))

...or maybe this...

    union {
      WORD flags;
      struct {
          WORD key:8;
          WORD mod:8;
      };
    } hotKey;
    hotKey.mod = (HOTKEYF_ALT | HOTKEYF_CONTROL);
    hotKey.key = 'P';

    pisl->SetHotkey(hotKey.flags);

...but test it first, I'm just typing things into OE.

--
Jeff Partch [MVP]



Thu, 03 Mar 2005 22:13:21 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. IShellLink::SetHotKey

2. Problem with IShellLink Please help

3. iShellLink Failure

4. IshellLinks

5. IShellLink

6. IShellLink::GetIconLocation returns success but doesn't fill buffer

7. Property page and IShellLink

8. About IShellLink:

9. IShellLink question

10. Using IShellLink

11. Deleting a shortcut (IShellLink)

12. IShellLink and MessageBox

 

 
Powered by phpBB® Forum Software