LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

accessing controls in another panel from a callback function

Wow scomack, I think you are on to something...  In debug mode, the values of my panel handles (I have three panels) are -1, 2, and 3 for panel1, panel2, and panel3, respectively.  But it looks as if whenever panel1 is referenced the value is somehow converted to 1... I tried using   (panel1 < 0)   to verify that panel1 is indeed negative, but it wasn't caught.  Strange.  The other two panels load just fine.  So what does "The Interface Manager could not be opened." mean?

-JR

0 Kudos
Message 11 of 17
(1,759 Views)

JR,

Panel 1, when you originally load it, if it is -1, that means that the panel isn't getting loaded.  Perhaps the panel is in a different UIR file?

0 Kudos
Message 12 of 17
(1,755 Views)
If the panel is not getting loaded then should I be able to see it when I compile and run the program?  Because I CAN see it.
 
-JR
0 Kudos
Message 13 of 17
(1,753 Views)

JR,

You souldn't be able to see the panel when you run and compile the program if, on load the panel returns a -1 for a value. Calling DisplayPanel(-1) will return an error, and no panel will be loaded.  Do you display all three panels, Panel1, Panel2, Panel3 and see each individual panel when you run?  If this is so then somewhere after you have called LoadPanel and DisplayPanel with Panel1 that value gets set to -1.   In fact, I think that this is what is happending, because typically the panel numbering goes up from 1, and the values you had for panel2 and panel3 were 2 and 3.  That means somewhere another valid panel was probably loaded (which would be panel1) and then somehwere in the code it got set to -1.   Perhaps a conditional statement with a single = instead of two == is doing this?  You can check for this by setting 'Detect assignments in conditional expressions' under options->build options in the CVI compiler.

0 Kudos
Message 14 of 17
(1,741 Views)

Thanks for all your guys' help!  I've solved my problem... although I am still not quite sure what the problem was.  Here's the rundown...  I had two ways of acquiring user input: 

GetUserEvent(FALSE,&panel1,&ctrl);
switch(ctrl)
...

and the callback functions

It seems as if these two methods were interfering with each other.  I opted to remove the cumbersome switch method and go full-fledged with the callback functions.  A little rewriting and addition of a RunUserInterface() call into main() and presto... no more problems!  Anyone have any ideas of what was going on here?  I know it sounds kinda weird and hard to follow... oh well.  Thanks again for the great support! 😄

-JR

0 Kudos
Message 15 of 17
(1,740 Views)
Ahh, it all becomes clear now...
 
Your problem was the GetUserEvent call that you were using.
 
In GetUserEvent the second parameter, in which you had 'panel1' is passed by reference.  This means that it passes back a value to you (nominally the panel on which the event occurs.)  But if no event occurs, then a -1 is passed back.  Which, is why you were getting a -1 on your 'panel1' variable and sometimes getting back to a 1 on your 'panel' variable.  At some times, no event was occurring which  means a -1 was getting passed back to ctrl and to panel1.   And since panel1 was a global variable, that -1 value was sticking with it even after the GetUserEvent was called.
0 Kudos
Message 16 of 17
(1,729 Views)

Neat, thanks for the clarification Dave!  Hope other people will find this thread useful.  One last thing, how do I remove this topic from appearing at the top of the list on the main page?

-JR

0 Kudos
Message 17 of 17
(1,725 Views)