🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #3072

Cancelling Esc key being pressed

#3072
From: Russell Allen
Date: Mon, 25 Sep 2006 14:31
25 lines
1717 bytes
Hi all,

I have a form with a FormKeyUp event handler intended to intercept the Esc key, and do something, as below (semi-pseudo-code).

TForm1::FormKeyUp(Sender, Key) {
  if (Key == 27)
    ShowMessage("Esc key pressed");
}

TForm1::Button1Click(Sender) {
  MessageDlg("Proceed?", mtConfirmation, TMsgDlgButtons() <<
     mbYes << mbCancel, 0);

  // Can I put some code here to stop FormKeyUp firing when
  // the user presses Esc?
}

The problem I'm having - when a piece of code elsewhere pops up a dialog box with a Cancel option, if the user presses "Esc" to cancel the dialog box, not only is the dialog box cancelled, the onkeyup event is being fired off as well!

Can I include a line to stop the Esc key press firing other events, or can I maybe unhook the OnKeyUp event handler before the dialog and rehook it after the dialog box?

Thanks in advance,

Russ
Technical Details
Message-ID: <4517e850$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!panix!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,31de055eac3be198,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Russell Allen" <russell.allen@bt.com>
Sender: "Russell Allen" <russell.allen@bt.com>
Reply-To: "Russell Allen" <russell.allen@bt.com>
Subject: Cancelling Esc key being pressed
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 193.113.57.163     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4517e850$1@newsgroups.borland.com>
Date: 25 Sep 2006 07:31:44 -0700
X-Trace: newsgroups.borland.com 1159194704 207.105.83.66 (25 Sep 2006 07:31:44 -0700)
Lines: 25
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!panix!newsfeed.media.kyoto-u.ac.jp!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail