08-08-2019 11:33 AM
Is it possible to dynamically retrieve the panelhandle, already loaded from a library call, using the name or the uir ID?
I need to change some attribute of panel control and doing that panel handle is mandatory.
Solved! Go to Solution.
08-08-2019 11:50 AM
I am not aware of a function that returns the panel handle when given its ID. But you can put them (panel handles) in a global array as you load them, indexing by their ID and then retrieve back when needed.
Hope that helps
08-08-2019 03:22 PM
I'm brand new to CVI (two weeks, if that) so take this with a grain of salt... What I've been doing is having each panel in it's own .uir file, and then having the corresponding .c file contain a "XXXXInit ()" routine that sets anything needed up, and returns the handle.
Then, in my main.c I can have things like
PanelSomethingInit (); PanelElseInit ();
They return the panel handle, so I can preserve them in main.c if I need to (as well as error check).
Then, each also has a GetHandle function:
somethingHandle = PanelSomethingGetHandle (); elseHandle = PanelElseGetHandle ();
I can obtain that easily anywhere I need it, and it keeps me from polluting variables by using globals everywhere. This also keeps all my UIs modular so I can drop them into any other program I need to, easily.
My coworker solved this earlier with a function that looks them up based on a pass-in define:
int ReturnHandleFunction (int panelID) { switch (panelID) { case PANEL_MAIN: return panelMainHandle; break;
...etc… He can then get any handle he wants by calling "handle = GetHandleFunction (PANEL_SETTINGS);" or whatever.
I really thought there should be a function in CVI that uses the #define created by the UI editor and returns the handle, but I haven't found it (if it exists).
08-09-2019 02:13 AM
The panelHandle I need is out of my scope. The Panel is loaded using a library function and the handle is static in that library so no way to retrieve it through the library exported function.
Only the name of the panel and its ID are in my hands.
08-09-2019 02:15 AM
I really thought there should be a function in CVI that uses the #define created by the UI editor and returns the handle, but I haven't found it (if it exists).
This should be the effective answer... but it isn't....
08-09-2019 07:45 AM
@brug71 ha scritto:
I really thought there should be a function in CVI that uses the #define created by the UI editor and returns the handle, but I haven't found it (if it exists).
This should be the effective answer... but it isn't....
Effectively such a function does not exist at present... and it will never exist, I suppose.
Simply consider that you can have more instances of a panel loaded in memory, each of them identified with its proper handle; as if you wanted to identify an individual car by its model type only: you can't! You need the actual plate number (i.e. the panel handle) to identify a single car among all the others of the same model.
08-09-2019 08:16 AM
@brug71 wrote:
The panelHandle I need is out of my scope. The Panel is loaded using a library function and the handle is static in that library so no way to retrieve it through the library exported function.
Only the name of the panel and its ID are in my hands.
Yeah, the library author should have at least provided a way to get that handle. How do you have the ID? Is it in a library-provided header file? I wonder what the use of that is, if there's nothing you can do with it.
Actually, I'm still new to this … when you say ID, what do you actually mean?
08-09-2019 09:20 AM
@RobertoBozzolo ha scritto:
@brug71 ha scritto:
I really thought there should be a function in CVI that uses the #define created by the UI editor and returns the handle, but I haven't found it (if it exists).
This should be the effective answer... but it isn't....
Effectively such a function does not exist at present... and it will never exist, I suppose.
Simply consider that you can have more instances of a panel loaded in memory, each of them identified with its proper handle; as if you wanted to identify an individual car by its model type only: you can't! You need the actual plate number (i.e. the panel handle) to identify a single car among all the others of the same model.
I agree with you, the plate example is the definitive answer.