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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. PreTranslateMessage return assertion

PreTranslateMessage return assertion

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 3 Posters 5 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.
  • A Offline
    A Offline
    ArielR
    wrote on last edited by
    #1

    this code: #include "myDlg.h" .... BOOL CSistemaPOSDlg::PreTranslateMessage(MSG* pMsg) { if(pMsg->message==WM_KEYDOWN { switch ( pMsg->wParam ) { case 106: // '*' was pressed - Asterisc numeric keyboard CallMyDlg(); break; case VK_RETURN: ......... break; default: break; } } return CDialog::PreTranslateMessage(pMsg); } BOOL CSistemaPOSDlg::CallMyDlg() { CmyDlg pDlg; pDlg.DoModal() } Pretranslate return me an Assertion failed when return from myDlg!! Way??

    M N 2 Replies Last reply
    0
    • A ArielR

      this code: #include "myDlg.h" .... BOOL CSistemaPOSDlg::PreTranslateMessage(MSG* pMsg) { if(pMsg->message==WM_KEYDOWN { switch ( pMsg->wParam ) { case 106: // '*' was pressed - Asterisc numeric keyboard CallMyDlg(); break; case VK_RETURN: ......... break; default: break; } } return CDialog::PreTranslateMessage(pMsg); } BOOL CSistemaPOSDlg::CallMyDlg() { CmyDlg pDlg; pDlg.DoModal() } Pretranslate return me an Assertion failed when return from myDlg!! Way??

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      What is the reason for the assertion?  Where does it occur? Is there a reason you need to handle messages in PreTranslateMessage() instead of handling them the usual MFC way? Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      1 Reply Last reply
      0
      • A ArielR

        this code: #include "myDlg.h" .... BOOL CSistemaPOSDlg::PreTranslateMessage(MSG* pMsg) { if(pMsg->message==WM_KEYDOWN { switch ( pMsg->wParam ) { case 106: // '*' was pressed - Asterisc numeric keyboard CallMyDlg(); break; case VK_RETURN: ......... break; default: break; } } return CDialog::PreTranslateMessage(pMsg); } BOOL CSistemaPOSDlg::CallMyDlg() { CmyDlg pDlg; pDlg.DoModal() } Pretranslate return me an Assertion failed when return from myDlg!! Way??

        N Offline
        N Offline
        Nishad S
        wrote on last edited by
        #3

        Just try to call the CDialog::PreTranslateMessage(pMsg) before the CallMyDlg(). I think the problem is because the DoModal will initiate a different message loop, thus the current message may be handled by this second message loop. So when the CDialog::PreTranslateMessage is called, the current message will be different or none. (Only a guess :)) )

        - NS -

        A 1 Reply Last reply
        0
        • N Nishad S

          Just try to call the CDialog::PreTranslateMessage(pMsg) before the CallMyDlg(). I think the problem is because the DoModal will initiate a different message loop, thus the current message may be handled by this second message loop. So when the CDialog::PreTranslateMessage is called, the current message will be different or none. (Only a guess :)) )

          - NS -

          A Offline
          A Offline
          ArielR
          wrote on last edited by
          #4

          Does Exist a way to release, or kill the loop from myDlg before return to the parent?

          N 1 Reply Last reply
          0
          • A ArielR

            Does Exist a way to release, or kill the loop from myDlg before return to the parent?

            N Offline
            N Offline
            Nishad S
            wrote on last edited by
            #5

            You mean exit from the application? Or simply skip the current loop of PreTranslateMsg?

            - NS -

            A 1 Reply Last reply
            0
            • N Nishad S

              You mean exit from the application? Or simply skip the current loop of PreTranslateMsg?

              - NS -

              A Offline
              A Offline
              ArielR
              wrote on last edited by
              #6

              the current loop, may be only with return;

              N 1 Reply Last reply
              0
              • A ArielR

                the current loop, may be only with return;

                N Offline
                N Offline
                Nishad S
                wrote on last edited by
                #7

                I think you need to skip the * key hit, right? If so you can just assign pMsg->message = WM_NULL. Then the allowing the current loop to continue.

                - NS -

                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