How do you monitor keyboard input for a modal dialog box?

I wish to have a modal dialog without any visable buttons, and the only way to continue is to press the special key combination on the keyboard.

Is this possible?
If so, how would I do this?  
Do I use the OnKeyDown/OnKeyUp functions or what?

Thanks in advance.
TrainManAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mikeblasCommented:
No.  The dialog manager eats all input messages and routes them to controls. You need to install a keyboard hook.

See the documentation for SetWindowsHookEx().

If you want a sample, just ask. But please tell me what specific key combination you want to use so I can make sure to show how to decode the virtual key codes.

..B ekiM
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TrainManAuthor Commented:
If you're willing to provide a sample I'm not going to be stupid and say no.

The key combination is ALT F10.  I've already defined this as a virt key in my resource.

Thanks in advance.
0
mikeblasCommented:
No need for a translator resource.

Please see the TENHOOK.ZIP sample at http://www.nwlink.com/~mikeblas/samples/ . Please note that my samples (well, my whole webpage, actually) will someday move to http://www.mooseboy.com/ .

..B ekiM
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

TrainManAuthor Commented:
Thanks for the sample code.  I took a quick look at it, but I might have a couple questions later.  So if you don't mind, I'll respond through this thread.
0
TrainManAuthor Commented:
I have a SDI application without a Document.  The dialog I wish to use your code in is called AbortDlg.

Do I need to have your code global to the app, in which case it would be located in MainFrm.cpp I guess, or in the AbortDlg.cpp file?

I ask this because with it in my AbortDlg.cpp file, everytime the program gets to "if (nCode == HC_ACTION)" there is an Assertion Error!  :(

This could be operator error on my part too.  The SetWindowsHookEx code is in the CAbortDlg::OnInitDialog().

Please advise, thanks in advance.
0
mikeblasCommented:
An if statement can't possibly generate an assertion error.

 > have your code

Which part of "my code" are you referring to?

..B ekiM
0
TrainManAuthor Commented:
I realize fully that there is nothing wrong with your code, it is the way that I'm installing it that has a problem.  That's why the question.

I have a SDI application without a Document.  The dialog I wish to use your code in is called CAbortDlg.

Do I need to have your code global to the app, in which case it would be located in MainFrm.cpp I guess, or in the AbortDlg.cpp file?
0
gpbaldazziCommented:
I needed something like what I found in your TENHOOK.ZIP and I'm going to use it.
Just a question: is there any particolar reason for using your IsKeyDown() inside the MyKeyboardHook to retreive what key is being pressed? Could I parse wParam and lParam?
Thanks
Gian Paolo
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.