break windows execution on key press event

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • andrew

    break windows execution on key press event

    I am trying to allow a windows form to accept an escape
    character to cancel the current operation (drawing a line
    on panel control contained within the form).
    I thought that the forms KeyPress or KeyDown event would
    suffice, but I have tried them and they don't seem to work.

    My form has a treeview docked to the LHS side, with a
    splitter control and then a panel filling the RHS.

    I have tried various combinations and find that the key
    pressed event doesn't seem to fire when my form has a
    treeview control on it (i.e I tried various combinations
    of blank form, form with one panel det to fill, form with
    two panels docked and splitters etc and I was able to
    display a message informing me of the key pressed event.

    Is this a glitch and does anyone have ideas on how to
    overcome?

    Thanking a helpful soul in advance.

    Andrew
  • EricJ

    #2
    Re: break windows execution on key press event

    did you set the form keyprieview event to true?


    "andrew" <anonymous@disc ussions.microso ft.com> wrote in message
    news:005201c3be 06$1208e580$a00 1280a@phx.gbl.. .[color=blue]
    > I am trying to allow a windows form to accept an escape
    > character to cancel the current operation (drawing a line
    > on panel control contained within the form).
    > I thought that the forms KeyPress or KeyDown event would
    > suffice, but I have tried them and they don't seem to work.
    >
    > My form has a treeview docked to the LHS side, with a
    > splitter control and then a panel filling the RHS.
    >
    > I have tried various combinations and find that the key
    > pressed event doesn't seem to fire when my form has a
    > treeview control on it (i.e I tried various combinations
    > of blank form, form with one panel det to fill, form with
    > two panels docked and splitters etc and I was able to
    > display a message informing me of the key pressed event.
    >
    > Is this a glitch and does anyone have ideas on how to
    > overcome?
    >
    > Thanking a helpful soul in advance.
    >
    > Andrew[/color]


    Comment

    • Herfried K. Wagner [MVP]

      #3
      Re: break windows execution on key press event

      * "andrew" <anonymous@disc ussions.microso ft.com> scripsit:[color=blue]
      > I am trying to allow a windows form to accept an escape
      > character to cancel the current operation (drawing a line
      > on panel control contained within the form).
      > I thought that the forms KeyPress or KeyDown event would
      > suffice, but I have tried them and they don't seem to work.
      >
      > My form has a treeview docked to the LHS side, with a
      > splitter control and then a panel filling the RHS.
      >
      > I have tried various combinations and find that the key
      > pressed event doesn't seem to fire when my form has a
      > treeview control on it (i.e I tried various combinations
      > of blank form, form with one panel det to fill, form with
      > two panels docked and splitters etc and I was able to
      > display a message informing me of the key pressed event.[/color]

      You can add a button and define it as the form's 'CancelButton'. Or
      you can set the form's 'KeyPreview' property to 'True' and wait for Esc
      in the form's 'KeyDown' event handler.

      --
      Herfried K. Wagner [MVP]
      <http://www.mvps.org/dotnet>

      Comment

      Working...