09-01-2020 04:08 PM
Is there a quick way to get the full name of a control from the UIR editor in CVI?
Here is an example;
I make a text box on a tab control in the UIR editor and I name it "tbDesc".
Now I jump back in the code (not the callback) and want to reference it somewhere else.
I have to go in to mainmodule.h and search for "tbDesc" to look up the full name.
Which is: "TAB_INFO_tbDesc".
Is there a way to get the full "TAB_INFO_tbDesc" name quicker without searching the header?
Thanks!
Joe
Solved! Go to Solution.
09-02-2020 03:49 AM
Just out of curiosity: why are you interested in the control name since you cannot use it to programmatically address the control?
In any case you can call GetCtrlAttribute with ATTR_CONSTANT_NAME attribute for each control you want to get the name of. ATTR_CONSTANT_NAME_LENGTH is the attribute you can use to dynamically allocate a buffer where to store the name if you need to.
09-02-2020 11:58 AM
HI Roberto,
Thank you so much for the quick reply;
I am doing a bad job explaining what I am trying to do, so I apologize.
Let me try again.
First let me say that this is more of a logistics question than a programming issue.
Let's say I have a main panel named "PANEL" and a 2 tabbed Tab control named "mainTab"
On the main panel I have a textbox control and the tab control.
On tab 1 I have a textbox control and on tab 2 I have a textbox control.
from the UIR editor they are named:
tbMain
tbTab1
tbTab2
In the header file they are named:
PANEL_tbMain
TABPANEL_tbTab1
TABPANEL_2_tbTab2
This makes sense, because they get associated with the panel they were created on.
Now in order for me to add text to the textbox on tab 2 I would need to write:
GetPanelHandleFromTabPage (panelHandle, PANEL_mainTab, 1, &tabPanelHandle);
SetCtrlVal(tabPanelHandle, TABPANEL_2_tbTab2, "Hello World!");
In other words, simply writing SetCtrlVal(tabPanelHandle, tbTab2, "Hello World!"); wont work obviously, because the control was defined as "TABPANEL_2_tbTab2"
So the only way I know how to obtain the full name for use in programming is by going to the header that is generated by the UIR editor.
This is not really a big deal, it really only takes a second to do this.
Is there a faster way to get the full name from the UIR editor, so after I create the control name I can simply paste it in to the code without looking around the header to find the fully qualified name?
I hope this makes better sense.
Thanks!
Joe
09-03-2020 03:52 AM
That's why I asked you the reason for asking. The problem here is that your TABPANEL_2_tbTab2 is not a string, it's a macro that in preprocessing evaluates to an integer!
SetCtrlVal actually does know nothing about the controls and their names: the function operates on the n-th control on the panel (and that's why you can receive the "control is not the type expected by the function" error if you state a wrong control ID). At runtime the command is translated in something like SetCtrlVal (1, 2, "Hello World!"); (supposing 1 is the panel handle and 2 is the value associated to the macro in the include file).
And so I'm asking again: why can't you simply use TABPANEL_2_tbTab2 macro?
09-03-2020 01:08 PM
I do use the TABPANEL_2_tbTab2 macro to talk to the control, that is not what I was asking.
What I am trying to ask (and doing a bad job of) is can you get that #define macro somehow other than looking in the header.h file?
I also understand that the controls are numbers that are defined by the UIR editor when they are created and that they are #defined names for easier readability, etc...
For example, lets say you are in the UIR editor.
You know how on the right side of the UIR editor you have a tree view that starts with "Source Code Connection"?
[-] Source Code Connection
| |_____ Constant Name tbTab2
| ______Callback Function
What I would like is if you could right click on the Constant Name box (tbTab2) and get a mouse menu option for "Copy full control name to clipboard".
(Obviously only if the header file already had it #defined)
Or right click on the control itself on the UIR editor and select "Go to Definition" or "Copy #define name to clipboard"
(Obviously only if the header file already had it #defined)
In other words is there any other way to get the #define name of a control (especially while in the UIR editor) without searching through the header.h file which can have 1000's of controls in it?
By the way, thank you Roberto for answering 100's of questions on these forms which I have found very useful!
Thanks,
Joe
09-04-2020 03:23 AM
Ok, now I understand your issue but unfortunately I don't know a way to solve it. I myself build up the full control ID with panel and control names when I need to use them.
The only way I have to ease up the process is to use meaningful names for those elements, so I would use for example SETTPNL_SETV instead of TABPANEL_NUMERIC1 for a control where to input a voltage setting on a settings panel. And if possible I would use a similar name for the variable where to store this element in order to have a visual feedback that I'm using the right variable on the right control: e.g. SetCtrlVal (panelHandle, SETTPNL_SETV, setV); . This is not always possible but when it is it helps me a lot.