LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I un-highlight a numerical control entry?

In LabWindows/CVI 6.0, when I enter a number into a numerical control, and hit Enter, the control responds by showing the entry in reversed video. No problem there; I'm guessing this is just normal control behavior. However, I would like to find some command - perhaps a attribute that could be changed - that would allow me to programmatically change the control's displayed number back to normal, unhighlighted (non-reverse-video) text.

Does anyone have a suggestion for how I can do this? There is an ATTR_HILITE_CURRENT_ITEM SetCtrlAttribute command, but it can't be used on numerical controls. -GA
0 Kudos
Message 1 of 3
(3,004 Views)
Hi Garth,

You can use the SetActiveCtrl (panel, control); function to change the focus from the NumEdit control to another control. The only drawback I see is that you need to know in advance which control will get the focus after the user presses enter in the NumEdit control.
This is the callback I used for the NumEdit control:

int CVICALLBACK numedit (int panel,int control,int event,void *callbackData,int eventData1,int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
SetActiveCtrl (panel, SOME_OTHER_CONTROL);
break;
}
return 0;
}

Note that when the user presses enter on the NumEdit control (and the value has changed), an EVENT_COMMIT gets generated.

Regards,
Azucena
NI
Message 2 of 3
(3,004 Views)
I think the highlite here is expected behavior. The highlite occurs upon the numeric control receiving focus. I have looked through the attribute settings in SetCtrlAttribute, as well as functions specifically for controls, and see nothing that can change this behavior.
I see two workarounds for this situation. The first is to set focus to a different control immdiately upon an EVENT_COMMIT to the control. This will unhighlite the numeric control, BUT YOU WILL ALSO lose focus on the control. This may or may not be a problem, depending on the situation of your application. The other wokraround is a bit of a longshot I thought up. You could make a textbox that acts like a numeric control. This would be a little more complicated, but it is possible, and
this would be able to keep the focus. You have to do typecasting conversions from doubles or whatever to character strings and back again. This could be done with Scan and Fmt functions. Then you could place command buttons for the up and down arrows. If you decide to take this path, and would like assistance, please drop a line back. Thanks for using the Discussion Forum for Measurement Studio, and have a great day.

Daniel McChane
Application Engineer
National Instruments.
0 Kudos
Message 3 of 3
(3,004 Views)