08-02-2011 06:19 PM
I have developed an ACT! Pro 2011 (for Windows) plugin in .NET that adds a tab to the Contacts detail view and a different tab to the Companies detail view. It all seems to work fine, except that if a contact is being displayed in the detail view, and the user goes to the Tools menu -> Design Layouts -> Contact to open the Layout Designer, and then closes the Layout Designer window (whether saving changes or not), the tabs on the contact detail view are refreshed and they are all duplicated (all the standard ones as well as my custom one). This doesn't happen if my plugin is not loaded, so is there something that a plugin needs to do to stop this from happening?
Here's some details of what the plugin code is doing (the code is based on samples that I've found around these forums):
In my event handler for ActApplication.AfterLogon, I subscribe to the ActApplication.ViewLoaded and ActApplication.ApplicationState.LayoutLoaded events.
In the ActApplication.ViewLoaded event handler, I check if the View in the ViewEventArgs parameter is an IContactDetailView - if so, I unsubscribe from ActApplication.ViewLoaded and load the tab using ActApplication.UILayoutDesignerManager.AddTabToCurrentLayout
In the ActApplication.ApplicationState.LayoutLoaded event handler, I check if the LayoutFileInfo.layoutType parameter is a Act.UI.LayoutDesigner.LayoutType.contact and the ActApplication.CurrentView is an IContactDetailView - if so, I load the tab in the same way as above.
The same things are done for my custom Companies tab - except it looks for company layouts and views instead of contact ones.
When debugging the plugin to try to find the cause of the problem, I can see that ACT has already duplicated all the standard Contact Detail View tabs (but not my custom tab yet) when the first event handler in my code (for ActApplication.ApplicationState.LayoutLoaded) is called after closing the Contact Layout Designer window.
Could someone please point me in the right direction for solving this problem? I suspect that there is something else that my plugin needs to do to prevent the Layout Designer from duplicating the tabs, but I can't find anything on it and I am stumped.
08-03-2011 06:50 AM
This is odd indeed, what version of Act are you using?
I glanced over the sample that I have and compared it to the description you gave, I think the issue may be with adding the tab in the LayoutLoaded event since it will get called again once we close and save the layout designer. In my sample I created an AddTab method and call it once in the ViewLoaded event.
The content of AddTab is pretty basic, this is the relevant portion:
System.Windows.Forms.TabPage myTabPage = new TabPage("Test");
08-03-2011 06:25 PM
The ACT version is: Sage ACT! Pro 2011 Version 188.8.131.52, Hotfix 1
The problem still occurs even if I don't subscribe to the LayoutLoaded event and just use the ViewLoaded event - the only difference is, my custom tab isn't duplicated, but all the standard ones are.
My equivalent to your AddTab function looks like this, the content of my tab is on a WinForms UserControl:
if (this.actApplication != null && (this.actApplication.CurrentView as IContactDetailView) != null)
TabPage myTab = new TabPage("My Tab");
MyUserControl myUserControl = new MyUserControl(actApplication);
myUserControl.Dock = DockStyle.Fill;
I found that if I changed this to show the tab without loading the user control into it, then it would work (Design Layouts wouldn't duplicate the tabs), so the problem wasn't the events, but something to do with the content of my user control. Through trial-and-error, I found that if I removed a SplitContainer that I had in the user control, it would work and Design Layouts wouldn't duplicate the tabs! As a test, I made another simple plugin, and found that if the user control content of the custom tab contains just a SplitContainer and nothing else, the problem of Design Layouts duplicating the tabs would occur.
I have also noticed some causes of the issue that seem totally bizarre to me - for example, my user control contains a group box which contains a data grid view. The group box is anchored to the bottom of the user control and the data grid view is anchored to the bottom of the group box, and it works fine, but if I change the anchoring of the data grid view to not anchor to the bottom of the group box, the problem occurs. Or if I change the DockStyle in the code above from Fill to Top, the problem occurs. Do you know why this might be? Should I be using something else other than a user control for my tab content?
So my simple solution is just to get rid of the SplitContainers from my tabs and be very careful with what I put on the tabs and how I anchor controls. This largely works, although I've noticed that sometimes the standard Contact tab, and sometimes my custom tab for companies, will still duplicate on the Companies detail view when closing the Design Layouts window after editing the Companies layout.
08-04-2011 07:02 AM
I was able to reproduce this issue, I created a simple user control that contained only a split container and it duplicated all the standard tabs. I tested again adding a split container to the tab but not within a new user control and the issue still occurred, I tried with a group box with no docking setting and it did not occur and then once more with the same groupbox except this time I added a datagrid view to it and it worked fine (no duplication).
I continued experimenting with different containers in the user control and haven't found any others (yet) that cause this behavior. Additionally, I couldn't cause the duplication with a group box + datagrid view regardless of the docking style I chose.
I'm going to have to look into this some more, this is certainly perculiar behavior.
08-04-2011 05:35 PM
I'm glad it's not just me going crazy. Even if I remove my SplitContainer, the problem often happens for me. There doesn't seem to be any apparent rhyme or reason to it. There's a number of controls on my tab (various text boxes, labels, buttons, a data grid view, overlapping group boxes with different visibility settings etc), but just the smallest thing like resizing a control can make the problem occur or not occur. Even worse, sometimes when I run ACT, I'll go to the default tab in Contacts detail view, do the Design Layouts for Contacts and the tabs are not duplicated. If I then click on my custom tab, and do the Design Layouts for Contacts again, the tabs are then duplicated!
This may be a fairly common problem for ACT plugins, as our client first contacted their ACT account manager about this duplicating tabs issue, and he told our client that he has seen this happen before when there are ACT add-ins installed.
Let me know what you find in your investigations.
Thanks for your help,
08-04-2011 08:27 PM
James & Matthew,
I suspect that the issue is that when part of a routine errors out the whole routine doesn't finish. In this case the routine placing the controls on the layout may have a problem when there is a splitter in the control. That routine might also determine if the tabs are already there. Since the routine doesn't finish it doesn't know the tabs aren't there so the next routine adds a new set. This is an over simplification and may not be what is really causing the problem but if you put error handling in the control you may be able to see where the error is if there is one and eliminate it getting rid of the additional tabs.
08-07-2011 11:22 PM
Hi Stan and Matthew,
I have tried to see if there's an exception occuring anywhere in my UserControl that I can catch, and have tried stepping through the code (including my UserControl's InitializeComponent that places the controls on it), but I can't see any error occurring in my UserControl when the tab duplication happens. The problem seems to be happening outside my UserControl, but is influenced by the content of my UserControl.
02-14-2013 07:01 PM
I am experiencing a similar experience with ACT! 2013 (V184.108.40.206 SP1) where changing a layout using " Design Layout" results in the Tab Bar being duplicated when saving and closing the Design Laout Option.
Refreshing the Views does not make any difference and opening the Design Layout, resaving and closing generates another set of the same tabs.
Normal ACT! Diag processes do nor rectify problem but closing the database and reopening it will some times revert to normal single Tab Set. Other times require shutting down ACT! and restarting.
The problem is replicated in other databases under same circumstances. The ACT! Pro Version has recently been updated to latest Release Version and various *.Bat Fixes applied. I have removed, cleaned and reinstalled the ACT! Software, MS SQL and Framework but still see the problem.
Any ideas or recommendations?
02-15-2013 07:58 AM
I have seen this happen many times on different components we have developed for ACT UI such as tabs dashboards and custom controls on the detail surface.
What we usually find is our component is not removing its event handles to the ACT events and thereby the garbage collection does not destroy the object.
Also for tabs; you can manually remove your custom tab page from the tabpage collection. You may still reside in memory because of the event handles but you are disconnect from the UI. Not the best option since it's a huge memory leak but how often will the users be going into the designer on any given day.
TabControl.TabPages.RemoveByKey(TabName + "_DurkinCustomTab")
Hope this helps
-- Jim Durkin