MdiWindowListItem


Author
Message
Michael Cobb
Michael Cobb
StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
Thanks Trent.  This works perfectly!
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I think that the best thing to do would be to expose the MDI client...or....if your main form just has the MDIContainer property set you can reference it directly.  When the form is launched it will have a reference to the parent form in the ParentForm property which you can type and reference.  You may need to make your LauncForm method public or Friend so it can be accessed though.

DirectCast(Me.ParentForm, MainForm).LaunchForm(GetType(MyChildForm))

If you are using an MDIClient control and manually adding it to the form, then you can just expose it through a public property and basically do the same thing:

DirectCast(Me.ParentForm, MainForm).MDIClientProperty.LaunchForm(GetType(MyChildForm))

Michael Cobb
Michael Cobb
StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)StrataFrame Novice (50 reputation)
Group: Forum Members
Posts: 26, Visits: 1K
This is a good thread.  This may be slightly off topic but I wasn't sure where to post this question. 

I have a main MDI form with the following method that is used to launch a child form.

    Private Sub LaunchForm(ByVal FormType As System.Type, Optional ByVal AllowMultiple As Boolean = True)
        '-- Look to see if the form is already loaded - bring to front
        If AllowMultiple = False Then
            For Each loCurForm As Form In Me.MdiChildren
                If Not loCurForm.InvokeRequired Then    ' Can access the form directly
                    If loCurForm.GetType() Is FormType Then
                        If loCurForm.WindowState = FormWindowState.Minimized Then
                            loCurForm.WindowState = FormWindowState.Maximized
                        End If

                        loCurForm.BringToFront()
                        Exit Sub
                    End If
                End If
            Next
        End If

        '-- Establish Locals
        Me.Cursor = Cursors.WaitCursor

        Dim loForm As Form
        loForm = CType(Activator.CreateInstance(FormType), Form)

        '-- Set the MDI
        loForm.MdiParent = Me

        '-- Show the form
        loForm.Show()

        Me.Cursor = Cursors.Default
    End Sub

The child form has a control which needs to open a new child form in the main MDI form.  Any ideas about how to accomplish this?

Thanks for looking!

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Seriously...it looks great! 
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
This form looks very familiar ... I just can't understand what it says BigGrin

Good job, I really like the way it looks!

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Can't believe it, Trent ... I did it!!!

It is even activating the item when clicked in the ListView.

I can go and enjoy my Friday night now.

THANKS A LOT.

Michael Reese
Michael Reese
Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)Advanced StrataFrame User (533 reputation)
Group: StrataFrame Users
Posts: 235, Visits: 1.6K
Hey Trent,

Nice, I have been attempting to do the same. Would be nice to have the sample code in a small projectSmile

Michael

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
You have put the Themed Containers in a docked form on the left, is that it?

That's it.  Just to improve performance on the ThemedContainer, set the MinimizeBodyBehavior to Snap instead of Scroll if you are going to allow the container to be opened and closed.

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)Strategic Support Team Member (4.9K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
wow ... thanks Trent. I had the LoadForm already, but the Handler got me stuck.

I will try to populate a list just like you did. You have put the Themed Containers in a docked form on the left, is that it?

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
If I feel like completely lost, I will cry for help.

Hehe Sounds good.

just need to find a nice peace of paper.

I don't know that one exists.  Here is a sample method to load up all of your client forms in the MDI.

Declare the form collection

''' <summary>
    ''' Collection of all of the forms
    ''' </summary>
    ''' <remarks></remarks>
    Private _Forms As New System.Collections.Generic.Dictionary(Of Integer, System.Windows.Forms.Form)

Create a reusable method to load a child form

''' <summary>
    ''' A reusable method that allows forms to be launched.  This will reside in your
    ''' MDI form.
    ''' </summary>
    ''' <param name="FormType"></param>
    ''' <remarks></remarks>
    Public Sub LoadForm(ByVal FormType As System.Type)
        '-- Establish Locals
        Dim loForm As System.Windows.Forms.Form

        '-- Create the form
        loForm = CType(Activator.CreateInstance(FormType), Form)

        '-- Associate the new form with the MDI form
        loForm.MdiParent = Me

        '-- Add a handler to the form close
        AddHandler loForm.FormClosed, AddressOf HandleFormClosed

        '-- This is a good place to update your open form collection
        _Forms.Add(loForm.Handle.ToInt32(), loForm)

        '-- Update the list or menu

        '-- Show the form
        loForm.Show()
    End Sub

Create a handler method that is used to trap the FormClosed event.  This will be assigned in the LoadForm() method

''' <summary>
    ''' Handles the closing of the form
    ''' </summary>
    ''' <param name="sender"></param>
    ''' <param name="e"></param>
    ''' <remarks></remarks>
    Private Sub HandleFormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs)
        '-- Establish Locals
        Dim loForm As System.Windows.Forms.Form

        '-- The sender will be the form.  See if the form is in the collection
        If _Forms.ContainsKey(CType(sender, Form).Handle.ToInt32()) Then
            '-- Get the form reference
            loForm = _Forms(CType(sender, Form).Handle.ToInt32())

            '-- Remove the handler
            RemoveHandler loForm.FormClosed, AddressOf HandleFormClosed

            '-- Remove from the collection
            _Forms.Remove(CType(sender, Form).Handle.ToInt32())

            '-- Update your list or menu
        End If
    End Sub

Sample method showing how to call the LoadForm method

''' <summary>
    ''' Just a sample of how to call the LoadForm method
    ''' </summary>
    ''' <remarks></remarks>
    Private Sub SampleLoadingForm()
        LoadForm(GetType(MyForm))
    End Sub

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search