I'm using CVI to test circuit boards so some of my ideas are probably crude from a software standpoint. However I've had good success doing the following.
Make a global variable for your panel. You are going to use it a lot so make it short. I use pan.
int pan; //going to be our panel handle
Then you load the panel by:
pan = LoadPanel (0, "path", PANEL);
path = .uir location like c:\cvi\myproject\main.uir
and PANEL is the name of the panel you want to load when you refer to the panel handle we have called pan. wow,okay.
So now go use the panel.
DisplayPanel(pan); //Displays PANEL
What if you want to display another panel? Well do the same thing with a new handle and say DisplayPanel(new handle name);
Try this with pan1 and pan2 as our two valid panel handles.
DisplayPanel(pan1);//Want to look at pan1
HidePanel(pan1); //hide pan1 and
DisplayPanel(pan2); //display pan2
then at the end of the code, which for me is beneath the RunUserInterface() function in the main function you just have
DiscardPanel(pan1);
DiscardPanel(pan2);
to clean up any used resources. The basics then is don't use DiscardPanel() until you are done which for me is at the end of the program.
I like to have a background that is just a solid blue panel that I load so it looks pretty. Then I overly the panel I want the user to use over that. What stinks is when the user clicks outside the panel I want them to use and the blue comes out front. I solved this by doing the following:
Create a global int called ActivePanel.
int ActivePanel=0;
okay, then every time I display a panel besides the background I do the following:
DispalyPanel(background); //Show the Big blue panel
DisplayPanel(pan1);//Show panel I want the user to use
ActivePanel=GetActivePanel(); //Save this panel # to variable ActivePanel.
Then I have a panel callback function on my background panel that responds to the case:
EVENT_GOT_FOCUS
So whenever my background panel gets focus I call this code:
switch(event)
{
case EVENT_GOT_FOCUS:
DisplayPanel(ActivePanel); //Display the panel number ActivePanel
break;
}
I'm sure there are things I'm forgetting but I hope this helps anyway. I can help you with basic questions so email me anytime you want.
Grant
I included a project with some sample code to check out.
Grant M. Johnson
Project Engineer
LECO Corporation