LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Obtaining a panel reference from a CtrL

I am creating multiple ctrls on a panel.  when the panel is full it opens another panel and populates the ctrls.  this is being handled using multithreading.  The thread updates a numeric timer.  when a 2nd panel is created the ctrl is created but is not being updated.  my thread is receiving a ctrl reference, not a panel reference.  does a function exist that can determine what panel a ctrl is on?  or how can I send multiple parameters to the thread?  currently only the numeric control reference is being sent.

 

0 Kudos
Message 1 of 6
(3,409 Views)

It is not possible to get the panel handle from a control ID (what I suppose you are intending as "control reference"): the control ID is simply an index among all controls in a panel, but it uniquely identifies an object only when paired with a panel handle. If you consider that a panel could be loaded multiple times in memory and the control ID does not change among all instances you can understand that this element alone is meaningless. What you can do is install the panel handle as callbackData to each control that is created, provided you are not already using that parameter in your application.

It is not easy to comment the other questions you are asking without knowing how you are handling your particular application.



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?
Message 2 of 6
(3,147 Views)

The example I am using is the cvi onepanel.cws example under multithreading.  I modified the code to fill the screen with 12 instances of the numeric timer, when the GUI is full a new panel is opened and displayed on a 2nd monitor.  The thread function receives the ctrl ID but the panel is hard encoded.  The timers update on the first panel but not the 2nd.   I was trying to derive the panel ID from the ctrl ID but I guess that is not possible.  I solved the issue but it is not ideal.  I created a different thread function for the 2nd panel with the panel ID hard encoded.  To simplify the code I could test the threadID to see if it is >12 and use panel2 to update the timer.  

0 Kudos
Message 3 of 6
(3,127 Views)

The don't hard-encode the panel ID in your timer callbacks, just use the panel ID provided as a function parameter by the callback function.

0 Kudos
Message 4 of 6
(2,558 Views)

A quick-and-dirty alternative: pass (panel handle * 100 + control ID) as FunctionData to the thread function 😉

(Not so elegant, I know. But as they say: the simpler, the better)



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?
Message 5 of 6
(2,535 Views)

I save all the ctrls into an array and pass the array location to the function.  It works just fine.  Thanks for all of your suggestions!

0 Kudos
Message 6 of 6
(2,528 Views)