It's never a good idea to close a window while still "being" in the open event.
What I do:
I have this function in my ancestor w_master window:
// of_closeFromOpenEvent()
// use this function to close any window from the Open() event:
//u2, mjl, 01/12/17: if window is maximized, you can't position outside of screen resolution, so we make it "normal" first:
if this.windowstate <> normal! then
this.windowstate = normal!
end if
this.y = 20000 // see n_display_props.of_saveWinPos(), don't change this 20000 value without changing also the value 20000 in n_display_props!!
this.ib_closing = TRUE
this.event POST pfc_close()
return
From the Open event of an inherited window, I do:
if ..... then
this.of_closeFromOpenEvent( )
return
end if
The function closes the window, but using POST, so the window first finishes to open up. Since I don't want to see a window flash up and then immediately disappear, I move it first waaaaaay downwards: y = 20000
That way the window is out of sight when it opens up for a very short time, thus avoiding flashes.
I have somewhere a function that saves window positions, when closing windows, so I had to add an exception to NOT save the positions when Y=20000. (n_display_props.of_saveWinPos() ). If not, next time the window opens up it would be invisible.
Just an idea.
regards
Thanks for your answer, I did almost the same and now it's working.
Regards