﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » Enhancement Requests  » Form manager class</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 02:35:18 GMT</lastBuildDate><ttl>20</ttl><item><title>Form manager class</title><link>http://forum.strataframe.net/FindPost11611.aspx</link><description>I have seen many post about the same thing, how to launch a form and have some control over the process.&amp;nbsp; Trent and others has made some very nice suggestion like the one below.&amp;nbsp; &lt;/P&gt;&lt;P&gt;I think that this type of functionality should be included in the SF framework itself, since 99% of projects based on SF will have to launch at least one form, this&amp;nbsp;functionality definately should be part of the framework.&lt;/P&gt;&lt;P&gt;[quote][b]Trent L. Taylor (06/07/2007)[/b][hr]You can do that, but you first need to have a centralized collection that can be referenced.&amp;nbsp; You are actually better off doing this outside of the instantiaion for one primary reason...speed and maintainability...OK, that is two reasons :)&amp;nbsp; We created a shared class called MenuSystem which houses all of our instantiation logic.&amp;nbsp; Security, form collections, multiple-instances, and whether the form will appear in the MDI window or on its own, all within one central location.&amp;nbsp; Ours had to be a bit more specialized since it can launch VFP forms or .NET forms.&amp;nbsp; But the logic is basically the same. &lt;/P&gt;&lt;P&gt;You could even create a class that is passed to the MenuSystem that has all of the logic that you need that you could pass over....or just create a bunch of overloads to do this for you.&amp;nbsp; It is just up to you, but the key is creating a class that launches all of your forms according to your environment and needs.&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;Public Notineritable Class MenuSystem&lt;BR&gt;&lt;BR&gt;Private Shared _MenuMdiClient As MDIClient&lt;BR&gt;Private Shared _Forms As New System.Collections.Generics.List(Of SYstem.Windows.Forms.Form)&lt;BR&gt;&lt;BR&gt;'-- Reference to the MDI client to which all client forms will be added.&amp;nbsp; Be sure to set this in your&lt;BR&gt;'&amp;nbsp;&amp;nbsp;&amp;nbsp; New of the parent that houses the MDI client.&lt;BR&gt;Public SHared Property MenuMdiClient As MDIClient&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return _MenuMdiClient&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set(Byval value as MdiClient)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _MenuMdiClient = value&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End Set&lt;BR&gt;End Property&lt;BR&gt;&lt;BR&gt;'-- This collection contains all of the forms that are loaded&lt;BR&gt;Public Shared Readonly Property Forms As System.Collections.Generics.List(Of System.Windows.Forms.Form)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return _Forms&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Get&lt;BR&gt;End Property&lt;BR&gt;&lt;BR&gt;'-- Central method to load all of the &lt;BR&gt;Public Shared Sub LaunchForm(ByVal FormType As System.Type, Byval SecurityKey As String, Byval SingleInstance As Boolean)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Establish Locals&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim loForm As System.WIndows.Forms.Form&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If SecurityBasics.CurrentUser.GetPermission(SecurityKey).Action = Grant&amp;nbsp;Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Check for a single instance&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If SingleInstance AndAlso&amp;nbsp;FormIsRunning(FormType) Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit Sub&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Create and launch the form&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; loForm = CType(Activator.CreateInstance(FormType), System.WIndows.Forms.Form)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; loForm.MdiParent = _MenuMdiClient&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; '-- Create a handler so it can remove itself from the collection&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; AddHandler&amp;nbsp;loForm.FormClosed, Addressof HandleFormClosed&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; loForm.Show()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp; Private Shared Function FormIsRunning(Byval FormType As System.Type) As Boolean&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim llReturn As Boolean = False&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each loForm As Form In _Forms&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If loForm.GetType() Is FormType Then&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; llReturn = True&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Exit&amp;nbsp;For&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; End If&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Next&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Return llReturn&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;BR&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Private Shared Sub HandleFormClosed(Byval sender as Object, Byval e as System.EventArgs)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; _Forms.Remove(CType(sender, Form))&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New"&gt;End Class&lt;/FONT&gt;[/quote]</description><pubDate>Fri, 21 Sep 2007 23:41:26 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Form manager class</title><link>http://forum.strataframe.net/FindPost11634.aspx</link><description>Hi,&lt;/P&gt;&lt;P&gt;Since I am really new to .NET I can get too deep into the discussion, but as a developer in general, all I want to see in the framework are those little things that has to be done in each project and that will take a lot of time to do all over again.&lt;/P&gt;&lt;P&gt;I have to admit that being working with a VFP framework may have spoiled me a little, but when is time to start a new project I don't want to have to remember to manually create classes all over again. :hehe:</description><pubDate>Fri, 21 Sep 2007 23:41:26 GMT</pubDate><dc:creator>Edhy Rijo</dc:creator></item><item><title>RE: Form manager class</title><link>http://forum.strataframe.net/FindPost11628.aspx</link><description>That's a good point Greg... everyone uses the scheme, but everyone also customizes it.&amp;nbsp; A template wouldn't be a bad idea.</description><pubDate>Fri, 21 Sep 2007 09:05:29 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: Form manager class</title><link>http://forum.strataframe.net/FindPost11622.aspx</link><description>I wonder if this should be part of the framework (i.e. one of the classes included in the framework).  I just seeing a zillion variations on the theme, so much so that I wonder how much something like this would actually get used.  I know I use constructors of forms a lot to pass in required initial data that is needed to load the data on the form.  &lt;br&gt;
&lt;br&gt;
However, what about making a template for this? Then there could be a new SF MenuSystem object that you could add to the project.  This is a very nice starting point for all of those variations.  Just a thought...</description><pubDate>Thu, 20 Sep 2007 11:16:13 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>