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. keyboard key event

keyboard key event

Scheduled Pinned Locked Moved C / C++ / MFC
questiondesign
28 Posts 4 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.
  • N Naveen

    i hope u have created the m_combo variable and mapped the PreTranslateMessage message using the class wizard. isn't it? did u tried puting breakpoint in the PreTranslateMessage fnuction? nave

    R Offline
    R Offline
    Ram Murali
    wrote on last edited by
    #11

    Ya u r correct. I used breakpoint also. Still i couldnt get the output window. I put breakpoint in OnInitDialog and PreTranslateMessage. once i press debug button, it directly goes to pretanslatemessage function and then goes to the end of the program. since i dun input any char if( WM_KEYDOWN == pMsg->message ) becomes false. so it goes to the end of the pretanslate function. in this case i can see the minimized window in the taskbar. but i couldnt maximize it. eventually i couldnt see the output window. :( Regards, Ram

    N 1 Reply Last reply
    0
    • R Ram Murali

      Ya i have added that in between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP. Regards, Ram

      T Offline
      T Offline
      ThatsAlok
      wrote on last edited by
      #12

      Ram Murali wrote:

      Ya i have added that in between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP.

      Sorry if my question look childish, Have you added OnKeyDown function plus What is your base class for your window program

      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

      R N 2 Replies Last reply
      0
      • T ThatsAlok

        Ram Murali wrote:

        Ya i have added that in between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP.

        Sorry if my question look childish, Have you added OnKeyDown function plus What is your base class for your window program

        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

        cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

        R Offline
        R Offline
        Ram Murali
        wrote on last edited by
        #13

        :(Yes i did that too. Regards, Ram

        1 Reply Last reply
        0
        • R Ram Murali

          Ya u r correct. I used breakpoint also. Still i couldnt get the output window. I put breakpoint in OnInitDialog and PreTranslateMessage. once i press debug button, it directly goes to pretanslatemessage function and then goes to the end of the program. since i dun input any char if( WM_KEYDOWN == pMsg->message ) becomes false. so it goes to the end of the pretanslate function. in this case i can see the minimized window in the taskbar. but i couldnt maximize it. eventually i couldnt see the output window. :( Regards, Ram

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #14

          will u plz paste the PreTranslateMessage funtion here. nave

          R 1 Reply Last reply
          0
          • T ThatsAlok

            Ram Murali wrote:

            Ya i have added that in between BEGIN_MESSAGE_MAP and END_MESSAGE_MAP.

            Sorry if my question look childish, Have you added OnKeyDown function plus What is your base class for your window program

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

            N Offline
            N Offline
            Naveen
            wrote on last edited by
            #15

            ThatsAlok wrote:

            OnKeyDown

            r u saying that u can get the key down event in the combobox just by doing like this. the WM_KEYDOWN message goes to the edit control inside the combobox. It cannot be mapped like this from the dialog class, nor from a class drived from CCcomboBox nave

            T 1 Reply Last reply
            0
            • N Naveen

              will u plz paste the PreTranslateMessage funtion here. nave

              R Offline
              R Offline
              Ram Murali
              wrote on last edited by
              #16

              BOOL CTest::PreTranslateMessage(MSG* pMsg) { if( WM_KEYDOWN == pMsg->message ) { if( ::GetParent( pMsg->hwnd ) == m_combo.m_hWnd ) { TCHAR tcChar[2] = {0}; tcChar[0] = pMsg->wParam; AfxMessageBox( tcChar ); } } return CTest::PreTranslateMessage(pMsg); } Regards, Ram

              N 1 Reply Last reply
              0
              • R Ram Murali

                BOOL CTest::PreTranslateMessage(MSG* pMsg) { if( WM_KEYDOWN == pMsg->message ) { if( ::GetParent( pMsg->hwnd ) == m_combo.m_hWnd ) { TCHAR tcChar[2] = {0}; tcChar[0] = pMsg->wParam; AfxMessageBox( tcChar ); } } return CTest::PreTranslateMessage(pMsg); } Regards, Ram

                N Offline
                N Offline
                Naveen
                wrote on last edited by
                #17

                Ram Murali wrote:

                return CTest::PreTranslateMessage(pMsg);

                here lies the problem it should be like this CDialog::PreTranslateMessage(pMsg); nave

                R 1 Reply Last reply
                0
                • N Naveen

                  Ram Murali wrote:

                  return CTest::PreTranslateMessage(pMsg);

                  here lies the problem it should be like this CDialog::PreTranslateMessage(pMsg); nave

                  R Offline
                  R Offline
                  Ram Murali
                  wrote on last edited by
                  #18

                  wow. thats gr8. But now i can able to key-in only one character. cannot key-in more than one char.:( Thanx for spending ur time for me. Thanx a lot. Regards, Ram

                  N T 2 Replies Last reply
                  0
                  • R Ram Murali

                    wow. thats gr8. But now i can able to key-in only one character. cannot key-in more than one char.:( Thanx for spending ur time for me. Thanx a lot. Regards, Ram

                    N Offline
                    N Offline
                    Naveen
                    wrote on last edited by
                    #19

                    Ram Murali wrote:

                    now i can able to key-in only one character.

                    what do u mean? nave

                    R 1 Reply Last reply
                    0
                    • N Naveen

                      ThatsAlok wrote:

                      OnKeyDown

                      r u saying that u can get the key down event in the combobox just by doing like this. the WM_KEYDOWN message goes to the edit control inside the combobox. It cannot be mapped like this from the dialog class, nor from a class drived from CCcomboBox nave

                      T Offline
                      T Offline
                      ThatsAlok
                      wrote on last edited by
                      #20

                      Naveen R wrote:

                      u saying that u can get the key down event in the combobox just by doing like this. the WM_KEYDOWN message goes to the edit control inside the combobox.

                      I believe you havn't read my question carefully!, after reading your discussion with the PP(Problem Poster), i come to know he need to implement that for Combo Box!

                      Naveen R wrote:

                      t cannot be mapped like this from the dialog class, nor from a class drived from CCcomboBox

                      Really do you need my comment on this?

                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                      N 1 Reply Last reply
                      0
                      • N Naveen

                        Ram Murali wrote:

                        now i can able to key-in only one character.

                        what do u mean? nave

                        R Offline
                        R Offline
                        Ram Murali
                        wrote on last edited by
                        #21

                        Let me explain my objective briefly. I need to desing combobox in such a way tat user can only enter the character "D", "I" and "0-9", in the combobox. If a user enters other character than the above specified, it should not be displayed in the Combobox. and the maximum no of character user can enter is only 5. this is my objective. with the current code, i can only enter one character. if i press the other character, the new one replaces the old character in the combobox. lets say i wannu enter "HELLO" if i press "H" message box shows H. then if i enter I, this I replace the H in the combobox. :(:^) again thanx a lot for ur spending ur valuable time for me. Regards, Ram

                        N 1 Reply Last reply
                        0
                        • R Ram Murali

                          wow. thats gr8. But now i can able to key-in only one character. cannot key-in more than one char.:( Thanx for spending ur time for me. Thanx a lot. Regards, Ram

                          T Offline
                          T Offline
                          ThatsAlok
                          wrote on last edited by
                          #22

                          Ram Murali wrote:

                          ut now i can able to key-in only one character. cannot key-in more than one char.:(

                          create a string there only!

                          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                          cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                          1 Reply Last reply
                          0
                          • T ThatsAlok

                            Naveen R wrote:

                            u saying that u can get the key down event in the combobox just by doing like this. the WM_KEYDOWN message goes to the edit control inside the combobox.

                            I believe you havn't read my question carefully!, after reading your discussion with the PP(Problem Poster), i come to know he need to implement that for Combo Box!

                            Naveen R wrote:

                            t cannot be mapped like this from the dialog class, nor from a class drived from CCcomboBox

                            Really do you need my comment on this?

                            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                            cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                            N Offline
                            N Offline
                            Naveen
                            wrote on last edited by
                            #23

                            ThatsAlok wrote:

                            i come to know he need to implement that for Combo Box!

                            its in the first question it self.:cool: nave

                            T 1 Reply Last reply
                            0
                            • R Ram Murali

                              Let me explain my objective briefly. I need to desing combobox in such a way tat user can only enter the character "D", "I" and "0-9", in the combobox. If a user enters other character than the above specified, it should not be displayed in the Combobox. and the maximum no of character user can enter is only 5. this is my objective. with the current code, i can only enter one character. if i press the other character, the new one replaces the old character in the combobox. lets say i wannu enter "HELLO" if i press "H" message box shows H. then if i enter I, this I replace the H in the combobox. :(:^) again thanx a lot for ur spending ur valuable time for me. Regards, Ram

                              N Offline
                              N Offline
                              Naveen
                              wrote on last edited by
                              #24

                              Ram Murali wrote:

                              the new one replaces the old character in the combobox

                              this is happening only because ur showing a messagebox in that code. Try removing the AfxMessageBox in that code. nave

                              R 1 Reply Last reply
                              0
                              • N Naveen

                                Ram Murali wrote:

                                the new one replaces the old character in the combobox

                                this is happening only because ur showing a messagebox in that code. Try removing the AfxMessageBox in that code. nave

                                R Offline
                                R Offline
                                Ram Murali
                                wrote on last edited by
                                #25

                                Ya.its working now. thanx for ur help.:-D Regards, Ram

                                1 Reply Last reply
                                0
                                • N Naveen

                                  ThatsAlok wrote:

                                  i come to know he need to implement that for Combo Box!

                                  its in the first question it self.:cool: nave

                                  T Offline
                                  T Offline
                                  ThatsAlok
                                  wrote on last edited by
                                  #26

                                  Naveen R wrote:

                                  its in the first question it self.:cool:

                                  then thats my mistake :).... Sorry:)

                                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                  cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                                  N 1 Reply Last reply
                                  0
                                  • T ThatsAlok

                                    Naveen R wrote:

                                    its in the first question it self.:cool:

                                    then thats my mistake :).... Sorry:)

                                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                    cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                                    N Offline
                                    N Offline
                                    Naveen
                                    wrote on last edited by
                                    #27

                                    hei, I found u too fro India. ur from which part of India? I am from kerala... nave

                                    T 1 Reply Last reply
                                    0
                                    • N Naveen

                                      hei, I found u too fro India. ur from which part of India? I am from kerala... nave

                                      T Offline
                                      T Offline
                                      ThatsAlok
                                      wrote on last edited by
                                      #28

                                      Naveen R wrote:

                                      I found u too fro India. ur from which part of India?

                                      Haridwar

                                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                      cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and You

                                      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