Determine keys pressed while clicking

Hello,

In my application I need to figure out which modifier keys (ALT, CTRL 
and SHIFT) are held when the user clicks somewhere.

I can easily figure out about the Shift and Ctrl key, since they're sent 
in the nFlags parameter of OnLButtonDown through MK_SHIFT and 
MK_CONTROL. But apparently MK_ALT isn't part of that, for some reason. 
Previously, I tried to grab the keystate with the GetKeyState function, 
except during beta testing it turned out it doesn't always work for 
everyone (I never had any problems myself, but some others did).

Is there another way to find out which keys are held by the user?

Thanks in advance,

-- 
Maarten Kools
___________________________________________
Van Gennep - Media Automation Consulting bv
Burg. Stramanweg 105
1101 AA Amsterdam
The Netherlands

Phone:  +31-20-697 6029
Fax:    +31-20-697 2249
E-mail: mkools@vangennep.nl
WWW:    http://www.vangennep.nl
WWW:    http://www.vangennep.com
___________________________________________
0
mkools (57)
7/27/2004 9:22:26 AM
vc.mfc 33608 articles. 0 followers. Follow

1 Replies
459 Views

Similar Articles

[PageSpeed] 30

Use GetAsyncKeyState. That should tell you the key state at the current instant.
				joe

On Tue, 27 Jul 2004 11:22:26 +0200, "M. Kools" <mkools@vangennep.nl> wrote:

>Hello,
>
>In my application I need to figure out which modifier keys (ALT, CTRL 
>and SHIFT) are held when the user clicks somewhere.
>
>I can easily figure out about the Shift and Ctrl key, since they're sent 
>in the nFlags parameter of OnLButtonDown through MK_SHIFT and 
>MK_CONTROL. But apparently MK_ALT isn't part of that, for some reason. 
>Previously, I tried to grab the keystate with the GetKeyState function, 
>except during beta testing it turned out it doesn't always work for 
>everyone (I never had any problems myself, but some others did).
>
>Is there another way to find out which keys are held by the user?
>
>Thanks in advance,

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
7/27/2004 3:20:58 PM
Reply:

Similar Artilces:

determine mail flow problem!!!!!!!!
Help! :-( Our mailflow from 2 backend 2003 exchange servers keeps queuing up in the outbound queue (which is set to always run delivery). Messages stay in there from 10 to 120 minutes before being sent to our gateway MTA and then sent off site (to hotmail.com for example). However when I telnet from a backend server to the gateway over port 25 and send a test message it goes right away. I can't for the life of me figure out why. One example when viewed in message tracking history says: 10:16am - smtp: store driver, message submitted from store 10:16am - smtp: message submitted to ...

Registry Key for Preffered server?
Hi All I am going through some series of upgrades which will force me to move the mail server between few machines. I want to avoid having the users change their proffered mail server every time I make a change. Can someone tell me where to find the Registry Key which handles the Exchange Server for the Outlook Client? -- Amnon Feiner http://www.woodcontour.com Solid Wood & Stone PC Peripherals. Found the answer to my own question, thank you -- Amnon Feiner http://www.woodcontour.com Solid Wood & Stone PC Peripherals. "A. Feiner" <none@none.com> wrote in mes...

Determine columns used
I have 100+ spreadsheets which i have to edit into a certain format. The spreadsheets currently have 100 columns (from 1-100). From there i have to reduce the number of columns set to 8 columns. E.g: 1 2 3 4 5 6 7 8 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 (from column 9 onwards, it goes to the 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 next rows' column 1) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 How do i do that without altering the order of the value of the cell? Let me make sure we understand the question. You have ...

Invalid Product Key on Outlook 2K, Win2003
When trying to install Outlook 2000 on a Windows Server 2003, I get the error "This is an invalid CD Key value. Please check the number located on your CD Key sticker." I *KNOW* the key is correct, because I have installed this copy of Outlook 2000 on NT4 server and Windows 2000 server. Why won't it work on Windows Server 2003? Thanks in advance for your help. -- ================================= Larry Wahlers, Systems Specialist Office of Information Systems The Lutheran Church--Missouri Synod Is Outlook 2000 compatible with Server 2003? I don't think so, but I coul...

Dynamically determining when a month ends
Hello all, Ok, I have a simple excel spreadsheet, where I keep track of my spending on one tab, my income in another and my summary in a thrid. My problem happens when I try to dynamically calc. avg's for months in the summary page. For instance, if I want to see how much money I spent on average per month, or even per day, I draw from the data entered into the spending page. Now, the spending page is set up with the following columns: Date:: Description:: Amount The problem with this is that I can't predefine a max row # for each month, since I might have 80 entries in spending...

how to determine the size of the sheet
Hi I had a collegue who told me once a way to dtermine the number of the rows in a sheet of the workbook I am working at. It is known that when you open a new workbook each sheet has maybe 65365 or something like that rows. MY QUESTION IS: HOW TO MAKE THE SHEET 1000 ROWS OR WHATEVER NUMBERS OF ROWS I ONLY NEED? Thanks in Advance, Ahmed Hi Ahmed The number of rows and columns are fixed. Your workaround would be to hide the ones you consider unneeded. HTH. Best wishes Harald "Ahmed SHEBL" <ahmad.shebl@hotmail.com> skrev i melding news:%231uFO3IcHHA.4720@TK2MSFTNGP0...

How do I determine
I have X number of rows that show employee names and a column (A2) that lists the value of products sold by each employee and I want to pay them a percentage based upon value of sales. For example: If they sell up to =A31,000 worth of products, I will pay them 3% of the value. Between =A31,000 & =A32,000, I will pay them 5% of the value Over =A32,000, I will pay them 10% of the value The amount paid to them in commission will be show in column (A3). Many thanks D.Haste darren.haste@ttt.co.uk "Hastey" <darrenhaste@sky.com> wrote in message news:6a0a4fa9-adcd-484a-80...

I clicked HTTP server what does incoming mail mean?
what do i type in incoming mail for HTTP server? "Diana" <Diana@discussions.microsoft.com> wrote in message news:2D52686D-B5D6-4C49-899F-6D3D5C2079B9@microsoft.com... > what do i type in incoming mail for HTTP server? Do you mean SMTP server? If so ask your Internet Service Provider. the server url - it only works for hotmail, msn and Exchange OWA addresses. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Need Help with Common Tasks? http://www.outlook-tips.net/beginner/ ...

How do you determine if you have access to remote files
I'm trying to scan a list of servers for a specific file (say for example \\<servername>\C$\MyApp\Test.ini\which may exist on some servers but not on others. In addition, I may not have have access to all servers that I'm checking. When using any commands in Powershell (1.0) that attempt to get the file (such as Get-Item) PowerShell returns the same "Cannot find path '<filename>' because it does not exist.)" error message in the following two scenarions: 1. I have access to the remote filesystem and the file does not exist (expected beha...

How to receive a MSOffice Home & Student Trial Key
My new laptop came with MS Office Home & Student 2007 pre-installed and I cannot take advantage of the 60 day free trial without a trial key. I have clicked on the icon on the desktop and the space where the trial key is supposed to be is blank. I have contacted my computer company and Microsoft and both continue to send me to the activation website. The only problem is that the activation website does not have any place to sign up or into and is basically blank other than the title of "Receive your activation key for the trial MS Office Home & Student 2007. An...

Why does the "/" key act like the alt key
I'm using excel 2007 and when I use the "/" it acts like the alt keys. Is there a way to turn this feature off? hi when used alone, it is the "help" key. when other characters are used first, it's just a slash. to change it or disable..... office button>excel options>advance scroll to the bottom. uncheck any transition setting. if there is a small box with a / in it, delete the /. should have heading of MS Menu or Help key. (i don't have 2007 yet. still doing reseach.) post back with your actions so i can add to my library. regards FS...

Determining A Rating
Hello, Suppose I have the following table: A B C 1 3 <3.80 2 3- 3.80 3.99 3 4+ 4.00 4.19 4 4 4.20 4.79 5 4- 4.80 4.99 6 5+ 5.00 5.19 7 5 5.20 5.79 8 5- 5.80 5.99 9 6+ 6.00 6.19 10 6 6.20 6.79 11 6- 6.80 6.99 12 7 7.50 7.99 13 8 8.50 8.99 14 15 4.91 16 4- Where A is a rating/score B is the low value range C is the high value range If I have a value in A15 of 4.91 (which is in the range of 4.80 and 4.99), I would like to return a rating in A16 of 4-. I've tried using a series of IF statements, ...

ListCtrl header right click
I want to bring up a context menu when the user clicks on the grey headers across the top of the columns in my CListCtrl class. What event do I have to use to catch a right click on a CListCtrl's header. I have tried OnNcRButtonDown in the list control, but it isn't hit, so something else must be catching the right click event. If I have to subclass the header control and catch the click in my specialised class, then how do I use my own class rather than the CListCtrl's normal class as it's creation is automatic? Thanks for any tips. "GT" <ContactGT_rem...

Change License Key
Helllo, I´ve the following problem: On my server runs MS CRM 3.0 with a trail license key. The license has expired now. But I cant change the license because I´ve 21 users in the system, but only 20 licenses... How can I solve this problem? greetings, Stefan disabling a user will remove a user license. "Stefan" <Stefan@discussions.microsoft.com> wrote in message news:4500CF02-65FD-46F8-B3B0-7A80A5B89005@microsoft.com... > Helllo, > > I�ve the following problem: > On my server runs MS CRM 3.0 with a trail license key. > The license has expired now...

Contacts are missing when I click To, CC, or BCC buttons
My Outlook worked fine until I switched computers. My contacts are in Outlook and when I start to type the address, my choices come up. But when I click To, CC, or Bcc, it's blank. "Pyrate63" <Pyrate63@discussions.microsoft.com> wrote in message news:704AD8A0-D531-41ED-9FD8-9273F90E4F2D@microsoft.com... > My Outlook worked fine until I switched computers. My contacts are in > Outlook > and when I start to type the address, my choices come up. But when I > click > To, CC, or Bcc, it's blank. Version of Outlook? How did you transfer y...

How do I determine the size of an excel worksheet?
How do I determine the size of an individual worksheet in an Office Excel 2003 file? The Properties featue only tells me the size of the whole file. Hi not directly supported by Excel. One workaround: Export this sheet to a separate workbook (with only this sheet) and measure its size -- Regards Frank Kabel Frankfurt, Germany "rajivsahib" <rajivsahib@discussions.microsoft.com> schrieb im Newsbeitrag news:7031AE58-EB7A-44CD-9AF5-940BD47DAA8B@microsoft.com... > How do I determine the size of an individual worksheet in an Office Excel > 2003 file? The Properties featue o...

Help Outlook disappers when clicking the minimize
When clicking the "-" in the upper right hand of the Outlook program window, the program disappears from the taskbar. An Outlook symbol still appears in the systray. When holding down Ctrl-Alt-Del, Outlook does not show up on the Applications tab, but Outlook still does show up on the processes tab. What gives? Is this a registry problem? Please help me can you? It isn't a problem its expected behaviour "Dave" <anonymous@discussions.microsoft.com> wrote in message news:04d501c3b3a3$661725a0$a401280a@phx.gbl... > When clicking the "-" in the...

ost2pst program--does anyone have a key code?
Thanks! Don't think that you will find that here, but here is a question for you that might help down the road. Do you still have access to an exchange server where you can build a new profile (w/ new ost) file? The reason that I ask is there is a way to fool Outlook into opening an orphaned OST w/out resorting to using a 3rd party program like ost2pst. -- Neo [MVP Outlook] Due to the Swen virus, all e-mails sent to this account will be deleted w/out reading. "xx" <x@x.com> wrote in message news:eovNzU9wDHA.2064@TK2MSFTNGP10.phx.gbl... > Thanks! > > Tha...

Determine if a sheet is protected?
How can I determine if a sheet is protected or not? thank u Try activesheet.protectcontents HTH Bob "Robert Crandal" <nobody@gmail.com> wrote in message news:h865n.9557$Ft3.8620@newsfe04.iad... > How can I determine if a sheet is protected or not? > > thank u > > Sub test() MsgBox ActiveSheet.ProtectionMode 'returns true or false End Sub Gord Dibben MS Excel MVP On Mon, 18 Jan 2010 16:28:18 -0700, "Robert Crandal" <nobody@gmail.com> wrote: >How can I determine if a sheet is protected o...

Problems with clicking on email link on a web page
When I click on an email link on a web page I get this message: "Could not perform this operation because the default mail client is not properly installed." Windows Live Mail is the only email account I have. What should I do? Thank you for your help. It's not interested in Accounts, it is interested in a Mail program installed on your PC. Are you using the Windows Live Mail (WLM) program or the Hotmail website? If in doubt, while reading an e-mail message do a Help (ALT+H). In the menu the pops-up, the last item will say "About Microsoft Windows Liv...

SHIFT / CONTROL Key Held?
How can I interpret whether a ALT, SHIFT or CONTROL key is being pressed? I have a function, and while it is running, I would like to interpret whether Alt, R/L shift or R/L control is being held at a given instant... depending on one of the state of the keyboard, the code branches in different direction? I am trying to implement functionality similar to, i.e., Adobe Illustrator, that when Shift-picking, lines, etc ,are constrained to 45deg angles, or when alt drawing an ELLIPSE, you can draw a perfect circile .. i.e, but if you release the key, the constraint is gone... however, I may only...

Calling a function via Key-stroke (eg Ctrl + S)
I want the user to invoke a function, via keystroke, rather than menu / button. How do I do this? Hi Hamish, override PreTranslateMessage and then: if (pMsg->message == WM_KEYDOWN) { if (pMsg->wParam == VK_F9) //for F9 YourFct(); } Regards Matthias Hi Hamish, override PreTranslateMessage and then: if (pMsg->message == WM_KEYDOWN) { if (pMsg->wParam == VK_F9) //for F9 YourFct(); } Regards Matthias If you want it application-wide, add an acccelerator to the accelerator table in the resource file. "Hamish" <h.dean@xtra.co.nz> wrote in...

Double-click does not open file
Today, out of the blue, Excel has become unable to open files by double-clicking. Clicking on an Excel file gives me the following error message (translated from Swedish): "Could not find the file xxx.xls (or one of its components). Check the file path, the file name and that all necessary DLL files are available." However, from inside Excel the files open correctly. Why is this, and what can I do to remedy it? Try to make a new short cut on Desktop and see if it works... "Hans N�slund" <hans.naslund@spray.se> wrote in message news:%23jm4RpnVDHA.532@TK2MSFTN...

Determining OS?
Is there a method to determine the operating system (98, XP, ME, etc) that a program is running under? Thanks, -- Knute Johnson email s/nospam/knute/ Molon labe... >Is there a method to determine the operating system (98, XP, ME, etc) >that a program is running under? See the GetVersionEx API. Dave -- MVP VC++ FAQ: http://www.mvps.org/vcfaq David Lowndes wrote: >>Is there a method to determine the operating system (98, XP, ME, etc) >>that a program is running under? > > > See the GetVersionEx API. > > Dave Thanks. -- Knute Johnson email s/n...

Other field Determination
Imagine this situation...there are: Owners (tblOwners) Pets (tblPets, child records of tblOwners) Medicines (tblMeds, child records of tblPets) Owners can have multiple pets. Pets have multiple medicines. Easy so far. Here's the tricky part. The Pets can be of different species (cat, dog, bird, snake, etc). Depending on what the species is, I want to determine the other data that needs to be stored for the pet. So instead of just height, weight, age, as fields in the pet table, I want to see number of whiskers, declawed? if its a cat...wingspan, beaklength, feather color if its a bi...