Question

I have a server that receives simultaneous client connections. I have mostly used the MultiClientServer sample provided by NI as a model to implement a server that uses multi-threading. I have up to 4 clients connecting, with each client sending information about its internal variables. My goal is to display this data in separate tabs depending of which client sent it. I have an array that holds the handle for each tab element,

static int ClientTABHandle[4] = {0,0,0,0};  

When client connect and report their ID's, the ID is used to refer to the right ClientTABHandle when calling SetCtrlVal. For example,

SetCtrlVal(boardTABHandle[clientInfoPtr->clientID],<control name>, <value>);

The values in <> are symblic.

Now, this lets me use the right TAB handle at runtime depending on which client I am dealing with, but I can't find a way to refer to dynamically. Since UI controls are in separate tabs, each control would have a prefix of its TAB name. For example, if the TABs are called TABPANEL1, TABPANEL2, TABPANEL3 and TABPANEL 4, then a UI element on the first TAB would be referred to as TABPANEL1_CONTROLNAME. But how can I make a string at runtime that refers to a control and use that in the SetCtrlVal command? I do not like using Fmt as it will slow things down and plus, I dont know of a way to use a string that would evaluate to a control name.

Was it helpful?

Solution

Your question how can I make a string at runtime that refers to a control and use that in the SetCtrlVal command?:
If your approach will allow you to programmatically create the controls for which you later need to SetCtrlVal, or SetCtrlAttribute, then the answer may be to experiment with the NewCtrl(,,,) function. It will allow you to create controls on the tab panels, and it will return a unique handle (ControlID) for each control it creates. All of the information is in the link, but here is its prototype:

int NewCtrl (int Panel_Handle, int Control_Style, char Control_Label[], int control_Top, int Control_Left);

Example code using NewCtrl is found here:
C:\Program Files (x86)\National Instruments\CVIxxxx\samples\userint\buildui.cws
C:\Program Files (x86)\National Instruments\CVIxxxx\samples\userint\ICOViewer.cws

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top