LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Return values in panel callbacks

Hello all,

can someone refresh my memory...?

I have written some code where the EVENT_PANEL_SIZE of some panel callbacks sometimes returns 0 and sometimes 1. I can't find a reference on what the return values do mean. The panels whose callbacks return 1 seem to only contain a tab (which contains child panels). Why did I do it this way ?

 

I'm asking because one of those panels is misbehaving in some circumstances, refusing to change size and it's driving me crazy.

Thanks.

0 Kudos
Message 1 of 9
(5,252 Views)

Hi Guillaume,

 

Returning 1 causes the event to be swallowed.

If there are chained callbacks they do not get executed and Windows does not get notified of the event.

 

The latter causes default behaviour of some controls to stop for that event.

For example, if you swallow a left click event on a listbox, your callback runs OK, but the clicked item does not get highlighted.

(or at least that's what I remember from my own experience of the concept)

 

Hope this helps,

S. Eren BALCI
IMESTEK
0 Kudos
Message 2 of 9
(5,238 Views)

Yes, I sometimes swallow keyboard events on controls. But for panels, is it only about chained callbacks or is there any other possibility ?

0 Kudos
Message 3 of 9
(5,130 Views)

Hi gdargaud,

 

Callback functions for UI events in CVI only ever return 1 or 0, depending on whether or not the event has been swallowed.  The KB Article linked below has more information.  However, you should note that the 

EVENT_PANEL_SIZE event is not a swallowable event, so it should not be causing the callback function to return 1.

 

What Does the Return Value of a LabWindows/CVI Callback Function Do?: http://digital.ni.com/public.nsf/allkb/C0BCE16EF2D1968586257442005CB285

EVENT_PANEL_SIZE: http://zone.ni.com/reference/en-XX/help/370051V-01/cvi/uiref/cvieventpanelsize/

 

Myriam

0 Kudos
Message 4 of 9
(5,090 Views)

Yes, and that's the way I understand it. That's why I'm suprised by some panel callbacks size events that take great care to return 1 in some (complex) sets of circumstances. I wonder if there isn't more to it than the official documentation. What of child panels ? Panels in tabs ?

0 Kudos
Message 5 of 9
(5,079 Views)

Hi gdargaud,

 

Would you be able to post the code for your callback here?  It would make it easier for us to see what's going on, and maybe someone will be able to offer some guidance.

 

Thanks,

 

Myriam

0 Kudos
Message 6 of 9
(5,058 Views)

Maybe you did not know size event cannot be swallowed at that time.

 

And after you found out that it is so, maybe you were reluctant to remove that complex logic from you code, just in case you may need to rewrite it at some later time.

 

That explains why the code is still there, but does not explain why you observe unintended behaviour.

 

Is it a consistent problem or an intermittent one?

S. Eren BALCI
IMESTEK
0 Kudos
Message 7 of 9
(5,046 Views)

Well, I was tracking down a strange behavior of a panel that refuses to accept the size set by an init sequence. It opens with a minimal size of a few pixels. There are 20 other panels in that same app and it happens only on this one, and only on Linux. It's a program that's been in development (and production) for 7 years so it's big. As I was tracking it down I noticed two things:

- those 'return 1' in some panel size callbacks including this one, with some elaborate conditionals (I'll see if I can simplify later)

- setting a breakoint on it I noticed that the callback is first called with the proper HxW values, and then with improper values. This call happens from the cvi library (in other words from draw panel events while cvi has time on its hands)

What makes me think that this is a bug in the CVI runtime is that if I place the DisplayPanel before the last SetPanelSize, the problem goes away (and that's my workaround for now).

0 Kudos
Message 8 of 9
(5,028 Views)

Hi gdargaud,

 

Since your application is quite large, and you've looked into this issue quite a bit, would you be able to recreate the issue in a smaller piece of code.  This would make it easier to help you troubleshoot the issue.  Also, which version of LabWindows/CVI are you using?

 

Thanks,

 

Myriam

0 Kudos
Message 9 of 9
(5,000 Views)