Results 1 to 7 of 7

Thread: virtual key

  1. #1
    Fengling
    Guest

    virtual key

    Hi,
    Does somebody know how to capture the Enter key?
    In my Visual c++ 5.0 program, i use the WM_KEYDOWN to capture the key press, I can capture most of the keys, like F1,F2,A,B,C....but Enter and Esc and a few others I can not. help please.

    thanks

  2. #2
    Fanatic Member
    Join Date
    Sep 2000
    Location
    UK.
    Posts
    728
    esc = Ascii code 27.
    enter/return = Ascii code 13.
    Digital-X-Treme
    Contact me on MSN Messenger: [email protected]

    [VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
    / (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]

  3. #3
    Fengling
    Guest

    my problem is...

    yes, I know the key value. My problem is that when I hit the Enter or Esc key, the program does not go to the WM_KEYDOWN function.

  4. #4
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    That's because they're already captured for things like the default button. Are you using a dialogue rather than a raw window?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  5. #5
    Fengling
    Guest

    Yes

    Yes, I am using CBitmapDialog, which is based on CDialog.
    I do not have any butttons on it, just some static lables. If the Enter and Esc are captured by default, where? and how can I change the default setting? Thanks.

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    In MFC you can probably override the PreTranslateMessage function. In WinAPI I believe it to be impossible with normal dialogs (it may be impossible with the common dialogs in MFC too).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    Fengling
    Guest

    Wink thanks for the help

    yes, you are right. I do need override the PreTranslateMessage function. It works OK now.

    Thanks again,guys.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width