MDI child and tool widows - always on top?

M

Mitchell Vincent

I have an MDI child window that pops open it's own tool windows. I would
like for the tool window to stay on top of that MDI child so that if
they open the MDI child back up they *have* to dismiss the tool window
to continue working.. I don't want this tool window to stay on top of
others, though, as it will have nothing to do with other parts of the
program.. Can I make the tool window a child of the MDI child window
somehow? I hope I'm not mixing up terms..

I hope you know what I mean (and how I might do it!).

Thanks!
 
E

Eric Moreau

Hi

A MDI Child cannot be set as TopMost.

We need to add the tool window as a control of the main form (that's why the
TopLevel property is set to False) so that we can set this new form as
TopMost:

Dim f As New fUnlockBillet
f.TopLevel = False
Me.Controls.Add(f)
f.Parent = Me
f.TopMost = True
f.Show()

--


HTH

Éric Moreau, MCSD, Visual Developer - Visual Basic MVP
(http://aspnet2.com/mvp.ashx?EricMoreau)
Conseiller Principal / Senior Consultant
Concept S2i inc. (www.s2i.com)
 
M

Mitchell Vincent

Eric said:
Hi

A MDI Child cannot be set as TopMost.

We need to add the tool window as a control of the main form (that's why the
TopLevel property is set to False) so that we can set this new form as
TopMost:

Dim f As New fUnlockBillet
f.TopLevel = False
Me.Controls.Add(f)
f.Parent = Me
f.TopMost = True
f.Show()

Thanks Eric! I really appreciate the pointer here.. However, this seems
to make the tool window always on top of the MDI container, not the
"parent" form. It always looks like the tool window doesn't have the
focus (it's grayed out) even though I can click on it and type in it's
form fields...
 
P

Peter Huang [MSFT]

Hi

I think you may try to run the code in the Child Form's Form_Load event,
then the embeded form will on the child form only.
Based on my research, the other floating windows, including the toolbar of
VS.NET IDE will not have hightlight when we click on it.
the Form2 is a child form

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim f As New Form3
f.TopLevel = False
Me.Controls.Add(f)
f.Parent = Me
f.TopMost = True
f.Show()
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Mitchell Vincent

Peter said:
Hi

I think you may try to run the code in the Child Form's Form_Load event,
then the embeded form will on the child form only.
Based on my research, the other floating windows, including the toolbar of
VS.NET IDE will not have hightlight when we click on it.
the Form2 is a child form

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim f As New Form3
f.TopLevel = False
Me.Controls.Add(f)
f.Parent = Me
f.TopMost = True
f.Show()
End Sub

Best regards,

Hi Peter! The problem is, however, that the form (Form3 in your example)
isn't showing on top of the 'parent' MDI child at all. I could almost
live with it not looking like it has focus, but it has to remain on top.

Perhaps the best way would be to loop through the MDI children and see
if the contact window exists (I can make the title of the window
correspond).

How do I loop through all open windows and apply focus to one (which
would go in the parent form's focus event, I assume)?

Thanks!
 
P

Peter Huang [MSFT]

Hi

I think we can enumerate the form in the MdiChildren collection and use
activate method to make certain form focused.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim fm As Form
fm = New Form2
fm.MdiParent = Me
fm.Show()

fm = New Form3
fm.MdiParent = Me
fm.Show()
End Sub

Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MenuItem1.Click
For Each fm As Form In Me.MdiChildren
If fm.Text = "Form2" Then
fm.Activate()
End If
Next
End Sub

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 

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