How to make MODAL MDIChild

C

Chris Petchey

My App is an MDI Parent with MDI Child forms.

One of the child forms calls a modal dialog form.

I would like the modal dialog form to be INSIDE the mdi parent window.

I am not bothered about any of the other things associated with MDI
Parent/Child relationships, this is purely an appearance issue.

MDIParent property and ShowDialog seem to be mutually exclusive.

Surely some bright sparks knows how this is achieved.
 
N

ng

The best I can offer is to set the modal form's owner property to the
mdiparent, then call showdialog. It won't be truly an mdichild, but at
least it will be connected to the mdiparent.

T
 
C

Chris Petchey

If I understand your suggestion:

Dim f As New Form2
f.Owner = Me.MdiParent
f.ShowDialog()

It appears to me that the second line makes NO DIFFERENCE AT ALL.
In what way is it "connected to the mdiparent" ?
It is not visibly contained within the mdiparent window, a specific
requirement of my original post.
Please clarify
 
C

Cor Ligthert [MVP]

Chris,

Some people give a solution and than that solution is not to do, and you get
very few answers.

Others ask help for a problem.

Can it be that your problem is that when the mdi form is showed that it
might give only control to another form or whatever as some conditions are
fulfilled.

That is easy to do by setting in the closing event of that form
\\\
if something not is done then
e.cancel = true 'or false because I am always confused by that just try
that
end if
///

I hope this helps,

Cor
 
C

Chris Petchey

Cor,

I was quite specific about what I was attempting to do.
To reiterate:
I want my modal dialog to be "contained" in my mdiwindow. The modal
dialog does not need to be a true mdichild, but must give the appearance
of being contained within the mdiwindow.

I am unsure what your solution represents. It seems you have answered a
question other than the question I asked, and maintained the mysticism
of the redirection by enveloping it in a web of english is not my first
language.

As I am no closer to my solution, i guess it didnt help.

However, are you aware that google groups attributes 10,200 articles to
"you" in this news group alone (search on "Cor Ligthert")?

Chris
 
C

Cor Ligthert [MVP]

Chris,
I was quite specific about what I was attempting to do.

I doubt that because you did beside mine only get an answer how to handle a
showdialog.
To reiterate:
I want my modal dialog to be "contained" in my mdiwindow.

And therefore I gave an answer, just open it as a normal mdiform, however
prevent that the user can leave that the same as with a dialog form by
setting in the closing event of that mdi form.

If conditionIsNotFulfilled then 'which is the same as with a ShowDialog
e.cancel = true 'or as I wrote false just test that
end if

And than of course if you use a button on the mdi child in the event of
that.
condition set
me.close

I hope this helps,

Cor
 
C

Chris Petchey

Cor

Your solution prevents the user from closing the mdichild.

MODAL means that the user can't interact with any other form in the
application until the modal form closes.

How much more specific can I be? I want a modal form that cannot be
moved outside an mdiwindow. Access exhibits this behaviour.

Please attempt to understand my problem, rather than a different problem
that you know the answer to. It doesnt help. If you don't know, you
don't know.

Have a nice weekend

Chris
 
C

Cor Ligthert [MVP]

Chris,

You are right, I did not test it, I will try a solution tomorrow, based on
this.

It will be based on the fact that every form will when it get focus check
(using a shared class) if the form that we call modal. is open and than give
the focus back to that. AFAIK is a modal form nothing more than an advanced
dialog, and therefore unusable for this.

However I promised to somebody else to test something first and that is
primaley, maybe this sentence above gives you self the idea.

Cor
 
C

Cor Ligthert [MVP]

Chris

As promished. It is just a simple approach meant how it could be possible.

\\\The "Modal" child
Private Sub Form2_LostFocus(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.LostFocus
If Me.TextBox1.Text <> "1" Then
Me.Focus()
Else
Me.Close()
End If
End Sub
///
\\\All forms except the parent (you can by instance inherit a form)
Private Sub Form3_Activated(ByVal _
sender As Object, ByVal e As System.EventArgs) _
Handles MyBase.Activated
test.test(Me.MdiParent)
End Sub
End Class
///
\\\
Public Class test
Public Shared Sub test(ByVal par As Form)
For Each frm As Form In par.MdiChildren
If frm.Name = "Form2" Then
If DirectCast(frm, Form2).TextBox1.Text <> "1" Then
frm.Focus()
End If
Exit For
End If
Next
End Sub
///

I hope this helps,

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top