Toolbar and Button Creation

Creating a Toolbar with a Button

  • Toolbar and Button Declarations:
NktWLMailApi.Toolbar newToolbar;
       int newToolbarID ; //This will be used to tell the button the ID of the toolbar where we want to create it.
       NktWLMailApi.ToolbarButton newButton;

  • Create Toolbars and Buttons On Windows Live Mail Init ( This is a requirement, all Toolbars and Buttons should be created in this event ):
       
private void OnInitWLMailApi()
       {
           wlmailApiCore = new NktWLMailApi.WLMailApi();
           wlmailApiId = wlmailApiCore.GetID();

Toolbar Creation:
       
newToolbar= new NktWLMailApi.Toolbar();
           newToolbar.Create("Toolbar Name", wlmailApiId);
           newToolbarID = newToolbar.GetID();

Button Creation:
           
newButton = new NktWLMailApi.ToolbarButton();
           newButton.Create(newToolbarID, "Button Name", "ImagePath", "", 0); // Leave ImagePath empty if you dont have an image.
           newButton.OnClick += new NktWLMailApi.IToolbarButtonEvents_OnClickEventHandler(EventFunction);
       }

Creating a Button in the Home Toolbar (Only Windows Live Mail 15 (2011)

  • Using the same Toolbar and Button Declarations as before.
  • Create Toolbars and Buttons On Windows Live Mail Init:

private void OnInitWLMailApi()
       {
           wlmailApiCore = new NktWLMailApi.WLMailApi();
           wlmailApiId = wlmailApiCore.GetID();

Get Home Toolbar as newToolbar:

// Check Windows Live Mail Version
           if (wlmailApiCore.GetClientVersion() == 15)
           {
               newToolbar= wlmailApiCore.GetDefaultToolbar(0);
               newToolbarID = newToolbar.GetID();
           }

Button Creation (stills the same):

newButton = new NktWLMailApi.ToolbarButton();
           newButton.Create(newToolbarID, "Button Name", "ImagePath", "", 0); // Leave ImagePath empty if you dont have an image.
           newButton.OnClick += new NktWLMailApi.IToolbarButtonEvents_OnClickEventHandler(EventFunction);
       }

Create a Button with SubButtons

  • Using the same Toolbar and Button Declarations as before add one more:
NktWLMailApi.Toolbar newToolbar;
       int newToolbarID ; //This will be used to tell the button the ID of the toolbar where we want to create it.
       NktWLMailApi.ToolbarButton newButton;
       NktWLMailApi.ToolbarButton newSubButton;

  • Create Toolbars and Buttons On Windows Live Mail Init as before with this changes:
Button Creation:

newButton = new NktWLMailApi.ToolbarButton();
           newButton.Create(newToolbarID, "Button Name", "ImagePath", "", 1); // Changed 4th value from 0 to 1
           // Buttons with Sub Buttons can't have Click Events.
           // newButton.OnClick += new NktWLMailApi.IToolbarButtonEvents_OnClickEventHandler(EventFunction);

SubButton Creation:

newSubButton = newButton .CreateSubButton("Sub Button Name", "ImagePath", "", 0);
           newSubButton.OnClick += new NktWLMailApi.IToolbarButtonEvents_OnClickEventHandler(EventFunction);
       }






Comments