Community
Showing results for 
Search instead for 
Do you mean 
Reply

Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

Copper Contributor
Posts: 32
Country: Germany

Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

[ Edited ]

I have a problem with Act! v17 Premium.

After I change the position of the menu buttons in my  Act! Toolbar my plugin disappears.

Why and how can I change it?

(There is no such problem in Act! v16 as there is no function to change the positions of Act! Toolbar buttons)

Copper Contributor
Posts: 32
Country: Germany

Re: Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

[ Edited ]

The problem here was that i didn't changed the libaries Act.Framwork.dll and using Act.Framework.ComponentModel.Core from version 16.2 to 17.1.

Copper Contributor
Posts: 32
Country: Germany

Re: Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

[ Edited ]

I thought I solved it, but no. I Changed all the Act libaries to V17.1.. I can see the plugins. They work but when I try to change their position in the Act! Toolbar they vanishing. Simultaneously I can see a plugin of mine in the window where I determine the positions of the plugins but it is not installed. How can I delete this entry and why my plugins are vanishing?

Copper Super Contributor
Posts: 86
Country: United_Kingdom

Re: Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

Hi benoit22,

 

Which toolbar are you referring to?

I assume you're referring to the global toolbar along the top which starts with the back / forward buttons but I want to be sure.

 

Can you list the exact steps you're taking?

 

I can't replicate the first behaviour, when I re-arrange my buttons everything is fine.

I'm moving my buttons using "Global Toolbar Options". Is this the same way you're doing it?

 

I can definitely replicate the second one though. Now I've disabled my plugin the toolbar button has not disappeared, although interestingly all my other menus have as expected.

I'll need to double check the source code for my project as I think this might be my fault. You have to explicity remove all menus and toolbars in the shutdown event of your plugin and I might have missed this. I'll have to check and get back to you.

 

Kind regards,

 

Sam.

____________________________________________________________

Unfortunately I no longer work for Swiftpage International. Please do not send any queries to this account.
Copper Contributor
Posts: 32
Country: Germany

Re: Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

[ Edited ]

Thanks for reply. Yes I mean the the Global Toolbar aka "ACT! Toolbar".

The bottom line of the Code I am using is:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Windows.Forms;

using Act.UI;
using Act.Framework;
using Act.Framework.Contacts;
using Act.UI.Core;



namespace Testproject
{
    public class CustomMenuPlugin : IPlugin
    {


        Act.UI.Core.CommandBar tBar = null;
        Act.UI.Core.CommandBarButton newMenu = null;


        private const string CONNECTED_MENUBAR = "Connected Menus";
        private const string DISCONNECTED_MENUBAR = "Disconnected Menus";
        private const string ACT_TOOLBAR = "ACT! Toolbar";

        private const string CUSTOM_MENU_URN = "act-ui://com.act/application/menu/tools/customx";
        private const string CUSTOM_MENU_TEXT = "Custom";

        private ActApplication application;

        void IPlugin.OnLoad(ActApplication application)
        {
            // hold on to the application
            this.application = application;

            // be sure to keep track of when a user logs in or is logged out
            application.AfterLogon += new EventHandler(Application_AfterLogon);
            application.BeforeLogoff += new EventHandler(Application_BeforeLogoff);

        }

        void IPlugin.OnUnLoad()
        {

            // this is equivalent to being disposed,
            // so make sure to detach from any events
            if (application != null)
            {
                application.AfterLogon -= new EventHandler(Application_AfterLogon);
                application.BeforeLogoff -= new EventHandler(Application_BeforeLogoff);
                ActFramework framework = application.ActFramework;
                if (framework != null)
                {
                    framework.Database.BeforeDatabaseLock -= new Act.Framework.Database.DatabaseLockHandler(Database_BeforeDatabaseLock);
                }
            }
        }

        private void Application_AfterLogon(object sender, EventArgs e)
        {
            //TODO: attach to any events or perform actions

            // also, keep track of when we're about to be locked out
            application.ActFramework.Database.BeforeDatabaseLock += new Act.Framework.Database.DatabaseLockHandler(Database_BeforeDatabaseLock);



            // add custom menu
            AddMenuItem(CUSTOM_MENU_URN, CUSTOM_MENU_TEXT, new Act.UI.CommandHandler(DoStuff));

            this.application.ActFramework.Database.BeforeDatabaseLock += new Act.Framework.Database.DatabaseLockHandler(this.BeforeDatabaseLock);


        }

        private void Application_BeforeLogoff(object sender, EventArgs e)
        {
            // make sure to detatch from anything framework/database/user related,
            //as we are about to be logged out

            // Remove this so it doesn't become part of the customized menus
            RemoveMenuItem(CUSTOM_MENU_URN);
        }

        private void DoStuff(string command)
        {
            MessageBox.Show("Do something");
        }


        public void BeforeDatabaseLock(object obj, Act.Framework.Database.DatabaseLockInformation LockInfo)
        {

        }

        #region Custom Menu

        private void AddMenuItem(string urn, string text, Act.UI.CommandHandler Handler)
        {
            try
            {
                if (MenuItemExists(urn) == true)
                {
                    RemoveMenuItem(urn);
                }
                //Act.UI.Core.CommandBarControl parentMenu = this.application.Explorer.CommandBarCollection[ACT_TOOLBAR].ControlCollection[GetParentControlURN(urn)];
                 newMenu = new Act.UI.Core.CommandBarButton(text, text, null, urn, Properties.Resources.test, Properties.Resources.test);
                newMenu.DisplayStyle = Act.UI.Core.CommandBarControl.ItemDisplayStyle.ImageAndText;
                this.application.RegisterCommand(urn, new Act.UI.CommandHandler(Handler), Act.UI.RegisterType.Shell);

                tBar = this.application.Explorer.CommandBarCollection[ACT_TOOLBAR];
                tBar.ControlCollection.Add(newMenu);

                //parentMenu.AddSubItem(newMenu);
            }
            catch { }
        }

        private void RemoveMenuItem(string urn)
        {
            try
            {
                if (newMenu != null)
                tBar.ControlCollection.Remove(newMenu);


                this.application.RevokeCommand(urn);
                Act.UI.Core.CommandBarControl RemoveMenu = this.application.Explorer.CommandBarCollection[ACT_TOOLBAR].ControlCollection[urn];
                
                this.application.Explorer.CommandBarCollection[ACT_TOOLBAR].ControlCollection[GetParentControlURN(urn)].RemoveSubItem(RemoveMenu);
                this.application.Explorer.CommandBarCollection[ACT_TOOLBAR].ControlCollection.Remove(RemoveMenu);

            }
            catch (System.Exception ex)
            {
                MessageBox.Show("Error RemoveMenuItem:  " + ex.ToString());

            }
        }

        private bool MenuItemExists(string urn)
        {
            return (application.Explorer.CommandBarCollection[ACT_TOOLBAR].ControlCollection[urn] != null);
        }

        private string GetParentControlURN(string urn)
        {
            return urn.Substring(0, urn.LastIndexOf("/"));
        }

        #endregion

        private void Database_BeforeDatabaseLock(object sender, Act.Framework.Database.DatabaseLockInformation databaseLockInformation)
        {
            //TODO: we're about to be forced out, so perform any cleanup
        }

    }


}

As you can see its from the SDK Sample "CustomMenuPlugin" with a few changes.

 

 

Copper Super Contributor
Posts: 86
Country: United_Kingdom

Re: Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

Let me investigate this further and get back to you. I need to see if I can resolve the second issue before posting any code samples.

 

Kind regards,

 

Sam.

____________________________________________________________

Unfortunately I no longer work for Swiftpage International. Please do not send any queries to this account.
Copper Super Contributor
Posts: 86
Country: United_Kingdom

Re: Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

[ Edited ]

Hi benoit22,

 

I've tested this and my hunch was right, if I add code to explicity remove the button before shutdown then the issue goes away.

 

This is good practice and is what everyone should be doing with all additions they make to the UI. Each menu/button/tab/panel etc should be added after Act! is loaded and then explicity removed on shutdown. This prevents "ghosts" in the UI should your addin be disabled or uninstalled.

 

Try this and if you get stuck let me know and I'll see if I can get a code sample constructed for you.

 

Kindest regards,

 

Sam.

 

Edit: I forgot to add that I still can't replicate the first issue. If you could let me know what steps you're taking then I'll give it another go.

____________________________________________________________

Unfortunately I no longer work for Swiftpage International. Please do not send any queries to this account.
Copper Contributor
Posts: 32
Country: Germany

Re: Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

Thanks!!

 

One last thing. How can I identify the URN of the ghost?

Because if I loop through  Act! Toolbar:

 

  string ToolbarComponents = "";


  for (int x = 0; x < tBar.ControlCollection.Count; x++)
       {
         ToolbarComponents = ToolbarComponents + "tBar.ControlCollection[" + x + "]  " + tBar.ControlCollection[x].Command + "\n";
       }

                 MessageBox.Show(ToolbarComponents);

Theres is no sign of the Plugin (ghost) but I can see it in the "Global Toolbar Options".

 

Kind regards,

 

Marcus

 

Copper Super Contributor
Posts: 86
Country: United_Kingdom

Re: Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

[ Edited ]

Please see the following solution provided by Jim Durkin. It creates a text file with all URNs. It's in VB but is easy to convert to C#.

 

http://community.act.com/t5/Act-Developer-s-Forum/URN-for-Contacts-menu/m-p/246066/highlight/true#M6...

 

If the URN isn't there then the only other solution is to reset all menus and toolbars through Tools > Customise > Reset Menus and Toolbars. Unfortunately this will reset all menu customisation, there's no way to reset only the global toolbar.

____________________________________________________________

Unfortunately I no longer work for Swiftpage International. Please do not send any queries to this account.
Copper Contributor
Posts: 32
Country: Germany

Re: Act v17 Act! Toolbar / Button disappears after I change the position of other Act! Toolbar buttons

[ Edited ]

Thanks again!!

 

Finally I tried to reset all menus and toolbars through Tools > Customise > Reset Menus and Toolbars.

I still see the Plugin entry in the "Global Toolbar Options".

Maybe there is no way around to reinstall Act.

(I didnt found any URN)

 

 

best regards

 

 

Marcus

 

 

P.S. This only happens in relation to a specific User on Windows 7