11-06-2012 02:58 PM
I am trying to dynamically load the background image of an XControl facade using a 'LoadBackgroundImage.vi' that I have written. This SubVI has worked with a normal VIs panel before. It utilizes the 'Read PNG File.vi' from Labview to read in a transparent PNG file to overwrite the Facade background. When the XControl is loaded during design-time it generates an Error 1004 indicating that the 'Read PNG File.vi' is not in memory. I have tried to place a static reference to this vi to force it to load but I still get this error. What is the solution?
11-06-2012 03:05 PM
Wrong VI server class. Use VI Server.VI.FacadeVI
11-06-2012 04:53 PM
I took out the SubVI to clarify the issue with the Facade.vi inside the XControl (see attachment). I get the same error which seems to be related to the 'Read PNG.vi' not being in memory.
11-07-2012 08:57 PM
Hi Philibuster
I did a little research about that error and I found this link
The article says that "This error occurs most frequently at the Open VI Reference function when the VI name is specified incorrectly". If your are using serveral VIs references and subVIs this might be the reason why you are getting the error.
Regards
Esteban R.
11-08-2012 10:08 AM
Esteban, thanks for the information. I don't think that this article applies directly to my situation - take a look at the Facade.vi shown earlier. The central part of the code will work in a 'normal' SubVI but not in an XControl's Facade.vi. Apparently, when the XControl is loaded during the design mode the Facade doesn't have access to the system's Read PNG File.vi (it's not loaded into memory yet). The question is: How can the Read PNG File.vi be loaded and run while in design mode and then used to fill the Facade's background image? Or is there another way to dynamically load the background PNG image into the XControl's Facade.vi?
11-08-2012 12:48 PM
I do not use XControls extensively, but I do not think your problem has anything to do with the Read PNG File.vi. The Pane of the XControl facade VI is simply not rendered when you place it onto the FP. Try skipping the whole picture placement and simply change the color to see what I mean. I leave the ugly grey background on all of my facade VIs and when I drop the XControl it shows the current FP background, not that of the facade VI.
You could use a picture indicator on the facade VI to fake it, but this can have some performance issues if the controls overlap. Plus you have to handle the stretching yourself. If it were me, I would probably try using a SubPanel to achieve this effect.
11-08-2012 01:28 PM
Darin, thanks for your reply.
The XControl Facade is rendered on the Main FP when the Main.vi is opened in design mode. Previously I have placed a PNG image onto the Facade pane (i.e. drag-n-drop the image onto the Facade FP during design) and it is displayed on the Main.vi FP in design mode when Main is loaded. However, when I include a call to Read PNG File.vi in the Facade I get the 1004 error. You may not see this error without using a Simple Error Dialog. This failure to find Read PNG File.vi in memory is the main issue.
I have tried to use SubPanels before - they are useless for my purposes for many reasons (they don't show the underlying SubVI pane in design mode, they require the use of SubVI references to load - preventing the use of direct wiring to the SubVI connector, etc.).
Do you know how to dynamically load and call 'Read PNG File.vi' so that Labview is forced to load the VI and then Read PNG File can load the PNG image? I can get 'Read PNG File.vi' to dynamically load and show property values but to call it with the 'Call By Reference Node Function' I need a strict type def to be generated, etc. So what are the steps needed to create a dynamic call to 'Read PNG File.vi'? I haven't seen any good working examples that show how to create the strict typedefs that are required etc. There is no right-click > Make Type Def > ... for Read PNG File.vi or other ways to do this that I have noticed. Showing a finished example doesn't show you how to do it (menu selections, etc.). Or, do I have to hand construct these typedefs by reverse engineering the VI?
11-08-2012 01:46 PM
@Philibuster wrote:
Darin, thanks for your reply.
The XControl Facade is rendered on the Main FP when the Main.vi is opened in design mode. Previously I have placed a PNG image onto the Facade pane (i.e. drag-n-drop the image onto the Facade FP during design) and it is displayed on the Main.vi FP in design mode when Main is loaded. However, when I include a call to Read PNG File.vi in the Facade I get the 1004 error. You may not see this error without using a Simple Error Dialog. This failure to find Read PNG File.vi in memory is the main issue.
When you Drag-n-Drop an image to the FP it is placed as a decoration so it will be rendered as part of the XControl facade. Setting the background image is different, it becomes part of the pane, and is only drawn when the pane itself is rendered (which it is not for a facade VI).
11-08-2012 02:15 PM
Darin, thanks for the info. So how does one dynamically load the background image of the Facade similar to what would happen when dynamically loading the background image for a regular SubVI?
11-09-2012 03:59 PM
After finding a way to generate the typedef I was able to eliminate the 1004 error by dynamically loading the 'Read PNG File.vi'. Unfortunately the background image is still not rendered. If anyone has been successful at dynamically loading an image into the facade please let me know how you did it. The image needs to be rendered in the design state so that the XControl can be visually resized on the main panel containing the XControl during design.