Killing floating panels
pokeeffe
Running aTest(0) from the sample code below produces a progress window which closes upon reaching 100% or upon the Abort button being clicked. If you run aTest(1) instead to make the panel a floating one, the progress window remains even though the abort is handled correctly. (At least on my machine running Igor 6.2.2.2/WinXP)
How would I kill the panel if I used /FLT=2 instead?
Function aTest( float)
Variable float
string pname = NewTestProgressWindow( float )
Variable i,imax= 1000
for(i=0;i<=imax;i+=1)
Variable t0= ticks
do
while( ticks < (t0+1) )
UpdateTestProgressWindow( pname, i, imax)
endfor
DoWindow/K $pname
End
Function/S NewTestProgressWindow( float )
variable float
string myname = UniqueName("progwin", 9, 0)
If (float)
NewPanel/K=1/N=$myname/FLT=1/W=(629,345,929,442) as "Please wait..."
else
NewPanel/K=1/N=$myname/W=(629,345,929,442) as "Please wait..."
endif
ValDisplay vdProgress,pos={5,5},size={290,20},limits={0,1,0},barmisc={0,0},mode= 3,value= _NUM:0
TitleBox titleProgress,pos={5,30},size={54,13},frame=0,title="0/0 complete"
Button btnAbort,pos={245,26},size={50,20},help={"Click to end procedure execution"},title="Abort"
SetActiveSubwindow _endfloat_
DoUpdate/W=$myname/E=1
return myname
End
Function UpdateTestProgressWindow( name, val1, val2 )
string name // name of progress window to affect
variable val1, val2 // status values
DoWindow $name
If ( !V_flag )
return -1
endif
ValDisplay vdProgress,win=$name,value=_NUM: (val1/val2)
TitleBox titleProgress,win=$name,title= num2istr(val1)+"/"+num2istr(val2)+" complete"
DoUpdate/W=$name/E=1
If ( V_flag == 2 )
DoWindow/K $name
Abort
endif
If ( val1/val2 >= 1 )
DoWindow/K $name
endif
return 0
End
Variable float
string pname = NewTestProgressWindow( float )
Variable i,imax= 1000
for(i=0;i<=imax;i+=1)
Variable t0= ticks
do
while( ticks < (t0+1) )
UpdateTestProgressWindow( pname, i, imax)
endfor
DoWindow/K $pname
End
Function/S NewTestProgressWindow( float )
variable float
string myname = UniqueName("progwin", 9, 0)
If (float)
NewPanel/K=1/N=$myname/FLT=1/W=(629,345,929,442) as "Please wait..."
else
NewPanel/K=1/N=$myname/W=(629,345,929,442) as "Please wait..."
endif
ValDisplay vdProgress,pos={5,5},size={290,20},limits={0,1,0},barmisc={0,0},mode= 3,value= _NUM:0
TitleBox titleProgress,pos={5,30},size={54,13},frame=0,title="0/0 complete"
Button btnAbort,pos={245,26},size={50,20},help={"Click to end procedure execution"},title="Abort"
SetActiveSubwindow _endfloat_
DoUpdate/W=$myname/E=1
return myname
End
Function UpdateTestProgressWindow( name, val1, val2 )
string name // name of progress window to affect
variable val1, val2 // status values
DoWindow $name
If ( !V_flag )
return -1
endif
ValDisplay vdProgress,win=$name,value=_NUM: (val1/val2)
TitleBox titleProgress,win=$name,title= num2istr(val1)+"/"+num2istr(val2)+" complete"
DoUpdate/W=$name/E=1
If ( V_flag == 2 )
DoWindow/K $name
Abort
endif
If ( val1/val2 >= 1 )
DoWindow/K $name
endif
return 0
End
October 31, 2011 at 02:06 pm - Permalink
October 31, 2011 at 03:09 pm - Permalink