NI Home > Community > NI Discussion Forums

LabWindows/CVI

Showing results for 
Search instead for 
Do you mean 
Reply
Member
Guillaume Dargaud
Posts: 101
0 Kudos

Repeating controls

Hello all,
I'll describe something I do very often in user interfaces but maybe there's
a better way to do it.
Say I have an 'element' that needs various controls: a settable string for
its name, a settable value, a readback value, a small strip chart, etc...

Now I want to have many of those elements, each on its own line, on top of
each others, so what I do is that in my user interface I manually define the
1st line of controls and then I programmatically loop over as many elements
as I want, calling DuplicateCtrl for each, placing them below the previous
ones, storing the control numbers in various struct members, and keeping a
reverse lookup table from the control number to the 'element' number.

It works, even if a little painful to place everything properly.

Another similar way would be to place all the controls of the 1st element on
a child panel without decoration and simply duplicate the child panel many
times. In that case you only need to match panel number and line number,
both ways. This way it may even be possible to write a lib that takes
arbitrary controls for re-use.

Anybody has comments or tricks, maybe using a table (which I've never used)
to achieve the same thing ?
--
Guillaume Dargaud
http://www.gdargaud.net/
Active Participant vix
Active Participant
vix
Posts: 570
0 Kudos

Re: Repeating controls

I haven't tried yet, but probably you can create a "control array" with all the controls you need, then duplicate the control array.

Control array have been introduced in CVI 2010 if I'm right

Vix
-------------------------------------------
In claris non fit interpretatio

-------------------------------------------
Using LV 2013 SP1 on Win 7 64bit
Using LV 8.2.1 on WinXP SP3
Using CVI 2012 SP1 on Win 7 64bit, WinXP and WinXP Embedded
Using CVI 6.0 on Win2k, WinXP and WinXP Embedded
Proven Zealot
RobertoBozzolo
Posts: 5,228
0 Kudos

Rif.: Repeating controls

I have used all these methods and must admit that every one of them has some disadvantage. I like the DuplicateCtrl method as it is fast and relatively simple to handle when I have only a few controls to replicate. In a situation like yours I'd probably go the child panel way, since you have very different controls to accomodate on the screen. Additionally, I can handle all controls with a single array of panel handles, thus obtaining a simpler program structure.

 

The table way is indeed the simplest method but it's limited to the small set of values table cells can have (you cannot embed a graph in cell, for example). Additionally, tha "table-style" aspect the GUI assumes is not the best I can think of when designing the user interface.

 

I'm afraid I have no real trick to offer that you have not already mentioned.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Zone Community
________________________________________
If I have helped you, why not giving me a kudos?
Member
Guillaume Dargaud
Posts: 101
0 Kudos

Re: Repeating controls

> I haven't tried yet, but probably you can create a "control array" with
> all the controls you need, then duplicate the control array.
> Control array have been introduced in CVI 2010 if I'm right

I wasn't aware of control arrays. Reading about it right now. Do all
controls need be of the same style ?

Also, call me slow, but I'd never noticed the custom controls. Are the
predefined custom controls documented somewhere. I couldn't find info in the
F1 help.

Also I just saw a something about the user interface browser. Seems useful,
but where is that ?!? I can't seem to find it in the various menus.

Thanks.
--
Guillaume Dargaud
http://www.gdargaud.net/
Proven Zealot
RobertoBozzolo
Posts: 5,228
0 Kudos

Re: Repeating controls

As far as I can understand, control arrays simply handling of controls at runtime but do not modify the design of the UIR: you will still need to programmatically duplicate controls next you will need to add new controls to the array. It will be a little bit easies to address the controls from this moment on.

Control arrays can hold controls of different type: in this respect they can ease up your life while programming, provided they are well designed and documented.

 

As per the user interface browser, you cannot miss it: it shows to the right of the user interface editor. It consumes lots of space too, and on laptop screens this can be a problem. I have posted an idea for adding a panel preview exactly for this reason, which you may feel free to kudos.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Zone Community
________________________________________
If I have helped you, why not giving me a kudos?
Proven Zealot
RobertoBozzolo
Posts: 5,228
0 Kudos

Re: Repeating controls

[ Edited ]

Custom controls, both the so called "toolslib controls" and DAQmx controls, are documented in the tools library chapter in the online help. There are also sample programs for almost all of them, and some are distributed with the code so that you can understand how they work and personalize them further if you want to.

 

I forgot to mention in my previous post that the user interface browser (as well as control arrays) was introduced with CVI2010: you cannot find it in any previous version of the product.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Zone Community
________________________________________
If I have helped you, why not giving me a kudos?
Member
Guillaume Dargaud
Posts: 101
0 Kudos

Re: Repeating controls


> As per the user interface browser, you cannot miss it: it shows
> to the right of the user interface editor.

Hmmm, never seen it. Is it one of those things that shows up only in
Integrated View ? If so consider it a bug as it's nowhere to be seen in
Classic View (just like the missing Operate Tool events which used to work
fine).
--
Guillaume Dargaud
http://www.gdargaud.net/
Active Participant
LuisG
Posts: 1,978
0 Kudos

Re: Repeating controls

Hi Guillaume,

 

Back in 2003, when CVI changed from a top-level window layout to an integrated window lay-out, it retained the optional use of the top-level windows ("classic view") for those users who had a strong preference for the previous style. The expectation was that, over time, the number of users using classic view would diminish. For a while now this option has been considered a legacy option, and thus it's likely that it will continue having fewer and fewer features, relative to the integrated layout.

 

In this case, the user interface browser and the attribute browser are really features of the workspace window, which kick in when the user interface editor is visible within the workspace window.

 

Out of curiosity, what is the main reason that you prefer using classic view?

 

Luis