Limit Tabs / Forms
Posted: Thu Jan 16, 2020 4:45 pm
Is there a way to limit the number of forms/tabs that a user can open in the MDI Parent?
Manager.MDIParentForm.MdiChildren
SBarnes wrote:Yeah I know that but not where to start???
Scott.Pearce wrote:You are making it too easy for him Mike
public class ApplicationManagerPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaApplicationManagerPlugin
{
public override object InitializeLifetimeService()
{
// returning null here will prevent the lease manager
// from deleting the Object.
return null;
}
public void Setup(JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin)
{
//System.Diagnostics.Debugger.Launch();
Plugin.Manager.FormFactory.BeforeFormStart += BeforeFormStart;
Plugin.Manager.FormFactory.AfterFormStart += AfterFormStart;
}
public void BeforeFormStart(JiwaFinancials.Jiwa.JiwaApplication.Forms.Form form, string RecordID, bool NewRecord, object OwnerForm)
{
System.Windows.Forms.MessageBox.Show("Before form start " + form.Manager.MDIParentForm.MdiChildren.Length.ToString());
}
public void AfterFormStart(JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm JiwaForm)
{
System.Windows.Forms.MessageBox.Show("After form start " + JiwaForm.Manager.MDIParentForm.MdiChildren.Length.ToString());
}
}
Public Sub LogOff()
Dim cancelargs As New System.ComponentModel.CancelEventArgs
RaiseEvent LoggingOff(cancelargs)
If cancelargs.Cancel = False Then
If Not MDIParentForm Is Nothing Then
For Each form As Form In MDIParentForm.OwnedForms
form.Close()
Next
End If
...