LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

User changeable controls

Hello all,

I wonder what can be the best strategy to do the following: I want to have a panel that groups a bunch of numerical controls, and I want to give the users the ability to configure them to their taste: position, size, font size, style of control, etc... The only way to do this I can think of is to respond to an even, like a right clic, and pop up a special panel with all the options I want to allow. I foresee plenty of difficulties in the details (like placing the label...)

 

Can someone suggest a different way ? In some demos there are sometimes customization popups (for instance for graphs or traces), is there one for numerics ?

0 Kudos
Message 1 of 14
(4,451 Views)

As per positioning controls on the panel you can try exploring the "moveable controls" instrument driver: it's located in ...\toolslib\custctrl folder and there is also an example that demonstrates its features. After movine the controls you may save their position in some ini file and restore them at program startup.

I'm not aware of any way to operate on other attributes Smiley Sad



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 14
(4,451 Views)

Thank you, that's a good start, although I see some missing functionalities: you cannot resize a tank for instance, or resize the numeric of a tank or numeric slide.

 

In the past on a similar system, we simply gave the user access to the source code so they could change the .uir to their liking, telling them to be... cautious... Obviously it's an understatement to say that this is a risky method ! Anyway that's no longer possible since with the current licensing schemes we don't install the IDE everywhere !

0 Kudos
Message 3 of 14
(4,445 Views)

I'm trying to use movectrl.fp as you suggested. It works fine when dealing with controls inside a normal panel (ignore my previous comment, it's simply touchy as to where the sizable borders are), but it simply doesn't work when the panel is part of a tab. No effect.

 

GetMovableCtrlAttribute doesn't return any attribute (it doesn't change the pointed value), and error –45 "The control type passed was not a valid type". My controls are simply numerics or text strings.

Actually calling MakeMovableCtrl(PanelInTab, -1, "Mannaggia a voi", 1, 1, 1, 1) returns -45... What gives ?

EDIT: it works if I put the sample program in a tab... I'm looking into it... Must be some wrong handle somewhere.

0 Kudos
Message 4 of 14
(4,423 Views)

I have the problem when I use a config name in MakeMovableCtrl, whether the config already exist or not. I see the file custctrl.ini contains the proper config which I saved with SaveMovableCtrlSettings. I get error -90 if I try to use LoadMovableCtrlSettings. MakeMovableCtrl works fine using "". This is weird and I wonder if this is another share drive problem.

 

0 Kudos
Message 5 of 14
(4,409 Views)

I have tested the sample program in a Win7 machine with CVI 2009SP1 and had no problems in saving/loading different configurations from disk. I have no experience on Linux so I can help you in this matter, but since the instrument is distributed at source code level you can throughly debug it and see where the error arises.

To debug the instrument you must execute Instrument >> Edit menu function and then select the movable control instrument and press  "Attach and edit source" button; repeat it for Custom control support instrument and you'll have the source code files loaded into the IDE. Having this done, you can place breakpoints and execute the code line-by-line to see where the problem arises and which paths are used to access data.

 

(BTW the instrument leaves several blocks of memory and locks left as indicated by the resource tracking utility so it may need some revision from NI to fix it).



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 6 of 14
(4,390 Views)

I have found the bug but not completely worked around yet. It's the sscanf (geometryString...) on line 1235 of movectrl.c. It doesn't test if the line is absent in the ini file, and will leave garbage (uninit) values in the dimensions.

 

It's not a linux bug, I have it on Windows. It triggers if you save a config, then run it again with new controls on your interface. The 2nd time fails to find a dimension.

 

I added the following and it now mostly works:

    if (geometryString[0]=='\0') goto Error;


0 Kudos
Message 7 of 14
(4,382 Views)

I see: I have not tested with new controls on the panel.

You can also test for error in the preceding instruction: if the line does not exist Ini_GetStringIntoBuffer returns 0.

After that you can test for text, just in case there is an emplty string (it should not since the file is created programmatically, but who knows).



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 8 of 14
(4,379 Views)

I tried using SaveMovableCtrlSettings and Make MovableCtrl on only some controls of a panel and the reading doesn't match the saving.

Let me explain. I skip  the 1st 7 controls and save them all afterwards. The first relevant data in custctrl.ini is:

Control7 Control Autocenter = False
Control7 Control Centerable = True
Control7 Control ID = 8
Control7 Control Movable = True
Control7 Control Pos = "210 -696 15 121"
Control7 Control Sizable = False
Control7 Enabled = True

 Then when I restart the prog and want to position my 1st control (still skipping the first 7), I call MakeMovableCtrl(Panel, Ctrl, Label, 1, 0, 0, 0) but in the ReadPartSettings function, the value of itemName is "Control1 Control Pos", which doesn't exist. Hence the call fails and the control is not positioned back to where it was.

 

There's something wrong here, maybe in my understanding of how ReadPartSettings is supposed to work on individual controls. When called with -1, like in the example, all is fine.

0 Kudos
Message 9 of 14
(4,374 Views)

Now that the position/size of the controls are taken care of, I'd like to offer a choice of control style. But the problem is that the SetCtrlAttribute doesn't let you set ATTR_CTRL_STYLE. This is annoying since in the IDE you can simply press F11 on a control and have the option of compatible styles.

 

I could discard the control and call NewCtrl, but then I'd lose every setting: current value, min/max, etc. So I have no choice but to copy every important attribute into the new control.

 

Any alternative ?

0 Kudos
Message 10 of 14
(4,370 Views)