LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

UIR Control ID Problems in .UIR and .H files

I have a GUI that has 4 columns by 30 rows of TEXT MESSAGE controls that I populate from within my main program using a FOR loop:

controlID = PNLMAIN_COLUMN1TOP
for (i = 0; i less than 30; i++)
SetCtrlVal(panelHandle, controlID + i, value[i])


I set controlID in the command to the control ID of the first item in the column that I want to populate and the Control ID's increase by one as you move down the column. The '+ i' takes care of moving down the column.

When I first made the GUI, I drew the text message controls in the order I wanted them to get the sequential control ID order. A few times I have had to change some of the properties of the text message controls and when I resave the GUI, LabWindows reassi
gns the control ID's and sometimes the order of the ID is not sequential. When this happens I end up having to redraw the entire GUI and I'm getting tired of doing that. I have tried editing the .H file associated with the .UIR file but no matter what I do the out of order sequence is somehow preserved. If I resave the GUI and look at the .H file, the out of order sequence of the control ID's are there. How can I fix this?

0 Kudos
Message 1 of 5
(3,864 Views)
My personal way of solving this problem is to create an array of control IDs and use it instead of the control index.

That is: at the beginning of the program I create a global array
int ctl[30];

Next I fill the array with control IDs
ctl[0] = PNLMAIN_COLUMN1TOP;
ctl[1] = PNLMAIN_COLUMN2TOP;
and so on...

In the callback, when I have to manipulate the controls, I use the elements of the array instead the the index inside the panel:

for (i = 0; i <= 30; i++)
SetCtrlVal(panelHandle, ctl[i], value[i]);

I found this useful in my applications.



But, last but not least, could your panel be modified to use a (unique) table control instead of several texts? The table control is powerful, can be customized cell by cell (if necessary) and
seems a best approach to organize informations in row-by-column format. It can be filled programmatically in a similar manner as you fill the text boxes.

Hope all this helps
Roberto


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 2 of 5
(3,864 Views)
Hi,

I agree with Roberto here, creating an array of controls at the beginnign of your app is probably the best way to go:

int controls[30] = {PANEL_CTRL1,PANEL_CTRL2, PANEL_CTRL3, ...}


As you know now the numbers associated with the control's names are going to change when you edit the UIR.

Another aproach that you can use here is to create the controls programmatically, this way you have a reference to each control rigth there is your code.

Hope that helps.

Juan Carlos
N.I.
0 Kudos
Message 3 of 5
(3,864 Views)
Thanks for the responses. I never thought of making an array using the control names. That will make like easier if and when I make more changes to the GUI.
Thanks
0 Kudos
Message 4 of 5
(3,864 Views)
Hi.

You could try this:
In the UIR editor, select the panel which holds the controls you wish
to modify, then press Ctrl-T. In the resulting "Edit Tabbing Order"
window, you click on the controls in the order you require, and CVI
will re-assign the control ID's. Note that the #define's in the header
file will be offset by two from the numbers you see in this window.

Regards,
Colin.
0 Kudos
Message 5 of 5
(3,864 Views)