LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Panel Handle retrieve using its constant name or id

Solved!
Go to solution

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.

0 Kudos
Message 1 of 8
(2,751 Views)

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 

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 8
(2,742 Views)

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).

 

 

0 Kudos
Message 3 of 8
(2,700 Views)

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.

0 Kudos
Message 4 of 8
(2,683 Views)

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....

0 Kudos
Message 5 of 8
(2,679 Views)
Solution
Accepted by topic author brug71

@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.



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 6 of 8
(2,670 Views)

@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?

0 Kudos
Message 7 of 8
(2,662 Views)

@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.

0 Kudos
Message 8 of 8
(2,654 Views)