LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

what is the meaing of the sysmbolic constant value in the header file for UIR file and how they are used

In labwindows after creating the uir then header file is create automatically. There it has define some symbolic constant. As examples of colview.h(from the examples of labwindows )

 

#define  MAINPNL              1       /* callback function: MainPanelCB */

#define  MAINPNL_RESULTS      2     /* control type: table, callback function: ResultTableCB */

#define  MAINPNL_NEWTEST     3       /* control type: command, callback function: NewTestCB */

 

My question is how these values 1, 2 and 3  were selected and how they are used in programs ?

 

If anyone explains, it will be a great help.

0 Kudos
Message 1 of 2
(3,056 Views)

When creating a UIR file, CVI editor takes care of assigning constants to the panels / controls you create in it.

 

The conceptual framework is the following (assuming to treat the file you have reported in your message):

- Within a single UIR file all panels have a unique ID, which is the one you pass to LoadPanel when loading a panel into memory. LoadPanel (0, "myfile.uir", MAINPNL); is then translated to panelHandle = LoadPanel (0, "myfile.uir", 1); , that is: "load the first panel in the uir file". The panel in memory is then assigned a handle, which is guaranted unique by the OS and saved in panelHandle variable

- Addressing a control in a panel is done e.g. using SetCtrlVal (panelHandle, MAINPNL_NEWTEST, xxx);  , which again is translated to SetCtrlVal (panelHandle, 1, 3);  that is: "Set control #3 in the panel identified by panelHandle to value xxx".

 

You must not modify the include file associated to the UIR as it is fully maintained by the IDE and is rewritten each time you save the UIR file.

 

That conceptual framework has some advantages and some caveats:

- You can load the same panel more then once in your program: each instance is independent from the others as each panel handle is unique; in some occasions it may be helpful, e.g. if you need to handle several identical equipments connected to your PC and you can load the same control panel for each unit connected maintaining each of them independent

- If the panel handle is wrong, the system does not warn you of this as it does not know of the symbolic names you are using; if you try that SetCtrlVal command with a wrong handle you are trying to manipulate a control on a panel different from the one you intend: supposing actual panel idientified by the handle has control #3 the maximum you can expect is that you receive an error in case you pass e.g. a string to a numeric, but if controls are of the same type you have no errors or warning at all! This is particularly important when addressing controls on pages of a tab control: each page is really a separate panel with its proper handle that you must retrieve with GetPanelhandleFromTabPage command before addressing the controls on 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 2 of 2
(3,050 Views)