Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. 890918 - keystroke seems not to generate the desired command

890918 - keystroke seems not to generate the desired command

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    ilostmyid2
    wrote on last edited by
    #1

    hi i defined an accelerator Ctrl+T to generate ID_TMPDLG. i put

    ON\_COMMAND(ID\_TMPDLG, &Ct2App::OnTmpDlg)
    

    but the function is not called. i tried to see whether to message for the accelerator is generated correctly and i tested it in:

    BOOL Ct2App::PreTranslateMessage(MSG* pMsg)
    {
    // TODO: Add your specialized code here and/or call the base class
    if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 'T')
    return CWinAppEx::PreTranslateMessage(pMsg);
    return CWinAppEx::PreTranslateMessage(pMsg);
    }

    by defining a break point, i realized that the line is hit and the message is produced correctly. but i don't know why the command ID_TMPDLG is not generated or received by the application. i tried to handle the command in another places like main frame and child view, but it didn't help and the command is not still generated or received. i don't know whether the accelerator message is not converted into the command or the message is lost somewhere. what can i do? thx

    M 1 Reply Last reply
    0
    • I ilostmyid2

      hi i defined an accelerator Ctrl+T to generate ID_TMPDLG. i put

      ON\_COMMAND(ID\_TMPDLG, &Ct2App::OnTmpDlg)
      

      but the function is not called. i tried to see whether to message for the accelerator is generated correctly and i tested it in:

      BOOL Ct2App::PreTranslateMessage(MSG* pMsg)
      {
      // TODO: Add your specialized code here and/or call the base class
      if (pMsg->message == WM_KEYDOWN && pMsg->wParam == 'T')
      return CWinAppEx::PreTranslateMessage(pMsg);
      return CWinAppEx::PreTranslateMessage(pMsg);
      }

      by defining a break point, i realized that the line is hit and the message is produced correctly. but i don't know why the command ID_TMPDLG is not generated or received by the application. i tried to handle the command in another places like main frame and child view, but it didn't help and the command is not still generated or received. i don't know whether the accelerator message is not converted into the command or the message is lost somewhere. what can i do? thx

      M Offline
      M Offline
      mbue
      wrote on last edited by
      #2

      1.) create an accelerator resource. 2.) load them: _haccel = LoadAccelerator(0,MAKEINTRESOURCE()) 3.) translate them by calling TranslateAccelerator() have a nice day.

      I 1 Reply Last reply
      0
      • M mbue

        1.) create an accelerator resource. 2.) load them: _haccel = LoadAccelerator(0,MAKEINTRESOURCE()) 3.) translate them by calling TranslateAccelerator() have a nice day.

        I Offline
        I Offline
        ilostmyid2
        wrote on last edited by
        #3

        oh thanx so u mean my defined accelerator is not loaded or is not translated? i put it in the only one pre-existing accelerator list with the id of IDR_MAINFRAME. if it's not loaded the other defined accelerators in the list must also not work, but they do. for example Ctrl+S brings up the Save As dialog, etc. how can i justify this and how can i check that whether an accelerator is loaded or translated properly and where in the program does this happen? thx

        M 1 Reply Last reply
        0
        • I ilostmyid2

          oh thanx so u mean my defined accelerator is not loaded or is not translated? i put it in the only one pre-existing accelerator list with the id of IDR_MAINFRAME. if it's not loaded the other defined accelerators in the list must also not work, but they do. for example Ctrl+S brings up the Save As dialog, etc. how can i justify this and how can i check that whether an accelerator is loaded or translated properly and where in the program does this happen? thx

          M Offline
          M Offline
          mbue
          wrote on last edited by
          #4

          "so u mean my defined accelerator is not loaded or is not translated?" yes indeed - set a breakpoint at the TranslateMessage of the base class. enshure your accelerators are loaded. it seems only the predefined accelerators will work. good luck.

          I 1 Reply Last reply
          0
          • M mbue

            "so u mean my defined accelerator is not loaded or is not translated?" yes indeed - set a breakpoint at the TranslateMessage of the base class. enshure your accelerators are loaded. it seems only the predefined accelerators will work. good luck.

            I Offline
            I Offline
            ilostmyid2
            wrote on last edited by
            #5

            i couldn't find TranslateMessage! it seems to be an API function, not belonging to any class. TranslateMessage of what class u mean?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups