Strange Behaviour on Window Close
david.crowe
I have a panel with multiple sliders that, when used, issue a command to control a Xenon lamp. The widget should be spawned & closed from a button press on another GUI (via Execute "panelName()"), however, when closing this widget with the standard Windows X button every SliderControl's function is called. This is very strange and unwanted behavior. No where in my code do I have any hook on a Windows exit so I wonder if this has happened before? And Is there a way to disable the native Windows option menu or catch the termination to abort these function calls?
Here's a sample SliderControl function to set the lamp intensity:
Function solarSimIntensitySliderProc(sa) : SliderControl
STRUCT WMSliderAction &sa
NVAR instr = $GLOBAL_PATH + ":ShutterController:SC_solarSim_instr"
String cmd = ""
Variable curVal
switch ( sa.eventCode )
default:
if ( sa.eventCode & 1)
curVal = sa.curval
sprintf cmd, "P=%04g\r", (curVal * 10)
HW_SendVISACommand(instr, cmd)
endif
break
endswitch
return 0
End
STRUCT WMSliderAction &sa
NVAR instr = $GLOBAL_PATH + ":ShutterController:SC_solarSim_instr"
String cmd = ""
Variable curVal
switch ( sa.eventCode )
default:
if ( sa.eventCode & 1)
curVal = sa.curval
sprintf cmd, "P=%04g\r", (curVal * 10)
HW_SendVISACommand(instr, cmd)
endif
break
endswitch
return 0
End
Any insight would be greatly appreciated.
try
if ( (sa.eventCode > 0) && (sa.eventCode & 1))
Each control gets a "control about to be killed" event which is sa.eventCode == -1. That will pass your if statement.
May 6, 2019 at 09:01 am - Permalink
In reply to try if ( (sa.eventCode > 0… by JimProuty
Ah I see. Thanks Jim, everything's perfectly peachy now.
May 6, 2019 at 12:29 pm - Permalink