LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

child panels as custom controls

I would like to know a way to use child panels, or some other method, as a custom control. By custom control I mean a black box that will have inputs and outputs and perform some functions. I would like to be able to use multiple copies of this child panel on the same parent panel, with the only change being a different constant name for each instance of the child panel. This is where I am having a problem. I cannot find a way to link buttons with the same names, and same callback function name, on the child panels to callback functions that are restricted to that copy of the child panel. The only way I have found so far is to query the "int panel" parameter of the callback function and put different coding in there depending on th
e child panel name. Is there another way, either via child panels or some other type of custom control? Thanks.
0 Kudos
Message 1 of 4
(3,185 Views)
Phil,

First there is one thing to clarify; when you copy objects in the UI editor CVI automatically changes the constant name, but keeps the same callback name. You can't have repeated constant names, but you can have multiple controls with the same callback. The method that you are currently using is fine, however you can get into trouble when increasing the number of custom controls.

One possible way of doing this more eficiently is to generate the child panels with the controls programmatically. You can even use the same method that we used for the tab control: have the user place a picture control where he wants the custom control, then provide a function to convert a picture control into your custom control. I'm attaching a small example on how to d
o that, I'm just using the callback defined for the picture control, but you can add parameters to the ConvertPicToChild() to send pointers to your callbacks or send an array to get the controls constants or the panel handles.

I hope this helps, let me know if you have further questions.

Regards,

Juan Carlos
N.I.
0 Kudos
Message 2 of 4
(3,184 Views)
Thank you for this feedback. I think this way of programmatically developing controls will be useful in my application. I am currently looking into using an array to get the control's constants as part of the callback so that I can reference the callback programmatically to its button's source panel without writing additional callback code for every copy of the panel. I will let you know if I have any more questions. Thanks.
0 Kudos
Message 3 of 4
(3,185 Views)
I'm glad is working, it is definatelly a good idea to create arrays for the control constants and for the callback pointers.

Good luck!

Juan Carlos
0 Kudos
Message 4 of 4
(3,185 Views)