Community
Showing results for 
Search instead for 
Do you mean 
Reply

Creating New Toolbar

Tuned Listener
Posts: 29
Country: Canada

Creating New Toolbar

[ Edited ]
Hey everyone,
 
 I'd like to develope a commandbar visible for the user at the application front UI, and I understood that I can do that, from the example on SDK documentation I have done this:
 

private void AddMenu(string urn, string text)

{

try

{

CommandBar NewBar;

CommandBarButton button;

System.Drawing.Icon myIcon = ACT_Test.Properties.Resources.wiz;

NewBar = application.Explorer.CommandBarCollection[text];

if (NewBar == null)

NewBar = application.Explorer.CommandBarCollection.Add(text, CommandBarType.Toolbar);// I tried CommandBarType.Menubar as well

button = new CommandBarButton("Button 1", "testing buttons", null, urn, myIcon, CommandBarControl.ItemDisplayStyle.ImageAndText, true);

int btn = NewBar.ControlCollection.Add(button);

NewBar.IsVisible = true;

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

}

urn values: I tried the following...

"act-ui://com.act/application/menu/tools/custom"

"act-ui://com.act/application"

"act-ui://com.act/application/menu/tools"

However not sure urn would be of anyhelp, coz I'm trying to get something visible not inside the menues. 

Code runs with no exception but there is nothing visible. What is wrong am I doing?



Message Edited by hickins on 03-11-2008 08:17 AM
.NET Developer
Copper Contributor
Posts: 97
Country: USA

Re: Creating New Toolbar

Try adding your new bar to the application control collection and set it visible...
 
            Form mainApp = _ActApp as Form;       //Cast the ActApplication to a Form
            mainApp.Controls.Add(newBar);          //Add the new bar
            newBar.Visible = true;                          //Show the bar
            newBar.BringToFront();                        //Show the bar
 
Try this from ACT!'s ViewLoaded or AfterLogon event.
 
HTH,
jason
Jason Sellers
ACT! Engineer 2000-2007
Tuned Listener
Posts: 29
Country: Canada

Re: Creating New Toolbar

Thanks for the reply.
 
Cast will be possible for ActApplication to Form, but casting newBar to a System.Windows.Forms.Control will not be possible.
 
Didn't work, however it was nice to try.
 
 I have suggested to the management to have a seperate windows App that interact with ACT rather than embed a toolbar inside Act UI, since I have noticed that building an embeded toolbar is not popular practice in Act.
 
 Thank you!
 
Joe
.NET Developer
Copper Contributor
Posts: 97
Country: USA

Re: Creating New Toolbar

Hi Joe,
 
I've seen several add-ons that add toolbars... I think it's a great way to add value to ACT!'s UI while keeping the vast majority of the ACT! experience intact.  Besides, who wants another application?  ;-)
 
Do you need to use the CommandBar type?  Have you tried it with just a System.Windows.Forms.ToolStrip and ToolStripButton?  Works quite well using the method described above.
 
jason
Jason Sellers
ACT! Engineer 2000-2007
Tuned Listener
Posts: 29
Country: Canada

Re: Creating New Toolbar

[ Edited ]
Hey Jason,
 
 Thanks for the great replies. I have just released a product that integrates to Outlook CRM, and I have developed it with VSTO, and the idea is to have the same work done on ACT.
 
 Outlook commandbar is visible in Explorer UI, and it works like a charm, but I'm not sure if I'm missing something, but from what I am getting from Act support gave me an impression that what I have in mind is not so popular within Act developer community.
 
 I'm looking into a crisp commandbar (toolbar) embeded within ACT main UI, and that toolbar can have buttons, popup menus and comboboxes, however, I'm not sure yet if that is possible in Act, no one gave me a working code sample that does what I need.
 
 
 Thanks again Jasen.
 
 
Joe


Message Edited by hickins on 03-12-2008 01:32 PM

Message Edited by hickins on 03-13-2008 11:15 AM
.NET Developer
Copper Contributor
Posts: 97
Country: USA

Re: Creating New Toolbar

Hi Joe,
 
What's your product and where can I read more about it?
 
I have a friend on the dev team that knows more about the CommandBar structure than I do and I've asked him to review this thread.  If he has anything useful to add I'll post it.
 
In the meantime I'd suggest playing around with ToolStrip along with ToolStripButton, ToolStripDropDownButton, ToolStripComboBox, etc.
 
jason
Jason Sellers
ACT! Engineer 2000-2007
New Member
Posts: 2
Country: USA

Re: Creating New Toolbar

[ Edited ]

Here is a sample from a plugin that I created for doing some testing.  This creates a toolbar.   I would recommend creating your own toolbar.  I know that there are samples for creating a menu and getting it to show up in ACT!.  A couple of things I would like to point out that may not work in the future.   Using of DevComponents.DotNetBar items directly are not supported and might go away in the future.  This is needed today to add items into a combobox and get events from that item. The urn value that you need to set needs to be a unique command name.   I would recommend the something simular to the what you were attempting to use but have the act replaced with your company name and then the action.   You do not want to use he same commands that act is using.  You also want to use the overload that specifies the overload that allows you to set the category of the button.   This could cause other errors in the application if this value is not set.   The sample below can be stripped down and used in a plug in.    It provides a sample for CommandBarButton, BarLabel, CommandBarComboBox and CommandBarTextBox.  You can add CommandBarButton Items to CommandBarButtonItems.  I have never tested this with an Addin so I can not validate if it does actually work.

ActApplication actApplication;

#region IPlugin Members

public void OnLoad(ActApplication actApp){

this.actApplication = actApp;

this.actApplication.AfterLogon += new EventHandler(this.actApplication_AfterLogon);}

public void OnUnLoad(){

if (this.actApplication != null)

{

// Unregister from the events.

this.actApplication.AfterLogon -= new EventHandler(this.actApplication_AfterLogon);

}

this.cbtb = null;this.cbl = null;

}}

BarLabel cbl; CommandBarTextBox cbtb; CommandBarComboBox cbcb = null;

private void actApplication_AfterLogon(object sender, EventArgs e)

{

CommandBar theBar = null;

this.actApplication.ViewLoaded += new ViewEventHandler(actApplication_ViewLoaded);

if (this.actApplication.Explorer.CommandBarCollection["MenuToolbar Plugin"] == null)

{

// Add the bar.

theBar = actApplication.Explorer.CommandBarCollection.Add("MenuToolbar Plugin", CommandBarType.Toolbar);

actApplication.Explorer.CommandBarCollection.Add(theBar, true);

theBar.IsVisible = true;

theBar.BackColor = Color.Purple;

theBar.DNBar.CustomBar = true;

CommandBarButton cbb = new CommandBarButton("Custom Button", "Custom Button Tooltip", this.ButtonHandler, "Act.MenuToolbar.Tester.Button", Act.Shared.Images.ImageManager.GetIcon("call.ico"), CommandBarControl.ItemDisplayStyle.ImageAndText, false);

cbl = new BarLabel("Act.MenuToolbar.Tester.BarLabel");

cbcb = new CommandBarComboBox("Act.Menutoolbar.Test.ComboBox", "Custom Combobox Tooltip");

cbtb = new CommandBarTextBox("Act.Menutoolbar.Test.TextBox", "Custom Textbox Tooltip", string.Empty);

// Add items to the bar.

theBar.ControlCollection.Add(cbb);

theBar.ControlCollection.Add(cbl);

this.cbl.AllowCustomization = false;

this.cbl.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);

this.cbl.TextAlign = StringAlignment.Center;

this.cbl.BackColor = SystemColors.ControlLight;

cbl.ToolTip = "My MenuToolbar Label Tooltip";

theBar.ControlCollection.Add(cbtb);

theBar.ControlCollection.Add(cbcb);

cbcb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;

Items items = cbcb.Items;

cbcb.IsVisible = true;

int i = items.Add((string)"Item 1");

i = items.Add((string)"Item 2");

cbcb.ShortcutKeys = new Keys[] { System.Windows.Forms.Keys.ControlKey, System.Windows.Forms.Keys.F12 };

DevComponents.DotNetBar.ComboBoxItem dcCBI = cbcb.DNBBaseItem as DevComponents.DotNetBar.ComboBoxItem;

if (dcCBI != null)

{

dcCBI.Items.Add("Item xx");

}

}

else

{

// Find the items and hook the events.

theBar = this.actApplication.Explorer.CommandBarCollection["MenuToolbar Plugin"] as CommandBar;

if (theBar != null)

{

cbcb = theBar.ControlCollection["Act.Menutoolbar.Test.ComboBox"] as CommandBarComboBox;

cbcb.DropDownStyle = ComboBoxStyle.DropDownList;

cbl = theBar.ControlCollection["Act.MenuToolbar.Tester.BarLabel"] as BarLabel;

}

}

if (cbcb != null)

cbcb.Click += new CommandBarControl.ItemClicked(cbcb_Click);

if (cbl != null)

cbl.Click += new CommandBarControl.ItemClicked(cbl_Click);

}}

void actApplication_ViewLoaded(object sender, ViewEventArgs e)

{

// View was loaded so should be able to set the label text at this time.

this.cbl.Text = "View::" + e.View.InterfaceDisplayName();

this.cbl.Size = new Size(200, 20);

this.actApplication.Explorer.CommandBarCollection["MenuToolbar Plugin"].IsVisible = true;

}

void cbl_Click(object CommandBarControl, EventArgs e){MessageBox.Show("My Custom Label was clicked.");}

void cbcb_Click(object sender, EventArgs e)

{

if (this.cbl != null)

{

if (sender != null)

{

CommandBarComboBox cbcb = sender as CommandBarComboBox;

if (cbcb != null)

{

cbl.Text = ((DevComponents.DotNetBar.ComboBoxItem)cbcb.DNBBaseItem).SelectedItem.ToString();

}

}

}

}

#endregion

#region CommandBar event handlers

void ButtonHandler(object sender, EventArgs args)

{

cbcb.Items.Add("Item " + cbcb.Items.Count.ToString());

cbtb.ControlText = cbcb.Items.Count.ToString();

}

#endregion

void actApplication_BeforeLogoff(object sender, EventArgs e)

{

// Unregister from the loaded events.

}}



Message Edited by bhormann on 03-12-2008 04:12 PM
Tuned Listener
Posts: 29
Country: Canada

Re: Creating New Toolbar

Hey Jason,
 
 Thank you again for the time, you were very helpful.
 
About the product, you can see more information about in our website:
 
 
 I could get a toolbar going with the code sample sent. And as you have mentioned earlier, management gave priority to an Act commandbar, and if not possible will think about win app.
 
 Thanks for the help again.
 
 
Joe
.NET Developer
Tuned Listener
Posts: 29
Country: Canada

Re: Creating New Toolbar

[ Edited ]
Bhormann,
 
 Thank you very much for the helpful post, the code was very helpful and I could get a toolbar visible in ACT UI. I'll spend the rest of the day adding the necessary components and I'll make sure to post any problems or interesting issues I run into.
 
I had fun removing the smileys from the code though! Smiley Very Happy
 
 Thanks again!
 
 
Joe


Message Edited by hickins on 03-13-2008 07:29 AM
.NET Developer
Tuned Listener
Posts: 29
Country: Canada

Re: Creating New Toolbar

Guys,
 
 Ironically I added the toolbar, now I can't destroy it!!
 
This is now I created the toolbar:
 

private void AddMyMenu()

{

CommandBar myBar;

this.actApp.ViewLoaded += new ViewEventHandler(actApplication_ViewLoaded);

if (actApp.Explorer.CommandBarCollection[CUSTOM_MENU_TEXT] == null)

{

myBar = actApp.Explorer.CommandBarCollection.Add(CUSTOM_MENU_TEXT, CommandBarType.Toolbar);

actApp.Explorer.CommandBarCollection.Add(myBar, true);

myBar.BackColor = Color.Yellow;

myBar.CanUndock = true;

btnCall1 = new CommandBarButton("Call Button 1", "Call Button 1", null, "ConverTec.MenuToolbar.btnCall1", ACT_Test.Properties.Resources.wiz, CommandBarControl.ItemDisplayStyle.ImageAndText, true);

btnCall2 = new CommandBarButton("Call Button 2", "Call Button 2", null, "ConverTec.MenuToolbar.btnCall2", ACT_Test.Properties.Resources.wiz, CommandBarControl.ItemDisplayStyle.ImageAndText, true);

btnRelease = new CommandBarButton("Release", "Release", null, "ConverTec.MenuToolbar.Release", ACT_Test.Properties.Resources.wiz, CommandBarControl.ItemDisplayStyle.ImageAndText, true);

btnFind = new CommandBarButton("CRM Search", "Search for Contacts", null, "ConverTec.MenuToolbar.btnFind", ACT_Test.Properties.Resources.wiz, CommandBarControl.ItemDisplayStyle.ImageAndText, true);

btnCallHistory = new CommandBarButton("Call History", "Call History", null, "ConverTec.MenuToolbar.btnCallHistory", ACT_Test.Properties.Resources.wiz, CommandBarControl.ItemDisplayStyle.ImageAndText, true);

btnDND = new CommandBarButton("DND", "DND", null, "ConverTec.MenuToolbar.btnDND", ACT_Test.Properties.Resources.wiz, CommandBarControl.ItemDisplayStyle.ImageAndText, true);

cbStatus = new CommandBarComboBox("ConverTec.MenuToolbar.cbStatus", "System Notification");

btnSetup = new CommandBarButton("Setup", "Setup", null, "ConverTec.MenuToolbar.btnSetup", ACT_Test.Properties.Resources.wiz, CommandBarControl.ItemDisplayStyle.ImageAndText, true);

btnInfo = new CommandBarButton("Info", "Company Information", null, "ConverTec.MenuToolbar.btnInfo", ACT_Test.Properties.Resources.wiz, CommandBarControl.ItemDisplayStyle.ImageAndText, true);

btnHelp = new CommandBarButton("Help", "Help", null, "ConverTec.MenuToolbar.btnHelp", ACT_Test.Properties.Resources.wiz, CommandBarControl.ItemDisplayStyle.ImageAndText, true);

myBar.ControlCollection.Add(btnCall1);

myBar.ControlCollection.Add(btnCall2);

myBar.ControlCollection.Add(btnRelease);

myBar.ControlCollection.Add(btnFind);

myBar.ControlCollection.Add(btnCallHistory);

myBar.ControlCollection.Add(btnDND);

myBar.ControlCollection.Add(cbStatus);

myBar.ControlCollection.Add(btnSetup);

myBar.ControlCollection.Add(btnInfo);

myBar.ControlCollection.Add(btnHelp);

//btnCall1.Text = "BOB CLINTON (905) 469-1200"; // test

}

}

 and this is the method that I used to destroy the commandbar, but it does not work!!!

private void RemoveMenuItem(string name)

{

CommandBar myBar = actApp.Explorer.CommandBarCollection[name] ;

if (myBar != null)

{

CommandBarControls controls = myBar.ControlCollection;

int i = 0;

foreach (CommandBarControl cont in controls)

{

//actApp.Explorer.CommandBarCollection[name].ControlCollection[i].RemoveSubItem(cont);

actApp.Explorer.CommandBarCollection[name].ControlCollection[cont.Command].RemoveSubItem(cont);

cont.Dispose();

i++; // I used i indexer to reference the control instead of cont.Command and it did not work either!

}

btnCall1 = btnCall2 = btnCallHistory = btnDND = btnFind = btnHelp = btnInfo = btnRelease = btnSetup = null;

cbStatus = null;

myBar = null;

}

}

 What is wrong am i doing?

Thank you!

Joe

.NET Developer