Hi,
Is there a way to either check if a MsgBox is on screen, OR, check if more than 1 window (the main window) is open?
I have my main window containing a ListBox, and I want to prevent the contextual menu from showing if any MsgBoxes or other windows are open. I have no idea how to check if any other windows or MsgBoxes are being displayed however
I am thinking along the lines of setting the text of a hidden label to true whenever a MsgBox is called, or when a window is opened - and then check the text of the label in the contextual menu action.
A MsgBox is modal, so no other part of your application will react to mouse clicks.
For regular windows use the WindowCount and Window methods:
For i As Integer = 0 To WindowCount - 1
If Window(i) IsA MyWindow And Window(i).Visible Then
// at least one instance of MyWindow is open and visible
End
Next
Thanks, but the ContextualMenu in the ListBox in the main window does still show if the user right-clicks over it, - even if a msgbox is currently displayed.
At the moment I’m working on OS X, so I can’t help further - but it seems indeed strange that a application modal message box allows something like that.
I’m running windows 8.1 and don’t see this behavior. None of my right-click contextual menus will work if a msgbox is being displayed. Do you have an example project you can post?
In cases like this, create a small project that replicates the issue. That you can share and will go a long way to replicating the issue and getting it fixed. Until that happens all we can go on is that you have a problem but no one else can do it.
I’ve seen it happen, a lot, where in the process of making a very simple project to show others you discover the real issue. This happens to me all the time. Sometimes you’ll discover a true framework bug but most of the time you’ll find it in your own code.
I have just noticed that if the MsgBox originates from the same window - the right-click DOES NOT work (as expected).
BUT, if the MsgBox originates from window 2, the user can move the mouse over Window 1, and still use the right-click of that window.
Tim
What I meant was - if an action on window 2 initiates a MsgBox , the user can still use the contextual menu of window 1. This is what I am trying to prevent.
Seems like it’s always been window-specific in REALbasic on Windows. Maybe it’s always been wrong? I’m just used to it, so I assumed that’s the way it’s supposed to be.