Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Undocumented INKEY() return values

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB

Would like to know the INKEY() or LASTKEY() return values for:-

Shift + Left Mouse
Ctrl + Left Mouse

TIA

Chris
 
Chris,
It doesn't appear that the shift or control keys modify the mouse click value (151). Try running this little program (I did in FPW 2.6, VFP 5/6/7).

xx = 0
do while xx != 27 && esc to quit
xx = inkey(0, "M")
?xx
enddo

Rick
 
Rick

Thanks for your response and code - I had already tried something virtually identical and still returned 151 regardless of key/mouse combinations.

I find it hard to understand why such combinations always return 151.

Chris
 
Hi, Chris!

It is easy, however to check during mouse click if Ctrl or Alt keys pressed. Use API function for that, for example, use GetKeyState with key name to check if special key is pressed.



Vlad Grynchyshyn
vgryn@softserve.lviv.ua
The professional level of programmer could be determined by level of stupidity of his/her bugs
 
Hi Chris,

Originally I wasnt going to post a response to this thread because it appeared Rick had cleared the confusion; however, after reading it, a little curiousity seed in my brain began to sprout and thus spurned this post.

I'm curious as to WHY you are attempting to trap this key combination. So Chris, could you enlighten us on what you are trying to achieve?

As Vlad eluded to, here's an example of how you could provide the functionality you seek:

Code:
#DEFINE VK_SHIFT 0x10

DECLARE INTEGER GetKeyState IN WIN32API INTEGER

IF INKEY(0,'M') = 151 AND (GetKeyState(vk_Shift)<0)
  Messagebox('User pressed Shift+Left Mouse',0,'Wazzzup!')
endif
Jon Hawkins
jonscott8@yahoo.com

The World Is Headed For Mutiny,
When All We Want Is Unity. - Creed
 
OT:LOL:Wazzzup!

Sometimes i think you two (Jon and Vlad) know way too much.
Does having all that info in your brains hurt? Does knowledge leak out your ears at night or when you sneeze? I can barely fathom being that smart. ;-) I'm just kidding of coarse but between you two and FoxDev it seems you know all. I'm in a jolly mood today and your Wazzzup! messagebox forced me to write this post.

I apologise for cluttering the forum.
-Pete
 
Vlad, Jon, Pete

Thanks for your responses

Have not been able to log on, (outages in California?) hence late reply, but had already resolved problem. I forget that INKEY() does not detect a mouseclick by default, so a combination with a key is hardly likely to return a value.

Jon

The project involves extending the functionality of a grid to emulate Windows Explorer by allowing the user to select records by leftmouse, ctrl+leftmouse and shift+leftmouse.

The following code is from the .click event of an object and so does not require the INKEY() function.

#DEFINE VK_lSHIFT 0x10
#DEFINE VK_lCONTROL 0x11

DECLARE INTEGER GetKeyState IN WIN32API INTEGER

DO CASE
CASE GetKeyState(VK_lSHIFT) < 0
[tab]* Code
CASE GetKeyState(VK_lCONTROL) < 0
[tab]* Code
OTHE
[tab]* Code
ENDC

Chris :cool:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top