I explain the problem with this video: https://www.eprime.it/temp/wisejshodwialog1.zip
1) in a desktop application, open a FormX, and a children FormX2 with showdialog
2) open another main FormY
3) close the FormX2
4) now FormY is the new showdialog form, as if it had been opened by FormX
this problem in a desktop application it’s very limiting
thanks to the code you wrote in this thread, I have the complete solution
I have created an Extension, that do exactly what I ask.
and the parent form is locked exactly like on the desktop, and all other forms are free
it’s work wery well!
this is the code (in the forum I must put ‘’ instead ‘<'):
if you want you can integrate wisej ShowDialog code with this, if it is useful
Public Sub ShowWithParentLock(ByVal childForm As Form, ByVal parentForm As Form)
ShowWithParentLock(childForm, parentForm, Nothing)
''' Emulate showdialog function, without freezing only the parent form
''' [param name="childForm"][/param]
''' [param name="parentForm"][/param]
''' [param name="actionAfterClose"][/param]
Public Sub ShowWithParentLock(ByVal childForm As Form, ByVal parentForm As Form, ByVal actionAfterClose As Action)
If (childForm Is Nothing) Then
Throw New ArgumentNullException("childForm")
If (parentForm Is Nothing) Then
Throw New ArgumentNullException("parentForm")
Dim activatedDelegate As EventHandler = Sub(sender, e)
AddHandler childForm.FormClosed, Sub(ByVal sender As Object, ByVal closedEventArgs As FormClosedEventArgs)
If (actionAfterClose IsNot Nothing) Then
RemoveHandler parentForm.Activated, activatedDelegate
RemoveHandler parentForm.GotFocus, activatedDelegate
If (Not childForm.IsDisposed OrElse Not childForm.Disposing) Then
Catch ex As Exception
AddHandler parentForm.Activated, activatedDelegate
Wisej also manages normal windows opened after the modal, but it has to move them to the modal z-index range. That’s what you are seeing when closing the modal in between. There is no solution at the moment other than close the modal before opening a non-modal or make the non-modal modal.
Please login first to submit.