LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically retrieve all panels

Solved!
Go to solution

Is there some way to dynamically retrieve all panels that are in an application or at least all the panels per .uir?

 

Thanks

0 Kudos
Message 1 of 3
(2,127 Views)
Solution
Accepted by atomic928

You can retrieve all panels that are in a .UIR file with a simple trick. If you look into the include file associated to an .UIR file you will see that panels are listed inside it. Pnale constant names are in effect macros that evaluates on progressive numbers inside the include file, starting from 1 on. That is, when you call LoadPanel (..., "myUIR.UIR", PANEL); you are really telling CVI to load panel #x from the .UIR file, where x is the value PANEL macro evaluates to.

 

Given this, loading all panels in a .UIR can be done with a simple loop like this one that prints the constant name of all panels in a file:

 

	index = 0;
	while (TRUE) {
		handle = LoadPanel (0, "myfile.uir", ++index);
		if (UIEInvalidIDinResourceFile == handle) break;		// End of panels
		if (handle < 0) {
			// Error checking
			break;
		}
		GetPanelAttribute (handle, ATTR_CONSTANT_NAME, msg);
		DebugPrintf ("Panel %d: %s\n", index, msg);
		DiscardPanel (handle);
	}

 

You could also experiment with ATTR_NEX_PANEL panel attribute, but that one is aimed to enumerating child panels and in my attempts it not correctly working with top level panels (even though the help says it should).

 



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

Worked like a champ. Your the man. Thanks

0 Kudos
Message 3 of 3
(2,065 Views)