Closing custom window

I created a custom window for simple dialogs so that on windows I can try to keep them from popping behind the current window.

I just have an OK command button that on MouseDown calls Me.Window.Close

Works fine on my Mac. In Windows it does nothing when I click the button.
Window stays open.

Do I have to have some sort of return code to get it to work in windows.


Why would the button not call Self.Close on the Action event?

Sorry I pasted the wrong code. it does call Self.Close but it does not close.
Button flashes from the click but window does not close. Very bizarre.

I tried built the exe and same problem. Very weird.

If I find something odd like this I go back to first principles and make a blank test project with just the code in I want to test. This is put on the Window1 of a new project.

Sub Action() Handles Action Self.Close End Sub

This performs as expected on Windows so its probably your app logic doing something odd, or it would be something wrong with the version of Xojo you’re using (if its alpha/beta etc).

Did you open the window in some special/different way?

Is your code in a subclass definition? If so, Self is the button, not the window.

Wouldn’t that behave the same for both Mac and Windows though?

Why not put a breakpoint on the Self.Close and step to see what your app does afterwards?

Does the CANCELCLOSE or CLOSE event refer to ANY attribute of the window (property, control, etc)?
If so, and IMPLICIT INSTANCE is check (which by default it is), then the Window does in fact close, but immediately REOPENS because you made a direct or indirect reference to it again.

I will check on these things… just getting back to it after the weekend.

Shouldn’t this be the Action event?

Otherwise, put a break point in the code to make sure it’s actually getting to that code you think is supposed to run.

I believe the problem is that it was supposed to return a value and there was no return statement in the close method. The problem went away and I think that’s what did it.