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. Managed C++/CLI
  4. OnKeyPress oddity

OnKeyPress oddity

Scheduled Pinned Locked Moved Managed C++/CLI
c++question
18 Posts 3 Posters 51 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.
  • J James T Johnson

    Ensure that IsInputKey/Char returns true for that key; if it returns false you won't get the OnKey* events. James Simplicity Rules!

    N Offline
    N Offline
    Nish Nishant
    wrote on last edited by
    #4

    James T. Johnson wrote: Ensure that IsInputKey/Char returns true for that key; if it returns false you won't get the OnKey* events. You mean in addition to overriding OnKeyPress I also need to override IsInputKey ??? Nish


    Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

    1 Reply Last reply
    0
    • J James T Johnson

      Ensure that IsInputKey/Char returns true for that key; if it returns false you won't get the OnKey* events. James Simplicity Rules!

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #5

      I did this :-

      protected override bool IsInputKey(System.Windows.Forms.Keys keyData)
      {
      base.IsInputKey(keyData);
      return true;
      }

      But still OnKeyPress never gets called! Nish


      Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

      R 1 Reply Last reply
      0
      • N Nish Nishant

        I did this :-

        protected override bool IsInputKey(System.Windows.Forms.Keys keyData)
        {
        base.IsInputKey(keyData);
        return true;
        }

        But still OnKeyPress never gets called! Nish


        Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

        R Offline
        R Offline
        Rama Krishna Vavilala
        wrote on last edited by
        #6

        Use Anakrino. When you have anakrino you don't need to ask any quetions anywhere.:)

        N 2 Replies Last reply
        0
        • R Rama Krishna Vavilala

          Use Anakrino. When you have anakrino you don't need to ask any quetions anywhere.:)

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #7

          Rama Krishna wrote: Use Anakrino. When you have anakrino you don't need to ask any quetions anywhere How do I use Anakrino in this situation, Rama? My problem is that a handler is not getting called in the derived class despite the fact that I have overridden it :-( Nish


          Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

          1 Reply Last reply
          0
          • R Rama Krishna Vavilala

            Use Anakrino. When you have anakrino you don't need to ask any quetions anywhere.:)

            N Offline
            N Offline
            Nish Nishant
            wrote on last edited by
            #8

            I overrode WndProc and found that the WM_KEYDOWN message is not being received :-(

            protected override void WndProc(ref System.Windows.Forms.Message m)
            {
            base.WndProc(ref m);
            if(m.Msg == 0x0100)
            Text = "Hello World";
            }

            Nish p.s. In an MC++ program I can #include windows.h to get the defines for various messages, in a C# program how do I get the defines for messages. Above I have hardcoded 0x0100 [WM_KEYDOWN]


            Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

            J R 2 Replies Last reply
            0
            • N Nish Nishant

              I am deriving a class from ComboBox. I override OnKeyPress. But OnKeyPress never gets called! Anyone knows whether there is anything special I need to be doing? Nish


              Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

              N Offline
              N Offline
              Nish Nishant
              wrote on last edited by
              #9

              Blast! Just found out that this is a bug in both beta 1 and beta 2 Nish p.s. Gotta try this from home now :mad:


              Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

              1 Reply Last reply
              0
              • N Nish Nishant

                I overrode WndProc and found that the WM_KEYDOWN message is not being received :-(

                protected override void WndProc(ref System.Windows.Forms.Message m)
                {
                base.WndProc(ref m);
                if(m.Msg == 0x0100)
                Text = "Hello World";
                }

                Nish p.s. In an MC++ program I can #include windows.h to get the defines for various messages, in a C# program how do I get the defines for messages. Above I have hardcoded 0x0100 [WM_KEYDOWN]


                Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

                J Offline
                J Offline
                James T Johnson
                wrote on last edited by
                #10

                Find in Files for WM_KEYDOWN ;P There are a couple programs out there which will let you get the constants but I find it much easier to just do a Find in Files. James Simplicity Rules!

                N 1 Reply Last reply
                0
                • N Nish Nishant

                  I overrode WndProc and found that the WM_KEYDOWN message is not being received :-(

                  protected override void WndProc(ref System.Windows.Forms.Message m)
                  {
                  base.WndProc(ref m);
                  if(m.Msg == 0x0100)
                  Text = "Hello World";
                  }

                  Nish p.s. In an MC++ program I can #include windows.h to get the defines for various messages, in a C# program how do I get the defines for messages. Above I have hardcoded 0x0100 [WM_KEYDOWN]


                  Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

                  R Offline
                  R Offline
                  Rama Krishna Vavilala
                  wrote on last edited by
                  #11

                  Incidentally there was a discussion about this in one of my articles Link Don't use WndProc, use PreProcessMessage.

                  N 1 Reply Last reply
                  0
                  • N Nish Nishant

                    Rama Krishna wrote: Incidentally there was a discussion about this in one of my articles Link Thanks. Checked it out! Nish


                    Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

                    R Offline
                    R Offline
                    Rama Krishna Vavilala
                    wrote on last edited by
                    #12

                    How your article works. I see that OnKeyPress is getting called. :) Ofcourse highlighting text by mouse doesnot work in your combo box. :(

                    N 1 Reply Last reply
                    0
                    • J James T Johnson

                      Find in Files for WM_KEYDOWN ;P There are a couple programs out there which will let you get the constants but I find it much easier to just do a Find in Files. James Simplicity Rules!

                      N Offline
                      N Offline
                      Nish Nishant
                      wrote on last edited by
                      #13

                      James T. Johnson wrote: Find in Files for WM_KEYDOWN Blast!!! Of all things, a Jambo joke!!! Boooohhhhhhhhh! We don't want Jambo jokes! Booooooooooo! We want jambo-edited articles ;-) Nish


                      Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

                      J 1 Reply Last reply
                      0
                      • R Rama Krishna Vavilala

                        Incidentally there was a discussion about this in one of my articles Link Don't use WndProc, use PreProcessMessage.

                        N Offline
                        N Offline
                        Nish Nishant
                        wrote on last edited by
                        #14

                        Rama Krishna wrote: Incidentally there was a discussion about this in one of my articles Link Thanks. Checked it out! Nish


                        Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

                        R 1 Reply Last reply
                        0
                        • N Nish Nishant

                          James T. Johnson wrote: Find in Files for WM_KEYDOWN Blast!!! Of all things, a Jambo joke!!! Boooohhhhhhhhh! We don't want Jambo jokes! Booooooooooo! We want jambo-edited articles ;-) Nish


                          Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

                          J Offline
                          J Offline
                          James T Johnson
                          wrote on last edited by
                          #15

                          Nish - Native CPian wrote: We want jambo-edited articles I'll get back to editing once I figure out what has caused me headaches the past 2 days. James Simplicity Rules!

                          1 Reply Last reply
                          0
                          • R Rama Krishna Vavilala

                            How your article works. I see that OnKeyPress is getting called. :) Ofcourse highlighting text by mouse doesnot work in your combo box. :(

                            N Offline
                            N Offline
                            Nish Nishant
                            wrote on last edited by
                            #16

                            Rama Krishna wrote: How your article works It was a bug with beta 2. OnKeyPress won't get called in beta 2 :-) Rama Krishna wrote: Ofcourse highlighting text by mouse doesnot work in your combo box Huh? It does here :confused: Nish


                            Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

                            R 1 Reply Last reply
                            0
                            • N Nish Nishant

                              Rama Krishna wrote: How your article works It was a bug with beta 2. OnKeyPress won't get called in beta 2 :-) Rama Krishna wrote: Ofcourse highlighting text by mouse doesnot work in your combo box Huh? It does here :confused: Nish


                              Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

                              R Offline
                              R Offline
                              Rama Krishna Vavilala
                              wrote on last edited by
                              #17

                              Nish - Native CPian wrote: It was a bug with beta 2. OnKeyPress won't get called in beta 2 I got it. I thought that it was still a bug:) Nish - Native CPian wrote: Huh? It does here Sorry It doesnot work for me. BTW don't you love the rating you got for the new article.

                              N 1 Reply Last reply
                              0
                              • R Rama Krishna Vavilala

                                Nish - Native CPian wrote: It was a bug with beta 2. OnKeyPress won't get called in beta 2 I got it. I thought that it was still a bug:) Nish - Native CPian wrote: Huh? It does here Sorry It doesnot work for me. BTW don't you love the rating you got for the new article.

                                N Offline
                                N Offline
                                Nish Nishant
                                wrote on last edited by
                                #18

                                Rama Krishna wrote: BTW don't you love the rating you got for the new article. Yeah, about twice as much as my usual :-) Nish


                                Regards, Nish Native CPian. Born and brought up on CP. With the CP blood in him.

                                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