Redirect or capture keydown event from a child form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Frank T. Clark

    Redirect or capture keydown event from a child form

    How do I redirect or capture keydown events in a parent form from a child
    form?

    I have a main form which displays another informational form marked
    "SizableToolWin dow".

    Form child = new ChildForm();

    this.AddOwnedFo rm (child);

    child.Show();

    I don't want the child form to be active just to show information. I do want
    the user to be able to move the form and change the size. How do I make sure
    that the information from any keydown events goes to the parent form?

    I have programmed extensively in C using the Win32 API but I am only
    starting with C#.


  • Wasu

    #2
    Redirect or capture keydown event from a child form


    You could create an event in the child. The parent
    subscribes to it.
    Whenever the keydown is fired on the child, you should
    fire your event. Since the main form will be subcribing to
    it, it will also get the events.

    -Wasu
    [color=blue]
    >-----Original Message-----
    >How do I redirect or capture keydown events in a parent[/color]
    form from a child[color=blue]
    >form?
    >
    >I have a main form which displays another informational[/color]
    form marked[color=blue]
    >"SizableToolWi ndow".
    >
    >Form child = new ChildForm();
    >
    >this.AddOwnedF orm (child);
    >
    >child.Show() ;
    >
    >I don't want the child form to be active just to show[/color]
    information. I do want[color=blue]
    >the user to be able to move the form and change the size.[/color]
    How do I make sure[color=blue]
    >that the information from any keydown events goes to the[/color]
    parent form?[color=blue]
    >
    >I have programmed extensively in C using the Win32 API[/color]
    but I am only[color=blue]
    >starting with C#.
    >
    >
    >.
    >[/color]

    Comment

    • Tim Matteson

      #3
      Re: Redirect or capture keydown event from a child form

      Try adding a KeyEventHandler when you create the child form:

      //Create child
      private void mnuFileNew_Clic k(object sender, System.EventArg s e)
      {
      frmChild child = new frmChild();
      frmChild.MdiPar ent = this;
      frmChild.Show() ;
      //Raise keydown events to this form
      frmChild.KeyDow n +=new KeyEventHandler (frmChild_KeyDo wn);
      }
      //Child form KeyDown event raised to parent
      private void frmChild_KeyDow n(object sender, KeyEventArgs e)
      {
      //process key here
      }
      "Frank T. Clark" <Clark@JMIsoftw are.com> wrote in message
      news:#8bFp7aiDH A.1872@TK2MSFTN GP10.phx.gbl...[color=blue]
      > How do I redirect or capture keydown events in a parent form from a child
      > form?
      >
      > I have a main form which displays another informational form marked
      > "SizableToolWin dow".
      >
      > Form child = new ChildForm();
      >
      > this.AddOwnedFo rm (child);
      >
      > child.Show();
      >
      > I don't want the child form to be active just to show information. I do[/color]
      want[color=blue]
      > the user to be able to move the form and change the size. How do I make[/color]
      sure[color=blue]
      > that the information from any keydown events goes to the parent form?
      >
      > I have programmed extensively in C using the Win32 API but I am only
      > starting with C#.
      >
      >[/color]


      Comment

      • Frank T. Clark

        #4
        Re: Redirect or capture keydown event from a child form

        Thank you. I always say. "The answer is simple... Once you know the answer."
        :)

        "Tim Matteson" <Matteson75@hot mail.com> wrote in message
        news:O2pquBciDH A.1256@tk2msftn gp13.phx.gbl...[color=blue]
        > Try adding a KeyEventHandler when you create the child form:
        >
        > //Create child
        > private void mnuFileNew_Clic k(object sender, System.EventArg s e)
        > {
        > frmChild child = new frmChild();
        > frmChild.MdiPar ent = this;
        > frmChild.Show() ;
        > //Raise keydown events to this form
        > frmChild.KeyDow n +=new KeyEventHandler (frmChild_KeyDo wn);
        > }
        > //Child form KeyDown event raised to parent
        > private void frmChild_KeyDow n(object sender, KeyEventArgs e)
        > {
        > //process key here
        > }
        > "Frank T. Clark" <Clark@JMIsoftw are.com> wrote in message
        > news:#8bFp7aiDH A.1872@TK2MSFTN GP10.phx.gbl...[color=green]
        > > How do I redirect or capture keydown events in a parent form from a[/color][/color]
        child[color=blue][color=green]
        > > form?
        > >
        > > I have a main form which displays another informational form marked
        > > "SizableToolWin dow".
        > >
        > > Form child = new ChildForm();
        > >
        > > this.AddOwnedFo rm (child);
        > >
        > > child.Show();
        > >
        > > I don't want the child form to be active just to show information. I do[/color]
        > want[color=green]
        > > the user to be able to move the form and change the size. How do I make[/color]
        > sure[color=green]
        > > that the information from any keydown events goes to the parent form?
        > >
        > > I have programmed extensively in C using the Win32 API but I am only
        > > starting with C#.
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...