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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Key event for Edit Control in VS2005

Status
Not open for further replies.

Khewz

Programmer
Aug 30, 2007
2
FR

Hi all,

I have a stupid problem... It is about the event KEY_UP, KEY_PRESSED, KEY_DOWN and Edit Control.

In VS6, we could add a control of keyboard for all dialog component. we could connect WM_KEYPRESSED event on edit control IDC_EDIT_SAMPLE to a specific function (with, among all, the code of the key pressed as parameter).
Now, I use VS8 and I can't find this management anymore (the famous Ctrl+W doesn't work :'( ). The only events we can connect to 'Edit Control' are event on alignment or text modification.

Can someone tell me how to deal with such management pls ?

Thank you in advance,

Fred
 
I don't really know what Ctrl-W did on VS6: I was a masochist and coded stuff directly. Didn't use MFC or any of the wizard stuff because it rearranged the code in a totally illogical layout. It had no problem putting code in but if the code was to be removed, it took ages. Well, enough about my gripes.

In VS2005 with C# settings, Ctrl-W is always followed by another letter. Click on View and look at the shortcuts. eg Ctrl-W C will bring up the class browser, Ctrl-W S is the same as Ctrl-0 on VS6.

If you want to use the VS6 shortcuts, goto tools/options/keyboard and change it to Visual C++ 6.
 
Thanks xwb !
I will see this when I return to my office.
Anyway, don't you know a way to track keyboard event on a specific dialog control? Here on an EditBox?

Fred
 
Tracking keyboard events is standard: intepreting the key presses is a nightmare. Edit boxes are a bit of a pain since they only handle either everything or numerics but there is nothing for floats.

Once you get into doing your own handling, things get difficult. I find it easier to let the user type what they want and only validate when they either exit the field or hit the OK/submit button.

It may be OK when you only have one edit box but if you have 40 to 50 spread across several dialogs, each with different input requirements, it is easier by the validation routine. Alternatively, you could subclass the editcontrol but make sure you follow the rules so that it is compatible with both SDK and MFC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top