D
Daniel Friend
Hi,
I have a mdi program which a mdi child (MDI1) opens another mdi child (MD2).
What is happening, the MDI 1 stay focus, after MDI2 appears. The user has
to double click MDI2 to get focus, but the weird thing is that MDI2 is on
top. As you can see from the code, I tried everything to make sure MDI2 has
focus.
Thanks,
Dan
Here is my sample code:
MDIPARENT CODE:
==================
Public Sub BuildNewWindow(ByVal ssCaption As String, ByVal Tag As String,
ByVal Width As Integer, ByVal Height As Integer, ByVal sForm As Form)
sForm.Text = ssCaption
sForm.Width = Width
sForm.Height = Height
sForm.Left = (fDesktop.Width - Width) / 2
sForm.Top = (fDesktop.Height - Height) / 2
sForm.MdiParent = Me
sForm.Tag = Tag
sForm.Show()
sForm.BringToFront()
Application.DoEvents()
sForm.Focus()
sForm.Activate()
sForm.FindForm.Activate()
Application.DoEvents()
End Sub
MDI1 CODE:
==================
Private Sub OpenMsgWindow
Me.Cursor = Cursors.AppStarting
Application.DoEvents()
Dim sForm As Form2
sForm = New Form2
mdiParent.BuildNewWindow("Test Caption", "TAGINFO", 400, 200, sForm)
Me.Cursor = Cursors.Default
Application.DoEvents()
End Sub
I have a mdi program which a mdi child (MDI1) opens another mdi child (MD2).
What is happening, the MDI 1 stay focus, after MDI2 appears. The user has
to double click MDI2 to get focus, but the weird thing is that MDI2 is on
top. As you can see from the code, I tried everything to make sure MDI2 has
focus.
Thanks,
Dan
Here is my sample code:
MDIPARENT CODE:
==================
Public Sub BuildNewWindow(ByVal ssCaption As String, ByVal Tag As String,
ByVal Width As Integer, ByVal Height As Integer, ByVal sForm As Form)
sForm.Text = ssCaption
sForm.Width = Width
sForm.Height = Height
sForm.Left = (fDesktop.Width - Width) / 2
sForm.Top = (fDesktop.Height - Height) / 2
sForm.MdiParent = Me
sForm.Tag = Tag
sForm.Show()
sForm.BringToFront()
Application.DoEvents()
sForm.Focus()
sForm.Activate()
sForm.FindForm.Activate()
Application.DoEvents()
End Sub
MDI1 CODE:
==================
Private Sub OpenMsgWindow
Me.Cursor = Cursors.AppStarting
Application.DoEvents()
Dim sForm As Form2
sForm = New Form2
mdiParent.BuildNewWindow("Test Caption", "TAGINFO", 400, 200, sForm)
Me.Cursor = Cursors.Default
Application.DoEvents()
End Sub