LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Numeric slide does not fire EVENT_VAL_CHANGED as hoped

Hello,
 
I have created a custom control based on a numeric slide.
The main function of this custom control is to color the numeric text background of the numeric slide according to the value (e.g. value gets over 5 digital text background gets yellow and so on).
 
Eveything works fine this far. But as I change the value of the numeric slide by a function like SetCtrlValue or SetCtrlAttribute(...,...,ATTR_CTRL_VAL,...), no event is fired and so my callback isn't called.
 
The function help says:
Description: The EVENT_VAL_CHANGED event is generated continuously while the user is performing an ongoing action which results in the value of a control changing. Examples of these actions are: operating the up/down arrows of a numeric control, a ring control, or a table cell; holding the left mouse button down while selecting different items of a list box control; dragging a graph control cursor.
 
Unfortunatly it seems that the control needs direct user operations to fire the VAL_CHANGED event and won't fire on functions that change the value.
Actually I don't want to chain another timer callback to this control that checks the actual value continously, I'd rather have a real callback that can do that.
Is there a way to have this done?
 
Thanks
MaWie
 
 
0 Kudos
Message 1 of 5
(3,733 Views)

Hello Mawie,

The callback function is indeed only fired when the user is operating the slide directly.

I suggest you use the function CallCtrlCallback after each line in which you change the slide value to fire the callback function yourself:

 SetCtrlVal (pnlHandle, PNL_SLIDE, 100);
 CallCtrlCallback (pnlHandle, PNL_SLIDE, EVENT_VAL_CHANGED, 0, 0, NULL);

0 Kudos
Message 2 of 5
(3,728 Views)

Thanks Wim S,

your solution works fine, thanks.

Unfortunatly I am not the only one who will use this custom control and think that the programmers might forget to add the CallCtrlCallback function after each call of SetCtrlVal.

So if you or anyone else has another solution that helps to keep the usage of my custom control as simple as the use of every other control, I would appreciate.

MaWie

0 Kudos
Message 3 of 5
(3,726 Views)

I'm afraid you will have to create your own SetCtrlVal function for your control. This is not so uncommon for custom controls. If you use the password control, which is also a custom control, the user will have to use the PasswordCtrl_GetAttribute function to get the password entered by the user, instead of just using the GetCtrlVal function:

PasswordCtrl_GetAttribute (pnlHandle, PNL_PASSWORD, ATTR_PASSWORD_VAL, password_str);

You could write your own function (eg. CustomCtrl_SetCtrlVal) to change the value of the custom slide.

Message 4 of 5
(3,723 Views)

Thanks for you help, I think a new function (as in the password control) is a good compromise.

0 Kudos
Message 5 of 5
(3,707 Views)