From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Committing all the controls on a panel

Hello all,

how do I commit all the user-settable controls on a panel in a simple way ?

I was thinking of simply iterating through all the controls and using CallCtrlCallback(...EVENT_COMMIT), but then I thought:

- what if there is no callback function ? (probably OK)

- what if the control is hidden ? I'm OK if it's still being called.

- what if it's only an indicator or it's dimmed but still has a callback function ? It shouldn't be called, but will it ?

- anything I forget ?

 

 

0 Kudos
Message 1 of 5
(4,368 Views)

As you surely know, iterating through all controls is quite simple using GetPanelAttribute (..., ATTR_PANEL_FIRST_CTRL, ...); function and iterating until GetCtrlAttribute (..., ..., ATTR_NEXT_CTRL, ...); returns 0.

 

Regarding your questions:

 

- what if there is no callback function ? (probably OK)

The help explicitly states that nothing is done in this case

 

- what if the control is hidden ? I'm OK if it's still being called.

The callback will be called indeed

 

- what if it's only an indicator or it's dimmed but still has a callback function ? It shouldn't be called, but will it ?

The callback will be called

 

- anything I forget ?

What if a control reacts to events different from EVENT_COMMIT? As an example, I often trap EVENT_VAL_CHANGE to customize some panel elements based on use selection (e.g. the user selects an operating mode that does not require to fill all fields on the panel so I dim some of them)

 

Calling CallCtrlCallback actually supersedes what the OS would do in permitting you to operate or not on a control (hidden / dimmed / indicator / ...). It's up to you to decide wether to honour these conditions by querying the appropriate attributes (ATTR_DIMMED, ATTR_CTRL_MODE, ATTR_VISIBLE...)



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 5
(4,364 Views)

Just out of curiosity, what's your intention in commiting all controls on a panel? I can't imagine a situation in which I would be using it but I can simply be using a different programming approach and I'd like to know yours.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 5
(4,361 Views)

Thanks Roberto.

OK, so I'm doing it by iterating through all the controls like you describe, and testing if they are dimmed or only indicators or non-editable (*) and only then calling the callbacks. Seems to work well enough.

 

The reason I want to do that is that I have two panels with lots of retroactions from P1 to P2. Both contain plenty of user settable controls, but each time you change something in P1 it changes several things in P2. Instead of tracking down exactly what and doing a commit on those, I simply want to commit everything on P2 each time.

 

(*) What is this new ATTR_NO_EDIT_TEXT attribute ? It doesn't seem to be available on the controls I've tried, even though TFM says it applies to numerics.

0 Kudos
Message 4 of 5
(4,343 Views)

I see. I have never faced a situation like yours, that's why I didn't fel urged to do this commiting. It should work well and serve your needs.

 

The no-edit-text attribute limits the ability of the user to interact on controls. Used on numerics will prevent the user to type in a new number, while leaving it free to use up/down arrows to modifiy its actual value. I really don't know its utility on a string control, since it prevents not only to type in something but also to paste in some text.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 5
(4,340 Views)