MsgBox and MessageDIalog Problems

I am having a problem with msgbox and messageDialog.
They both require unusual conditions to operate.

If I run a MsgBox from within a module with buttons of any kind, it automatically sets it to the affirmative.
So if you set code like this

Dim i As Integer = MsgBox("Place this on the window", 36)
You will automatically get 6

The other problem I have is MessageDialog
In that same location and have it set to only

b = d.ShowModal // Code taken from the LR
Then the dialog doesn’t show literally. It should show but it doesn’t.

If I put in ShowModalWithin, that doesn’t work,
unless I pass the window WITHIN as part of the call.

so I need

d.ShowModaWithin(self)

Here is an example of what should work.
Example Project

If I have a method in a module that is several windows deep, I need to still pass a window to it, or it doesn’t work.

To me, this is not what should be happening.
Am I missing something?

Are you using Windows, Mac or Linux?

Your example project works ok on macOS 10.12.6. I even changed to b = d.ShowModal and it works.

Maybe I don’t understand the issue.

I couldn’t replicate your issues but personally I wouldn’t open modal message boxes/windows during an Open event of a window as it can cause all sorts of race/messaging issues.

Try this in Window1.Open:

Xojo.Core.Timer.CallLater(0, AddressOf Module1.Stuff)

This will make sure that Stuff is called after Open has completed and all the messages associated with opening the window have been processed.

Have a read up on Xojo.Core.Timer.CallLater, it’s very handy, you can also pass arguments along with it if needed.

Just for information:

b = d.ShowModal

will show the MessageDialog on the center of your screen, it could be outside your window

b = d.ShowModaWithin(self)

will show as a “drop down” on the top-middle of your window.

I think I only have the issue on Mac and it has been several years.
About using that in open - I forgot about racing. I forgot for the example.
About the example. It will work. If I put the same code in my app then it won’t.
I should not have to put in
Showmodalwithin(self) to make it work. It is also diffificult passing a window to a module.

Ok, so your example should work (and it works), but the same code will not work on your app.

If you can’t make an example (that won’t work and mimic your issues) for Xojo to take a look you may need to send your app (privately) for them to look at it.

If you open a modal dialog in the OPEN event of a window, it could cause that event (or at least the Activate to fire again, as you removed focus from the window to show the dialog)… and if done during the CLOSE event, the window may not truly close (it might hide, but stay instantiated)

I know about that one too, :frowning:
Thanks for confirming what I did. I haven’t resolved it yet, but it’s more clear.

Thanks for letting me vent my grumbles. It helps me believe I can get a resolution.