Please bear with me as this is an area I have little or no knowledge
in.  I understand you need to check for the particular key in the OnKeyDown
event, but I was assuming in error that the "and $80)> 0 was doing the same.

        How exactly does this part work?  You say it masks out the other
bits in the byte returned by GetKeyState, but why is that necessary in this
example when it wasn't in the other I mentioned earlier where I had
originally been using GetAsynchKeyState?  That now works perfectly without
having to mask out the other bits.
        This is exactly why I've been wanting to take some real computer
science courses.  I'm working at a completely abstracted level and really
don't understand what's going on beneath the covers!  

from Robert Meek dba Tangentals Design  CCopyright 2006

"When I examine myself and my methods of thought, I come to the conclusion
that the gift of Fantasy has meant more to me then my talent for absorbing
positive knowledge!"
                                                    Albert Einstein


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Rob Kennedy
Sent: Monday, April 24, 2006 3:04 PM
To: Borland's Delphi Discussion List
Subject: RE: Virtual key codes

Robert Meek wrote:
> I had tried mixing the virtual key code and GetkeyState together as
> you show but of course it didn't work until I saw your example and added
> the
> rest of the evaluation: "and $80)>0".  That did the trick, unfortunately I
> don't know exactly what it is you are doing here.

GetKeyState returns a Byte. As the documentation states, if the high-order
bit is set, then it means the key you asked about is currently down, the
"and $80" masks out all the other bits. If the one remaining bit is set,
then the result will be non-zero.

> It seems like you are
> checking to see if the F1 Key is down, but if so then why is "if
> (key=VK_F1)" even necessary? Wouldn't it be redundant as this is in the
> OnKeyDown event?

Uh, because the OnKeyDown method gets called for *all* the keys. You only
want to do the test for one key, F1. Otherwise, you'll be checking for
*any* key being pressed while the Shift key is down.


-- 
Rob


_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to