Board index » cppbuilder » How to calculate the value for 'WORD &Key' of OnKeyDown() ...

How to calculate the value for 'WORD &Key' of OnKeyDown() ...


2004-10-06 02:00:15 AM
cppbuilder107
How to calculate the value for 'WORD &Key' of
OnKeyDown() for the specific KEY?
In DOC says ord( 'M' ), but AFAIK that doesn't exist
in BCB...
Best regards,
Vladimir Stefanovic
 
 

Re:How to calculate the value for 'WORD &Key' of OnKeyDown() ...

"Vladimir Stefanovic" < XXXX@XXXXX.COM >wrote in message
Quote
How to calculate the value for 'WORD &Key'
of OnKeyDown() for the specific KEY?
What exactly are you trying to accomplish? Please be more specific.
Quote
In DOC says ord( 'M' ), but AFAIK that doesn't
exist in BCB...
That is Delphi code. The equivilent in C++ is to just assign the character
as-is, since ASCII letters are already their own ordinal value:
Key = 'M';
Gambit
 

Re:How to calculate the value for 'WORD &Key' of OnKeyDown() ...

Wrong alert Remy, sorry:
I somehow thought that this does not work:
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if ( Key == 'Q' )
ShowMessage("Q");
... and I need this:
void __fastcall TForm1::FormKeyDown(TObject *Sender, WORD &Key,
TShiftState Shift)
{
if ( Key == 81 ) // 81 = = Q
ShowMessage("Q");
... but the both works.
Best regards,
Vladimir Stefanovic
Remy Lebeau (TeamB) < XXXX@XXXXX.COM >wrote in message
Quote

"Vladimir Stefanovic" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>How to calculate the value for 'WORD &Key'
>of OnKeyDown() for the specific KEY?

What exactly are you trying to accomplish? Please be more specific.

>In DOC says ord( 'M' ), but AFAIK that doesn't
>exist in BCB...

That is Delphi code. The equivilent in C++ is to just assign the
character
as-is, since ASCII letters are already their own ordinal value:

Key = 'M';


Gambit


 

{smallsort}

Re:How to calculate the value for 'WORD &Key' of OnKeyDown() ...

"Vladimir Stefanovic" < XXXX@XXXXX.COM >wrote in message
Quote
I somehow thought that this does not work:
That code works just fine.
Quote
if ( Key == 81 ) // 81 = = Q
Capital 'Q' equal decimal 81 in value.
Gambit