LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Discard All panels function ?

Leaving a thread, I want to discard all panels displayed in the thread.
Is there any function, which does it?
Or must I always keep track of all panels displayed?
--
Best regards
Lars P. Magnussen
Magnatek aps
0 Kudos
Message 1 of 7
(3,720 Views)
Hello,
No, there is no existing function that does that. The best way would be to store all the panel handles in an array as you create them, and delete them all.

Mika Fukuchi
Application Engineer
National Instruments
Message 2 of 7
(3,720 Views)
If the panels are setup as parent/children, DiscardPanel on the parent also discards all child panels.
0 Kudos
Message 3 of 7
(3,720 Views)
Yes, disposing of a parent panel will also dispose of its child panel(s). Otherwise Mika is right you will probably have to dispose of each individual panel before exiting the thread.

Regards,
Azucena
0 Kudos
Message 4 of 7
(3,720 Views)

Sorry for replying to a very old thread.  But I stumbled upon a novel way of handling loading and unloading of many non-child panels for an application that must work on a multi-monitor installation.

 

I have an application whose panels must all load on one or the other monitor.  I've made the monitor "home" selectable in-applicaiton. However, ATTR_DEFAULT_MONITOR changes only work before LoadPanel.  Hence, the need to execute DiscardPanel and then LoadPanel for each global panel handle.  Yuck!

 

I love the array idea.  So for my implementation, I created a define for MAX_PANELS equal to 50 and an array of this size.


Next, I utilze the UIR header macros for each panel, knowing that a 0 is by definition not a valid panel handle number.  Then, I'm able to simply use for loops to both load and discard panels quickly:

 

	// fist discard all the panel handles
	for (int i=0; i<MAX_PANELS; i++)
	{
		DiscardPanel(panels[i]);
		
		// reinit array too
		memset(panels, 0, MAX_PANELS);
	}
	
	// re-init the default monitor
	SetSystemAttribute(ATTR_DEFAULT_MONITOR,systemConfig.monitor);
	
	// now reinitialize all panels
	for (int i=0; i<MAX_PANELS; i++)
		uiChk(panels[i] = LoadPanel(0, "Panels.uir", i));
0 Kudos
Message 5 of 7
(3,214 Views)

Just a little note for what is probably just a typo: you must put memset () out of the loop, otherwise all panel past the first will not be discarded Smiley Wink

Additionally, you could have a global int array which you can fill in at program start with the pane IDs of the only panels you want to always load and iterate on the elements of that array to load/unload them. This way you can handle panels that do not need to be always loaded in mmory but still are present in the .UIR file.



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 7
(3,210 Views)

Oops, yes big mistake there.

 

And yes, good suggestion on the panels that are drawing in the UIR but are not loaded/needed.  Those would present a situation where a simple loop would crash.

0 Kudos
Message 7 of 7
(3,207 Views)