I am encountering a situation from which I cannot get out and neither can I find an alternative solution.
My application builds the GUI programmatically from a configuration file.
In particular, there are several objects in the front panel of my main VI that are hidden. On startup, they are "populated" and then placed in the required position. The main GUI objects I use are subpanels, texts and images.
The mechanism I use is based on a class structure. Each type of element in my interface corresponds to a class. I have a base class UIElement from which other classes derive: Text, Picture, Subpanel, etc.
Each of these classes has a Draw method that allows the relative object to draw itself. Through the Draw method, the application moves the control in requested position, set visible = true and insert its content.
What I described above is a simplified version. Actually, the application has other types of GUI elements that are a group of other UIElements.
To simplifiy, each UIElement object corresponds to a front panel control and its reference is a property of the UIElement class itself. When an object needs to be drawn, the application calls the Draw method which uses the related control reference and set position, visibility, value and other properties (via the property nodes).
So, the use of references and therefore programmatic access to the controls is essential for me.
I have a problem with pictures.
There are pictures that the application loads, displays in the front panel and manipulates during execution.
These pictures are placed in .NET PictureBox objects. I don't use 2D picture LabvIEW controls because the quality of the image I get is not acceptable.
When I retrieve the reference of the .NET PictureBox object, type of the reference I get is ActiveXContainer. But from this reference I can't use property and methods of the .NET object it contains. In other words, having to programmatically access the .NET PictureBox object, I need to somehow retrieve the reference of the .NET PictureBox object starting from the reference of the ActiveXContainer.
I cannot directly pass the .NET PictureBox terminal (available in the block diagram) to my classes and methods because retrieving the control references must be done programmatically.
Is there a way?
Thanks in advance
Solved! Go to Solution.
How are you creating the .NET PictureBox in the first place? Is there any way you can use the .NET constructor node which (as far as I can tell) returns the correct reference then store that in your object?
Unfortunately I cannot use the .NET constructor. The only way for me to create the .NET PictureBox is to select it from the LabVIEW palette (in the front panel). See the picture below.
I believe that the constructor is "automatically and hiddenly" called when the VI run.
Sorry, I missed the part where you said the objects already exist on the front panel!
You may find some useful information in this thread, particularly from rolfk who is rather an expert in the details of Windows plumbing.