Window.Close causing System.Beep to sound

I have two properties on winFont. One is OK, set by btnOK and btnCancel. btnOK also builds a FontClass object stored in a property. The caller reads the OK and Font class and deals with it.

Still using .Hide and a subsequent .Close should not yield random system beeps, it is valid code and should work.

As you’ve discovered, reading properties on a closed window is OK, but accessing UI controls is not.

I agree it’s probably a bug. However, since you are in some sense “doing it wrong” (the immediate hide then close is… unusual) and if you were doing it the “right” way, there’s no Beep.

If you trace through the code in the debugger, it’s definitely odd - the “hide” command seems to be functioning as a “window.close” command (because if the window didn’t close, the event loop would be stuck in ShowModal, and your parent window could never reach the next line:

oWindow.ShowModal( Self )
...
oWindow.Close  <-- this line is only reached after the window has closed

except that .Hide does end the ShowModal It always has. In VB it was the way it was done so I suspect that is the reason it doesn’t work the way you think it should. I disagree it is not “doing it wrong”, simply doing it a different way from you.

1 Like

Huh, according to https://documentation.xojo.com/api/user_interface/desktop/desktopwindow.html.ShowModal you are correct, it says “or until the window becomes invisible”

I wonder if this is an API1 vs 2 bug then?

Just tried an old API1 version and it didn’t make the sound.