Community
Showing results for 
Search instead for 
Do you mean 
Reply

Complete Example for Adding Buttons to ToolBar?

Copper Contributor
Posts: 12
Country: USA

Complete Example for Adding Buttons to ToolBar?

Hi All;

 

As a .NET newbie, it seems that examples posted on this topic assume knowledge that may not be there on the part of the reader (a common problem with high level knowledge, when explaining things you just take for granted).  I've been playing with adding a button in a plugin, using the examples given and it just isn't working for me.

 

Does anyone have a working example that includes all Subs, Functions and qualifiers, such as the urn, image files/icons, etc. so I don't have to guess?

 

I've been around and around in circles in the SDK documentation, which is not particulary useful as it has no actual working code examples for this.

 

Thanks!


 

Employee
Posts: 1,163
Country: USA

Re: Complete Example for Adding Buttons to ToolBar?

In this thread i posted a method for adding a new button to the toolbar, in this case, the opportunity tool bar, and the event in which it was called. These two methods were added to the plug-in sample that is included in the SDK download.

 

If you have any specific questions regarding implementation don't hesitate to ask.

Matthew Wood
Act! SDK Support
Community Moderator
Copper Contributor
Posts: 12
Country: USA

Re: Complete Example for Adding Buttons to ToolBar?

Hi Matthew;

Thanks for the reply - I should have mentioned that I'm using VB.NET, not C#, so it's a bit hard to follow. Do you have a VB example?
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Complete Example for Adding Buttons to ToolBar?

[ Edited ]

Attached is a full VS 2008 project/solution in both VB.Net and C# which demonstrates how to add a toolbar icon. It may be more helpful then just posting code examples. To run, extract the VS 2008 project attached open in VS 2008/2010. By default the startup project is the VB example.

 

I am running Win7/64 so the "Start External program" is set to :
"C:\Program Files (x86)\ACT\Act for Windows\ActSage.exe"

 

If you are NOT running Win7/64 please set this to:
"C:\Program Files \ACT\Act for Windows\ActSage.exe"

 

Let me know if you have any issues getting this example solution to run or if you had any difficulties so I can adjust the solution for future examples.

 

Thanks

-- Jim Durkin

Copper Contributor
Posts: 12
Country: USA

Re: Complete Example for Adding Buttons to ToolBar?

Hi Jim;

Thanks for that, but once I added all the code to my solution and tried to run it, ACT! started kicking an error and wouldn't start. Here's the error from the ACT! error report:
----------------------------------------
Microsoft.Practices.Unity.ResolutionFailedException: Resolution of the dependency failed, type = "Act.UI.ActApplication", name = "". Exception message is: The current build operation (build key Build Key[Act.UI.ActApplication, null]) failed: Value of 'null' is not valid for 'stream'. (Strategy type BuildPlanStrategy, index 3) ---> Microsoft.Practices.ObjectBuilder2.BuildFailedException: The current build operation (build key Build Key[Act.UI.ActApplication, null]) failed: Value of 'null' is not valid for 'stream'. (Strategy type BuildPlanStrategy, index 3) ---> System.ArgumentException: Value of 'null' is not valid for 'stream'.
at System.Drawing.Icon..ctor(Stream stream, Int32 width, Int32 height)
at System.Drawing.Icon..ctor(Stream stream)
at Act.UI.Common.Images.ImageManager.GetIcon(String iconName)
at Act.UI.Core.MenuImageManager.getIcon(String imageFileName)
at Act.UI.Core.MenuImageManager.GetIcon(String urn)
at Act.UI.Core.Explorer.RestoreImagesToCollection()
at Act.UI.Core.Explorer.LoadDisconnectedMenuToolBar()
at Act.UI.ActApplication.InitializeExplorer()
at Act.UI.ActApplication.InitializeApplication()
at Act.UI.ActApplication..ctor(IUnityContainer container, IEventAggregator eventAggregator)
at BuildUp_Act.UI.ActApplication(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
--- End of inner exception stack trace ---
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.Builder.BuildUp(IReadWriteLocator locator, ILifetimeContainer lifetime, IPolicyList policies, IStrategyChain strategies, Object buildKey, Object existing)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name)
--- End of inner exception stack trace ---
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name)
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name)
at Microsoft.Practices.Unity.UnityContainerBase.Resolve[T]()
at Act.Application.ActBootstrapper.ConfigureContainer()
at Act.Composite.UnityExtensions.SimpleUnityBootstrapper.Run(Boolean useDefaultConfiguration)

-----------------------------------------------
I took out the code and recompiled and it still produces the error. I then took out the plugin from the plugins directory and ACT! still kicks the error! Anyone have any idea what is wrong with this picture?
Bronze Super Contributor
Posts: 1,231
Country: USA

Re: Complete Example for Adding Buttons to ToolBar?

It looks like when you added the code into your project you did not copy of the BMP file used in the NewToolbar or you did not set the 'Build Action" of that BMP to 'Embedded Resource'

 

You also may not have removed the NewToolbar on the ACT Unload event. Either way the ACT toolbar preference file has a null icon and is choking when loading its preferences.

 

I am guesstimating this based on the stack:

ACT is loading its menu preferences on this line;

Act.UI.Core.Explorer.LoadDisconnectedMenuToolBar()


Then ACT is loading the image on the this line:

at System.Drawing.Icon..ctor(Stream stream, Int32 width, Int32 height)

 


If you actually get into ACT! then TOOLS->CUSTOMIZE->RESET MENU AND TOOLBAR.

If you can not get into ACT then delete the preference file. Its something like:

USpreferences206.xml

DisconnectedBarV13.ser

ConnectedBarsV14.ser

 

These files would be found in the roaming profile folder:
"C:\Users\USERNAME\AppData\Roaming\ACT\ACT Data\Preferences\"

 

Hope this helps

-- Jim Durkin

Copper Contributor
Posts: 12
Country: USA

Re: Complete Example for Adding Buttons to ToolBar?

Hi Jim;

No Joy in Mudville.

Still getting the error and can't get into ACT!

I've searched for these files and only found the preferences files and deleted those. I'm using ACT! 2010 Premium installed on drive E:\. I don't have an E:\Users\USERNAME\AppData\Roaming\ACT\ACT Data\Preferences folder.

I previously had this problem and wound up taking out everything ACT! and SQL server from the folder trees after doing an uninstall, including from the registry before it would let me do a re-install. Hoping to avoid that exercise.

I suspect that the root problem that caused this was trying to load a non-standard sized icon that was wider than it is tall. Also tried to load both the large and small icons. Any other ideas?

Thanks for the help! Very much appreciated.
Copper Contributor
Posts: 12
Country: USA

Re: Complete Example for Adding Buttons to ToolBar?

Hi Jim;

I found the bad boys - my Windows Explorer search criteria didn't have system and hidden files selected. Doh!

Thanks again!