Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Virtual key code

DonotaloDonotalo Member Posts: 715
[purple]what is the virtual key code for equal sign (=)? i googled for it but cudn't find the equal sign in any virtual key code list.
[/purple]
[hr][purple]~Donotalo()[/purple]

Comments

  • anthrax11anthrax11 Member Posts: 511
    : [purple]what is the virtual key code for equal sign (=)? i googled for it but cudn't find the equal sign in any virtual key code list.
    : [/purple]
    : [hr][purple]~Donotalo()[/purple]
    :

    [blue]Virtual keys map the actual keys on the keyboard, but the equal sign requires a key combination. If you`re doing a window loop, you could process WM_CHAR instead of WM_KEYDOWN/WM_KEYUP. That way, the virtual keys are already translated into character codes for you by the TranslateMessage function in the window loop.[code]; WndProc
    switch (message) {
    case WM_CHAR:
    switch (wParam)
    case "=":
    ...
    )[/code]
    I hope this helps![/blue]
  • DonotaloDonotalo Member Posts: 715
    : : [purple]what is the virtual key code for equal sign (=)? i googled for it but cudn't find the equal sign in any virtual key code list.
    : : [/purple]
    : : [hr][purple]~Donotalo()[/purple]
    : :
    :
    : [blue]Virtual keys map the actual keys on the keyboard, but the equal sign requires a key combination. If you`re doing a window loop, you could process WM_CHAR instead of WM_KEYDOWN/WM_KEYUP. That way, the virtual keys are already translated into character codes for you by the TranslateMessage function in the window loop.[code]; WndProc
    : switch (message) {
    : case WM_CHAR:
    : switch (wParam)
    : case "=":
    : ...
    : )[/code]
    : I hope this helps![/blue]
    :
    [purple]i see. thanks. i was trying to implement every WM_KEYDOWN using virtual key code.

    another question: when a key is pressed, how do i detect whether SHIFT, CTRL or ALT, or any combination of these, is also pressed or not?
    [/purple]
    [hr][purple]~Donotalo()[/purple]

  • anthrax11anthrax11 Member Posts: 511
    [purple]: another question: when a key is pressed, how do i detect whether SHIFT, CTRL or ALT, or any combination of these, is also pressed or not?
    : [/purple]
    : [hr][purple]~Donotalo()[/purple]
    :
    :
    [blue]Use GetKeyState with the virtual key code(VK_SHIFT, VK_CONTROL, VK_MENU[grey](Alt)[/grey]) as the parameter.
    The high-order bit of the return value is set if the key is down:
    [code]
    if (GetKeyState(VK_SHIFT) < 0) {
    ...
    }
    [/code]MSDN on GetKeyState:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/getkeystate.asp

    I think you may want to read about accelerators for an analogical approach:
    http://msdn2.microsoft.com/en-us/library/ms646335.aspx[/blue]
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [b][red]This message was edited by AsmGuru62 at 2006-11-23 5:15:59[/red][/b][hr]
    [b][red]This message was edited by AsmGuru62 at 2006-11-23 5:15:20[/red][/b][hr]
    [blue]Some keys should go into WM_KEYDOWN section and symbols will go into WM_CHAR section of WndProc(). For example arrows will not generate WM_CHARs - only WM_KEYDOWN/WM_KEYUP pairs. However, some key will generate both messages: VK_TAB, VK_RETURN, etc. Trace it in debugger and you will see. Combination of keys: just call the GetKeyState() a few times to get a combination:
    [/blue]
    [code]
    int bShift = (GetKeyState (VK_SHIFT) < 0);
    int bCtrl = (GetKeyState (VK_CONTROL) < 0);

    if (!bShift && !bCtrl) {
    UnmodifiedKeyDown ();
    }
    else if (bShift && !bCtrl) {
    ShiftKeyDown ();
    }
    else if (!bShift && bCtrl) {
    CtrlKeyDown ();
    }
    else if (bShift && bCtrl) {
    CtrlShiftKeyDown ();
    }
    [/code]




Sign In or Register to comment.