Results 1 to 3 of 3

Thread: multiple mdi childs of the same form question

  1. #1

    Thread Starter
    Frenzied Member markman's Avatar
    Join Date
    Nov 2000
    Location
    Florida.
    Posts
    1,197

    multiple mdi childs of the same form question

    How do you jump between mdi childs? I loaded them with this:
    Code:
    Public Sub CreateNewDocument()
        Static DocCount As Long
        Dim frmDoc As frmDocument
        Set frmDoc = New frmDocument
        DocCount = DocCount + 1
        frmDoc.Caption = "Document " & DocCount
        DoEvents
        frmDoc.Move 0, 0
        frmDoc.Show
    End Sub
    and now, say when I hit command1, I want the one that says document3 to come to the front. How?
    retired member. Thanks for everything

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    just use the SetFocus method to bring the form to the front.

    You'd need to loop through the Forms collection to do what you want...paste this into a module
    VB Code:
    1. Public Function FrmFocus(frmCaption As String) As Integer
    2. ' Inputs: Form caption
    3. ' output: 1 form found, 0 form not found
    4.  
    5. Dim frm As Form
    6.  
    7. For Each frm In Forms
    8.     If frm.Caption = frmCaption Then
    9.         'match found, set focus
    10.         frm.SetFocus
    11.         FrmFocus = 1
    12.         Exit Function
    13.     End If
    14. Next frm
    15.  
    16. ' not found!
    17. FrmFocus = 0
    18.  
    19. End Function
    Usage...
    VB Code:
    1. Private Sub Command2_Click()
    2.  
    3. Dim intReturn As Integer
    4.  
    5. intReturn = FrmFocus("Form4")
    6.  
    7. If intReturn = 0 Then MsgBox "Form 4 not found!", vbCritical
    8.  
    9. End Sub

  3. #3
    Addicted Member Michael Woolsey's Avatar
    Join Date
    Nov 2000
    Location
    Calgary, Alberta, Canada.
    Posts
    243
    You will probably want to use the ActiveForm Property to utilize the form when you have found it.

    Just rambling in case you didn't know it existed.

    Michael Woolsey
    Application/Web Developer

    Visual Basic 6.0 SP5
    Active Server Pages
    Oracle 9i
    - I'm going to live forever, or die trying!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width