Board index » cppbuilder » TMyForm::FormKeyUp

TMyForm::FormKeyUp


2004-07-21 09:21:23 PM
cppbuilder48
I have a method in my Form for tracking the enter key like this:
void __fastcall TMyForm::FormKeyUp(...)
{
if(Key == VK_RETURN)ShowMessage("My message");
}
The problem is when the ShowMessage is showed if I use enter key, the
FormKeyUp is fired, and then show again the message box. How I can
desactivate the FormKeyUp method when the ShowMessage is active (showed) ?
Sam
 
 

Re:TMyForm::FormKeyUp

Solution 1) Use FormKeyUp instead.
Solution 2) Implement logic to determine if the key was down:
bool KeyWasDown = false;
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if( Key == VK_RETURN )
KeyWasDown = true;
}
void __fastcall TForm1::FormKeyUp(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if(Key == VK_RETURN && KeyWasDown )
{
KeyWasDown = false;
ShowMessage("My message");
}
}
Todd
"sam" < XXXX@XXXXX.COM >wrote in message news:40fe6dd4$ XXXX@XXXXX.COM ...
Quote
I have a method in my Form for tracking the enter key like this:
void __fastcall TMyForm::FormKeyUp(...)
{
if(Key == VK_RETURN)ShowMessage("My message");
}
The problem is when the ShowMessage is showed if I use enter key, the
FormKeyUp is fired, and then show again the message box. How I can
desactivate the FormKeyUp method when the ShowMessage is active (showed) ?