MdiWindowListItem


Author
Message
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
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.

Replies
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
The form handle won't change after it has been assigned.  If you are running in an MDI environment, then you can handle the OnParentChanged event and save off the handle at that point (I recommend against this).  You should ALWAYS be able to reference the Me.Handle of the form and it will return the handle to which it is presently assigned, which is the only one that you should ever deal with.  This is standard WinForms logic...once a handle is assigned it should never be changed unless the parent changes...that may be the ONLY time that it would change. 

Now it is another thing entirely if the handle has already been released.  In that case you just need to handle an event further up the chain to perform your closing logic.

Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Just to confirm,

I'm also getting back a different handle to than which the child window was assigned on creation.

And also I've tried changing to formclosing but the handle still changes.

Edhy Rijo

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
OK...different than what?  You have mentioned that you are getting back a different handle...but what are you comparing the handle to? 
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
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 (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
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 (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K 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 (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 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).
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ivan George Borges - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ivan George Borges - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ivan George Borges - 19 Years Ago
                         [quote]You have put the Themed Containers in a docked form on the...
Trent L. Taylor - 19 Years Ago
                             Hey Trent, Nice, I have been attempting to do the same. Would be nice...
Michael Reese - 19 Years Ago
                                 Can't believe it, Trent ... I did it!!! It is even activating the...
Ivan George Borges - 19 Years Ago
                                     This form looks very familiar ... I just can't understand what it says...
Trent L. Taylor - 19 Years Ago
                                         Seriously...it looks great!
Trent L. Taylor - 19 Years Ago
Chan - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Michael Cobb - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Keith Gordijn - 17 Years Ago
Keith Gordijn - 17 Years Ago
                         That will work fine :)
Trent L. Taylor - 17 Years Ago
Michael Cobb - 18 Years Ago
             Glad it worked for you :)
Trent L. Taylor - 18 Years Ago
StarkMike - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Teddy Jensen - 18 Years Ago
Trent L. Taylor - 18 Years Ago
Teddy Jensen - 18 Years Ago
Ivan George Borges - 18 Years Ago
Edhy Rijo - 17 Years Ago
StrataFrame Team - 17 Years Ago
                         [quote][b]Ben Chase (03/31/2008)[/b][hr]You'll need to store more than...
Edhy Rijo - 17 Years Ago
Chan - 17 Years Ago
Mike Tomlin - 17 Years Ago
Trent L. Taylor - 17 Years Ago
Edhy Rijo - 17 Years Ago
Trent L. Taylor - 17 Years Ago
                         Oh....nevermind, you are using that older logic on the window handles...
Trent L. Taylor - 17 Years Ago
                             Since we no longer use this logic I hadn't noticed that Vista changes...
Trent L. Taylor - 17 Years Ago
                                 [quote][b]Trent L. Taylor (04/15/2008)[/b][hr] [codesnippet]For each f...
Edhy Rijo - 17 Years Ago
                                     You would be passing it into some method. If you look further up the...
Trent L. Taylor - 17 Years Ago
Teddy Jensen - 17 Years Ago
Edhy Rijo - 17 Years Ago
Paul Chase - 17 Years Ago
lastcanary - 15 Years Ago
Ivan George Borges - 15 Years Ago
Russell Scott Brown - 15 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search