Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

How are hot keys implemented in Measurement Studio?

Some measurement studio controls include a keyboard mode that can be set to KeyboardNone or KeyboardHandled. This implies to me that hot keys are allowable for the control. I have not read any documentation describing what the hot keys are or how to associate them with a control. What does the keyboard mode do? (In Microsoft MFC an ampersand (&) in front of a character in the control label specifies the hot key for that control.) Some measurement studio controls include message handlers for key presses, but of course they are only active when the control has focus. The message handlers operate independently of the keyboard mode. Of course a keypress message handler at the application level that decodes the key and takes the appropriate action is the work around for the problem(old school). How are hot keys implemented for Measurement Studio controls?
0 Kudos
Message 1 of 4
(3,612 Views)
Measurement Studio controls follow the same rules as other controls in VC++ 6.0. That is, if you use the ampersand (&) in front of the desired hot key in the control’s caption, you will have yourself a hot key.

For example, changing a push button’s caption from "Run Test" to "Run &Test" will have "T" be the hot key for the push button.

Regards,

Eric
0 Kudos
Message 2 of 4
(3,586 Views)
Eric,

That is how I would like the control to work. It does not work that way for me. I tried a little experiment. I used Visual Studio 6 and the NI Measurement Studio AppWizard to create a dialog box. It contains three buttons. 1 & 2) The default windows OK and Cancel button. ( I used the & notation in front of the K to create a hot key for the OK button.) 3) A CNiButton labeled Run Test. Using your example, the & was placed in front of the T. Executing the project from this point the hot key T or t does not work, but K or k does actuate the OK button. Then I created a CNiButton control variable using the Class Wizard called m_RunStop. I placed the following line in the OnInitDialog member function (m_RunStop.KeyboardMode = CNiButton::KeyboardHandled;) Executing the project from this point the hot key T or t does not work, but K or k does actuate the OK button. The attached zip file contains the whole project(you will have to build it). You can also recreate the experiment from scratch in a couple of minutes.

What does the KeyboardMode actually do??

Playing with this app also brings up another problem. When the NI button has focus, the OK hot key message does not get handled. (ie. it does not work). It would seem that each NI control will have to implement its message handler to pass the keypress on to the apps thread.

Thanks,

Kiel
0 Kudos
Message 3 of 4
(3,581 Views)
Kiel,

I made a mistake in my previous post. You are right. The ampersand will NOT work to create a hot key for a CNiButton. Sorry for the erroneous info. The Measurement Studio controls do not really have support for hot keys. In other words, the “old school” workaround you mentioned may be your best bet. That is, you could use a KeyPress message handler for each control that passes the pressed key and takes the appropriate action.

Also, if you set the KeyboardMode Property of a CNiButton to KeyboardHandled, then pressing the spacebar when the button is active will have the same effect as clicking on the button with the mouse.

One last note, the behavior of the K in the OK button is a feature of the windows native push button and not of the Measurement Studio controls.

Regards,

Eric
0 Kudos
Message 4 of 4
(3,567 Views)