CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2003
    Posts
    162

    How to detect F1 keydown

    Hi, i have a dialog which is inside a tab control. The tab control is inside CFormView.

    How can i detect 'F1' key down regardless of where my focus is?

    I could detect it without the tab control inside my form view using PreTranslateMessage of CView to detect the 'F1' but with tab control added, it doesn't works anymore.

    Anyone has any idea?? Thanks......
    0 error(s), 0 warning(s)

  2. #2
    Join Date
    Dec 2001
    Location
    Ontario, Canada
    Posts
    2,236
    Regardless of focus you need to use a keyboard hook. If you want to hook only with-in your application this can be done in an a function. If you want to hook system-wide you must implement it in a DLL.

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    F1 ---> WM_HELP

    Handle WM_HELP in main application window.
    Note that, in ClassWizard messages list, it is renamed as WM_HELPINFO.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    Aug 2003
    Posts
    162
    mwilliamson : what do you mean by keyboard hook?? any example?

    ovidiucucu : that message is only for F1 to F12 key? or any key? Is it same as PreTranslateMessage??

    Thanks.
    0 error(s), 0 warning(s)

  5. #5
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244
    Originally posted by ayumi
    ovidiucucu : that message is only for F1 to F12 key? or any key? Is it same as PreTranslateMessage??

    Thanks.
    Only for F1.
    Not the same, PreTranslateMessage is not a message but a virtual function.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,637

    Re: How to detect F1 keydown

    Originally posted by ayumi
    Hi, i have a dialog which is inside a tab control. The tab control is inside CFormView.

    How can i detect 'F1' key down regardless of where my focus is?

    I could detect it without the tab control inside my form view using PreTranslateMessage of CView to detect the 'F1' but with tab control added, it doesn't works anymore.

    Anyone has any idea?? Thanks......
    PreTranslateMessage in your app class ought to do it.

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

Featured