AutoPositionWindow problem

Hi,

I have written a procedure to bring up a new image window for drawing a ROI and a panel with controls based on the wavemeterics Image ROI.ipf. In the code I use AutoPositionWindow to place the panel underneath the new image using AutoPositionWindow. When I put break points in the code and follow through step-by-step the panel positions fine, however, when I remove the break points the panel is placed on top of the new image. Does anyone have any suggestions?

Here is the code if it helps, the two functions are executed one after the other from a button action procedure:

Function GIXS_newImageForROI()
    Wave currentImage = $GIXS_getQpanelImageWave()
   
    Display/N=Temp_ROI_plot as "Draw ROI";AppendImage currentImage
    DoWindow/F Temp_ROI_plot
    ModifyGraph width={perUnit,400,bottom},height={perUnit,400,left}
    SetAxis left -0.3,0.5
    SetAxis bottom -0.7,0.7
    ModifyImage ''#0 ctab= {25,*,Rainbow,1},log=1,minRGB=(0,0,52224),maxRGB=0
End

Function GIXS_createROIpanel()

    DoWindow/F Beamstop_ROI
    if( V_Flag==1 )
        return 0
    endif
   
    String igName = GIXSTopImageGraph()
   
    NewPanel /K=2 /W=(563,327,744,514) as "Beamstop ROI"
    DoWindow/C Beamstop_ROI    
    AutoPositionWindow/M=1/R=$igName
    ModifyPanel fixedSize=1

// panel controls


I think it might have something to do with the delay in generating the initial image, so I even tried using sprintf to write a command then use Execute at the end of the procedure but that didn't work either.
Try adding a DoUpdate somewhere to force display of the plot window. In a slightly modified version of your code fragment, adding DoUpdate at the end of GIXS_newImageForROI() causes AutoPositionWindow to work as expected.