MdiWindowListItem


Author
Message
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
Hiya.

I am shamelessly trying to copy "someone's" idea of a MainForm.Tongue

My intention is to get rid of the MenuStrip and use the ThemedToolStrip instead. So far, so good. But now I got to the "Window" item, which will show the opened MDI windows list.

Now I would need to have a "Window" ToolStripDropDownButton to behave in the same way as the MenuStrip MdiWindowListItem. Would that be too difficult to implement?

Cheers.

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
I am shamelessly trying to copy "someone's" idea of a MainForm.

I wonder where I have seen that done before Wink

Now I would need to have a "Window" ToolStripDropDownButton to behave in the same way as the MenuStrip MdiWindowListItem. Would that be too difficult to implement?

It really isn't too difficult.  We actually use a list instead of updating the DropDown menu, which is easier and takes less time.  In either case, you just need to "wrap" the loading and closing of your forms.  We have a menu system that wraps all of our menu calls and we create a handler when the form is created.  Also, when the form is created we add it to the list and pass along the window handle.  When the forms "FormClosed" event fires, we then remove the item from the list.

The above is a screen shot from our medical system and shows how we implement the Windows Panel.  Ours is a little more complicated because we actually have a legacy VFP session within the MDI environment as well as the .NET forms.  So both of them have to show up in this panel which is a little more cumbersome.  But for .NET only forms, this is much easier because you are directly in control of the forms.

One other option is to just monitor the MDIChildren property of the MDI form or client.  The MDI client or form has a property called MdiChildren which is a list of all of the visible forms:

Me.MdiChildren

In any case, there are a number of ways to monitor the forms and place them in a collection and deal with them.  If this doesn't get you started let me know and I will give you some more snippets.

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
I see you copied from the same person!!!  BigGrin

Yeah, I found your main form pretty sharp, so I'm trying the same.

I got the idea, will work on it. If I feel like completely lost, I will cry for help. I'm looking for the proper way to "wrap" the loading and closing of the forms ... just need to find a nice peace of paper. Hehe

Thanks Trent.

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K 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 (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
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.

Michael Reese
Michael Reese
StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 reputation)StrataFrame User (403 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

Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K reputation)Strategic Support Team Member (3.5K 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.

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

Good job, I really like the way it looks!

Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Seriously...it looks great! 
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