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#
  4. Redirecting keystrokes to a RichTextBox Control in C#

Redirecting keystrokes to a RichTextBox Control in C#

Scheduled Pinned Locked Moved C#
questioncsharpc++javascripthelp
3 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.
  • P Offline
    P Offline
    pbalaga
    wrote on last edited by
    #1

    I have a Form with a few panels and a RichTextBox on it. I need to detect any key messages on the level of form and send them to other child controls on my own way. I tried calling/overriding WndProc, PreProcessMessage, etc. Also tried setting my own MessageFilter via Application.AddMessageFilter() and finally gave a try to a native method SendMessage. None of these work. I CAN detect the messages. But the problem is that when I'm passing them to the RichTextBox there's no effect (no text is appended). How can I make that control react on the redirected messages? Thanks in advance.

    C 1 Reply Last reply
    0
    • P pbalaga

      I have a Form with a few panels and a RichTextBox on it. I need to detect any key messages on the level of form and send them to other child controls on my own way. I tried calling/overriding WndProc, PreProcessMessage, etc. Also tried setting my own MessageFilter via Application.AddMessageFilter() and finally gave a try to a native method SendMessage. None of these work. I CAN detect the messages. But the problem is that when I'm passing them to the RichTextBox there's no effect (no text is appended). How can I make that control react on the redirected messages? Thanks in advance.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Why can't you do it on the level of keydown, keypress and keyup messages ? Why can't you just detect a keydown and pass the focus to the control ?

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      P 1 Reply Last reply
      0
      • C Christian Graus

        Why can't you do it on the level of keydown, keypress and keyup messages ? Why can't you just detect a keydown and pass the focus to the control ?

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        P Offline
        P Offline
        pbalaga
        wrote on last edited by
        #3

        Firstly, when a key is pressed, I need to add a char to the textbox, even if it does NOT have focus. Then, when I press a key, the keydown event is obviously not detected by the textbox. The same with the form! There is no info about this event. I could use PreviewKeyDown, but I couldn't mark the message as used/handled. Secondly, the form should distribute the messages, not necessarily to the box. Maybe somewhere else, basing on other conditions.

        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