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. Visual Basic
  4. Raising a keypress event without pressing a key

Raising a keypress event without pressing a key

Scheduled Pinned Locked Moved Visual Basic
tutorialhelp
5 Posts 3 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.
  • K Offline
    K Offline
    kutz9
    wrote on last edited by
    #1

    Greetings, As indicated in the title I am trying to work out how to raise a keypress event in code, something I cannot find an article or tutorial on anywhere!! Which, to me, would be counter-inuitive as it would seem to be incredibly simple. Any help would be greatly appreciated. Regards, Kutz _____________________ Don't take out the Magic Pen, Don't draw on the Infinity Board - Neil Young

    D 1 Reply Last reply
    0
    • K kutz9

      Greetings, As indicated in the title I am trying to work out how to raise a keypress event in code, something I cannot find an article or tutorial on anywhere!! Which, to me, would be counter-inuitive as it would seem to be incredibly simple. Any help would be greatly appreciated. Regards, Kutz _____________________ Don't take out the Magic Pen, Don't draw on the Infinity Board - Neil Young

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      It's not counter-intuitive, really. If you have to that you need to execute from two of more different functions/methods, move that code to it's own function/method and call it from wherever you need with whatever parameters you need. It's much easier than trying to figure out how to create event parameters from scratch. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

      K 1 Reply Last reply
      0
      • D Dave Kreskowiak

        It's not counter-intuitive, really. If you have to that you need to execute from two of more different functions/methods, move that code to it's own function/method and call it from wherever you need with whatever parameters you need. It's much easier than trying to figure out how to create event parameters from scratch. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        K Offline
        K Offline
        kutz9
        wrote on last edited by
        #3

        Sorry mate, but your comment doesn't help me at all. I found it a little hard to understand actually. It's not about catching or handling an event, but simulating a user's keytouch. This is because there is no way to open a dateTimePicker's calendar dropdown from code (or at least none that I can find) so in order to make it appear, you could raise a keypress event which would then be automatically handled by the control and make the calendar appear. Is this any clearer? _____________________ Don't take out the Magic Pen, Don't draw on the Infinity Board - Neil Young

        R 1 Reply Last reply
        0
        • K kutz9

          Sorry mate, but your comment doesn't help me at all. I found it a little hard to understand actually. It's not about catching or handling an event, but simulating a user's keytouch. This is because there is no way to open a dateTimePicker's calendar dropdown from code (or at least none that I can find) so in order to make it appear, you could raise a keypress event which would then be automatically handled by the control and make the calendar appear. Is this any clearer? _____________________ Don't take out the Magic Pen, Don't draw on the Infinity Board - Neil Young

          R Offline
          R Offline
          rwestgraham
          wrote on last edited by
          #4

          Don't know if this is the best way to do what you want, but... Find the control window handle using the FindWindowEx API. Then use the SendMessage API to send it a message that simulates a left button mouse click. The tricky part is that a DateTimePicker behaves differently depending on where you click on it. But the control itself only exposes a single hwnd for the entire control. So you will have to figure out the correct message parameters to make it think you clicked on the drop button instead of the in the date text area. Run an application that has a DTPicker control, then use the Spy++ tool to log WM_USER and all mouse related messages, and study the results. Then it is matter of tinkering with the message parameters until you find what works. Good Luck ... Robert

          K 1 Reply Last reply
          0
          • R rwestgraham

            Don't know if this is the best way to do what you want, but... Find the control window handle using the FindWindowEx API. Then use the SendMessage API to send it a message that simulates a left button mouse click. The tricky part is that a DateTimePicker behaves differently depending on where you click on it. But the control itself only exposes a single hwnd for the entire control. So you will have to figure out the correct message parameters to make it think you clicked on the drop button instead of the in the date text area. Run an application that has a DTPicker control, then use the Spy++ tool to log WM_USER and all mouse related messages, and study the results. Then it is matter of tinkering with the message parameters until you find what works. Good Luck ... Robert

            K Offline
            K Offline
            kutz9
            wrote on last edited by
            #5

            Cheers for your help, Robert. I'm not 100% on how to use FindWindowEx just yet, but a little net research will probably clear that up. I get the general idea, but how to use some of the parameters will take a bit more thinking. Cheers mate, kutz _____________________ Don't take out the Magic Pen, Don't draw on the Infinity Board - Neil Young

            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