Article View: borland.public.cppbuilder.nativeapi
Article #3076Re: Cancelling Esc key being pressed
From: 4N
Date: Tue, 26 Sep 2006 17:14
Date: Tue, 26 Sep 2006 17:14
49 lines
2545 bytes
2545 bytes
The problem is that OnActivate of a form isn't called when a form changes is
Focused status.
I tryed catching WM_ACTIVATE but the form is activated before it receives
the Escape message so you can't block esc when the form is not focused.
I was thinking to add a timer (which autodisables itself) of 300 ms that is
enabled when WM_ACTIVATE is catched and drop the Escape key in OnKeyUp()
function till the timer is active...
but I dunno if there's a better solution.
If you have a better idea let me know it :)
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> ha scritto nel messaggio
news:45181312$1@newsgroups.borland.com...
>
> "Russell Allen" <russell.allen@bt.com> wrote in message
> news:4517e850$1@newsgroups.borland.com...
>
>> 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!
>
> void __fastcall TForm1::FormKeyUp(TObject *Sender, char &Key)
> {
> if( Key == VK_ESCAPE )
> Key = 0;
> }
>
>
>> Can I include a line to stop the Esc key press firing other events
>
> No.
>
>> can I maybe unhook the OnKeyUp event handler before the dialog
>> and rehook it after the dialog box?
>
> void __fastcall TForm1::Button1Click(TObject *Sender)
> {
> this->OnKeyUp = NULL;
> MessageDlg("Proceed?", mtConfirmation, TMsgDlgButtons() << mbYes <<
> mbCancel, 0);
> this->OnKeyUp = FormKeyUp;
> }
>
>
> Gambit
>
>
Technical Details
Message-ID:
<45195fcd$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4517e850$1@newsgroups.borland.com> <45181312$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,31de055eac3be198 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "4N" <xxxx@yyyy.zzz> Newsgroups: borland.public.cppbuilder.nativeapi References: <4517e850$1@newsgroups.borland.com> <45181312$1@newsgroups.borland.com> Subject: Re: Cancelling Esc key being pressed Date: Tue, 26 Sep 2006 19:14:56 +0200 Lines: 51 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 87.19.108.7 Message-ID: <45195fcd$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1159290829 87.19.108.7 (26 Sep 2006 10:13:49 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail