MdiWindowListItem


Author
Message
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
Oh....nevermind, you are using that older logic on the window handles being stored off in the collection...gotcha.  I will see if I can reproduce.
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
Since we no longer use this logic I hadn't noticed that Vista changes the handle several times through the life of the form.  So to get around this, if you still intend to use window handle, then you will need to override the OnHandleChanged method to trap that event so that you can update your collection logic.

Overrides Protected Sub OnHandleChanged(...)
    '-- Add your logic to update the collections
End Sub

However, I would recommend against using the window handle at this point and add a Guid property to your BaseForm that uniquely identifies the form:

Public Class MyBaseForm
     Inherits MicroFour.StrataFrame.UI.Windows.Forms.StandardForm

   Private _FormId As String = System.Guid.NewGuid().ToString()

   Public Readonly Property FormId As String
        Get
             Return _FormId
        End Get
   End Property
End Class

Then you can enumerate the Forms collection of the MDI to find your form and then activate it (this code would be referencing the MDI  form):

For each f as Form In Me.MdiChildren
    If DirectCast(f, MyBaseForm).FormId = MyLookupId Then
        '-- You found the form
    End If
Next

If you take this approach you will be much safer across multiple platforms and won't be reliant upon the window handle.

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Trent L. Taylor (04/15/2008)

For each f as Form In Me.MdiChildren
    If DirectCast(f, MyBaseForm).FormId = MyLookupId Then
        '-- You found the form
    End If
Next

If you take this approach you will be much safer across multiple platforms and won't be reliant upon the window handle.

Trent, I hate to ask, but using the GUID logic, where is the MyLookupID value coming from?

Edhy Rijo

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 would be passing it into some method.  If you look further up the food-chain on this thread, you will see that they have a collection that stores off the open forms.  So when the form is loaded, you would add this guid to the collection with probably a title or something else so that it could be identified in the list (if you are using the panel on the left approach).
Teddy Jensen
Teddy Jensen
StrataFrame Novice (112 reputation)StrataFrame Novice (112 reputation)StrataFrame Novice (112 reputation)StrataFrame Novice (112 reputation)StrataFrame Novice (112 reputation)StrataFrame Novice (112 reputation)StrataFrame Novice (112 reputation)StrataFrame Novice (112 reputation)StrataFrame Novice (112 reputation)
Group: StrataFrame Users
Posts: 52, Visits: 8K
In case anyone wants a ToolStripDropDownButton instead of a windowslist in a sidepanel or on a menu you can use this approach.

On the toolstrip i have a button called tsbVinduer so my code on the main form is

Private Sub tsbVinduer_DropDownOpening(ByVal sender As Object, ByVal e As System.EventArgs) Handles tsbVinduer.DropDownOpening

 

        tsbVinduer.DropDownItems.Clear()

 

        For Each f As Form In Me.MdiChildren

 

            Dim item As ToolStripMenuItem = New ToolStripMenuItem(f.Text)

            item.Tag = f

 

            AddHandler item.Click, AddressOf item_Click

 

            tsbVinduer.DropDownItems.Add(item)

        Next

 

    End Sub

 

    Private Sub item_Click(ByVal sender As Object, ByVal e As EventArgs)

 

        Dim item As ToolStripItem = TryCast(sender, ToolStripItem)

        If item IsNot Nothing Then

            Dim f As Form = TryCast(item.Tag, Form)

            If f IsNot Nothing Then

                f.Activate()

            End If

        End If

    End Sub

It gives me this result:

/Teddy

Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Teddy,

Thanks for sharing this approach, it definitely provide ideas on how to get similar results in different ways which is very good, specially when learning .NET.

Edhy Rijo

Paul Chase
Paul Chase
Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)Advanced StrataFrame User (576 reputation)
Group: Forum Members
Posts: 414, Visits: 2.8K
Just to add another option to this thread you can also handle the Mdi Client Control Added and Removed on your Main MDI Form.

#Region " MDI Client Handled Events"

Protected Sub MDIClient_ControlAdded(ByVal sender As Object, ByVal e As Windows.Forms.ControlEventArgs)

'--> Cast To My Base Class so we get custom properties

Dim loChild As Payroll.Base.WindowsForms.DevExMaintFormBase = CType(e.Control, System.Windows.Forms.Form)

' do anything you need to do -add handlers update custom lists etc

End Sub

Protected Sub MDIClient_ControlRemoved(ByVal sender As Object, ByVal e As Windows.Forms.ControlEventArgs)

'--> Cast To Base Class so we get custom properties

Dim loChild As Payroll.Base.WindowsForms.DevExMaintFormBase = CType(e.Control, System.Windows.Forms.Form)

' do anything you need to do - remove handlers update custom lists etc

End Sub

#End Region


Keith Gordijn
Keith Gordijn
StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)
Group: Forum Members
Posts: 35, Visits: 2.6K
Trent L. Taylor (06/14/2007)
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))




Hi Trent,



My project follows the ideas outlined in this topic by following the StrataFlix example and I would also like to use the LaunchDialog method of the mainform from a "Setup and Configuration" form (strangely also very similar to the PracticeStudio.NET screen shot earlier in this topic) to open a maintenance form as a child form in the main mdi form.



Unfortunately my still limited knowledge of C# wont let me alter the above VB code to a C# version so any help on doing this would be great.



Cheers,

Keith
Keith Gordijn
Keith Gordijn
StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)StrataFrame Novice (69 reputation)
Group: Forum Members
Posts: 35, Visits: 2.6K
Hooray, I've had some success! Maybe I should get up at 2am more often. BigGrin



So, now my question is, is this the best way of doing this?



private void tlmSecurity_ItemClicked(object sender, ThemedLinkMenuClickEventArgs e)

{

if (e.Item.Key.Equals("SecurityEditor", StringComparison.OrdinalIgnoreCase))

{

MainForm loForm;

loForm = (MainForm)this.ParentForm;



loForm.LaunchDialog(typeof(SecurityDialog));

}

}




Cheers,

Keith
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
That will work fine Smile
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