LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

create new panel

Hello. I have created 3 panels for my .uir file and for some reason, when I created the fourth panel, the header file displayed it as having the number 2 instead of 4. This creates a problem when I try running my code. I don't want to go through and change all my panelHandles. Any suggestions?

Thanks,
Jason
0 Kudos
Message 1 of 6
(2,869 Views)
The constants assigned to panels in the .h file for the UIR file should have no impact on your code. These automatic changes should be completely transparent to you.
In your code, you should refer to the panels using the constant names, not the literal numeric constants, in the LoadPanel() calls. In any subsequent function call that needs a panel handle, e.g. GetCtrlVal(), you should use the value returned by LoadPanel(), not the constant from the .h file.
0 Kudos
Message 2 of 6
(2,869 Views)
Thanks for the fast response. I do not use the numeric constants though. I always use the constant names shown in the header file, but for some reason, when I added this new panel I get the following error. When it comes to a SetCtrlVal line, the run-time error "control does not have value appears". If I remove the panel from my .uir, the code works fine. I'm not sure what the problem is. Any more suggestions?

Thanks again,
Jason
0 Kudos
Message 3 of 6
(2,869 Views)
What do you mean by "I always use the constant names"?
Use the panel constant names only in the LoadPanel() function calls. In any SetCtrlVal, use the panel handle, not the constant name of the panel. The control ID should be a constant, and it should take the form PANEL_CONTROL. For example, if the panel constant is MYPANEL and you have an LED with a constant seen in the UI Editor as MYLED, the control ID for SetCtrlVal would be MYPANEL_MYLED.
If you want a more educated guess, can you post your code?
0 Kudos
Message 4 of 6
(2,869 Views)
To further clarify:
If you have a panel with a constant MYPANEL and an LED with a constant MYLED:
...
panelHandle = LoadPanel (0, "MyUI.uir", MYPANEL);
...
// turn LED off
// note that the first argument is panelHandle, not MYPANEL
// and the second agrument is MYPANEL_MYLED, not just MYLED
SetCtrlVal(panelHandle, MYPANEL_MYLED, 0);
...
In this manner, you do not need to change any of your code due to any automatic changes to the .h file for the UIR.
0 Kudos
Message 5 of 6
(2,869 Views)
I figured out what I was doing wrong. Sorry for the confusion. I was writing "PANEL_DATA" instead of "panelHandle2". I just got lucky before because they both had the same integer value. Thanks for you help.

Jason
0 Kudos
Message 6 of 6
(2,869 Views)