LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

loading panels

Hi,
 
I was wondering if someone can help me with my problem. Basically i have a uir....on that uir i hv callback button when pressed should load a panel that is saved under a different name from main uir.....so the first time it wrks fine.....it loads the other panel.....now on that panel i hv put a close button, and in the callback i jus say discardpanel(panelhandle).....it closes and my main window is displayed...i can make changes to that and then when i press the button to for that other panel again....it crashes i get error code -4 that is Panel, pop-up, menu bar, or plot ID is invalid.
 
I would appreciate if someone can help me out....
 
thanks
 
k1_ke
0 Kudos
Message 1 of 10
(4,989 Views)

Hello,

does the error occur when the LoadPanel function is executed?

0 Kudos
Message 2 of 10
(4,979 Views)
A panel can be loaded and discarded several times: there must be some incoherence in the source code when loading and displaying the new panel.
Can you post the code for "Other panel" button?


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 3 of 10
(4,977 Views)

Hi,

Thanks Roberto and Wim for replying back. Roberto here is the code. i have put this in a separate .c file

int CVICALLBACK EdgesCallback (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 switch (event)
 {
  case EVENT_COMMIT:
   edge_handle = LoadPanel (edge_handle, "edges.uir", EDGE);
   RecallPanelState (edge_handle, "edges.uir",1);     //loads the previous saved panel by user
   DisplayPanel (edge_handle);
 }
 return 0;
}

int CVICALLBACK CloseCallback (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{

 switch (event)
 {
  case EVENT_COMMIT:
   DiscardPanel (edge_handle); 
   break;
 }
 return 0;
}

I dont know why but i have been loading different panels n wrks fine but all the tiem the code has been in the same main.c file....this time i hv it in another file..the first time it wrks fine....bt then after closing it, if i click on the button again i get the error msg.......it crashes at LoadPanel because the error handle is -4.

I guess its something simple but hard to see. hope you can solve it for me.

Thanks

k1_ke

0 Kudos
Message 4 of 10
(4,970 Views)
I think your problem is that you are using the same .uir file from which you load the panel, as a panel state file. When you call the SavePanelState function, the resulting file is not a .uir file. It is a different format, in which only the control values are preserved. (There is no suggested extension. You can name it what you like). What is happening is that by overwriting the .uir file whenever you save the panel state, the next time you try to load a panel from the original .uir file, you won't be able to.

Try saving the panel state in a different file, and see if the problem goes away.

Luis
NI
0 Kudos
Message 5 of 10
(4,965 Views)

Hi, thanks for the reply. Sorry for having the RecallpanelState....i was just trying it. I didnt hv it before and still crashed even having it there no luck.....

Do you think i can call a uir file which is in another .c file....and i used a button that is on my main uir (main.c)... e.g main.uir has the button.....the callback is in a file edge.c......and the panel i want to load then is edge.uir.....

I will try saving it to a different panel name and get back to you.

thanks

k1_ke

0 Kudos
Message 6 of 10
(4,961 Views)
You can load a panel from any .uir. The .c file doesn't matter. And it also doesn't matter which .c file the callback functions are in, as long as they're in the same EXE or DLL from which you call LoadPanel.

Keep in mind that the problem with the .uir file was not the RecallPanelState function, per se. It was probably the SavePanelState function that you presumably also had somewhere else in your code.

Luis

0 Kudos
Message 7 of 10
(4,950 Views)

Hi,

I think , your problem is in call LoadPanel with invalid parent panel handle

1 state :run EdgesCallback ()
    edge_handle = LoadPanel (edge_handle, "edges.uir", EDGE);//edge_handle is replace by new panel

2 state :run CloseCallback ()
   DiscardPanel (edge_handle);  //edge_handle is now invalid

3 state :run EdgesCallback ()
    edge_handle = LoadPanel (edge_handle, "edges.uir", EDGE); //invalid edge_handle is used a s parent

ovrabek/CZ

Message Edited by ovrabek/CZ on 03-24-2006 08:18 AM

0 Kudos
Message 8 of 10
(4,944 Views)

Hi k1_ke,

I think there is another way to solve your problem, at least is how i do it when working with more than one panel, and it doesn't fail. First in the main function you load all the panels, but only display the main panel or the first you want to appear, then when you want to change from a panel to other you do:

int CVICALLBACK EdgesCallback (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
 switch (event)
 {
  case EVENT_COMMIT:
   HidePanel (main_panel);          //Hides/closes the main panel
   DisplayPanel (edge_handle);   //Shows/opens the edge panel
 }
 return 0;
}

int CVICALLBACK CloseCallback (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{

 switch (event)
 {
  case EVENT_COMMIT:
   HidePanel (edge_panel);          //Hides/closes the edge panel
   DisplayPanel (main_handle);   //Shows/opens the main panel
   break;
 }
 return 0;
}

Finally before exiting the application you discard all the panels you have loaded in the beginning, so really you are working with all the panels loaded, but you only show the ones you want to show Smiley Wink

Hope it helps you

Juan

0 Kudos
Message 9 of 10
(4,931 Views)

HI Guys,

Thank you very much for replying. I was able to solve my problem wiht Juan's suggestion....now i load the panels in the start and show or hide according to what i want...wrks fine.

ovrabek/CZ - yeah i knew that was my problem...jus wanted to figure a way around it but Juan was able to help me out. thanks for ur help

Luis G -  thank you for ur input also....yeah well see the first the it wasnt workign so i was tryin to save the panel....change the state index and load the new index.....but that wasnt doing the trick for some reason...mayb i had to change the file name too....but i hv used savepanel state in my previous project n wrks fine...bt the same method didnt here.

In the end i was able to solve the problem.

Thanks

k1_ke

0 Kudos
Message 10 of 10
(4,915 Views)