MessageBox inside a custom class

I have a window with two custom classes… [container controls with embedded canvas]
each one needs to detect if its contents change on Window Activate… (another Topic, and I have that part working)
but if it does detect a change, I need to ask the user if they want to reload the data.

It displays the dialog, and regardless of which button (Yes/No) I click… the dialog dims slightly and the app freezes

as a test I put the below in the Window Activate, and then the app crashes when I click a button…
I have used this many times… but this is first time since Mojave (not sure who to blame :slight_smile: )

Dim d As New MessageDialog                  // declare the MessageDialog object
Dim b As MessageDialogButton                // for handling the result
d.Icon = MessageDialog.GraphicCaution       // display warning icon
d.ActionButton.Caption = "Yes"
d.CancelButton.Caption = "No"
d.CancelButton.Visible = True              // show the Cancel button
d.AlternateActionButton.Visible = False     // show the "Don't Save" button
d.Message =filePATH.NativePath
d.Explanation = "has been changed by another application."+EndOfLine+"Do you want to reload it?"
debug "AAAA"
b = d.ShowModal                             // display the dialog
debug "BBBB"  <------- IT NEVER GETS HERE.... the app just seems to freeze
Select Case b                               // determine which button was pressed.
...... more stuff

In order to make it work I had to change this line :frowning:

b = d.ShowModalWithIn(Window1)

I guess it was trying to show it in the ContainerControl instead

you should be able to change that to self.truewindow so it displays modally over the front most window

Thanks… .that worked too…

Now the problem is… since this is in WIndow Activate… it calls it twice… but I think I can get around that

yeah you’d get another activate when the dialog gets closed

yup… I just had to have the dialog box also update the cached mod date… and it seems to work as desired


This document offers great advice for improving dialog messaging: