Limit Tabs / Forms  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Limit Tabs / Forms

Postby SBarnes » 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?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Limit Tabs / Forms

Postby Scott.Pearce » Thu Jan 16, 2020 4:46 pm

Sound like a job for a plugin.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Limit Tabs / Forms

Postby SBarnes » Thu Jan 16, 2020 4:48 pm

Yeah I know that but not where to start???
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Limit Tabs / Forms

Postby Scott.Pearce » Thu Jan 16, 2020 4:49 pm

Code: Select all
Manager.MDIParentForm.MdiChildren
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Limit Tabs / Forms

Postby Mike.Sheen » Thu Jan 16, 2020 4:50 pm

SBarnes wrote:Yeah I know that but not where to start???


Manager has a property, MDIParentForm and that has a property OwnedForms which is a list of Form. Use the count of that to see if you have exceeded your imposed limit in a handler of the Manager.FormFactory BeforeFormStart event.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Limit Tabs / Forms

Postby Scott.Pearce » Thu Jan 16, 2020 4:51 pm

You are making it too easy for him Mike ;-)
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Limit Tabs / Forms

Postby Mike.Sheen » Thu Jan 16, 2020 4:52 pm

Scott.Pearce wrote:You are making it too easy for him Mike ;-)


Sorry - I didn't realise we were supposed to be making it difficult.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Limit Tabs / Forms

Postby SBarnes » Thu Jan 16, 2020 4:55 pm

No if you wanted to make it difficult you would have given me the code in CIL but it's not April yet :lol:
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Limit Tabs / Forms

Postby SBarnes » Thu Jan 16, 2020 5:53 pm

Ah see you promised not to make it difficult and unless I've missed something I found a bug in the below code only the After Start message shows up and looking in Just Decompile in the form Factory BeforeFormStart is declared but never checked for being set and called and OwnedForms.Length is always zero.

Code: Select all
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());       
   }
}
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Limit Tabs / Forms

Postby Mike.Sheen » Fri Jan 17, 2020 9:06 am

Ok, then use the property Scott suggested - Manager.MDIParentForm.MdiChildren.

I only suggested OwnedForms because in our LogOff method we use that to close all open forms - whether they are MDI Children or not:

Code: Select all
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
...
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests