This interface lets you create a plug-in that adds a menu to the library window menu bar. For example, you can add a menu containing commands specific to your integration with HotDocs.
When HotDocs starts up, it attempts to load each registered plug-in. If it finds a plug-in that implements the ILibraryWindowMenuExtension interface, HotDocs calls:
When a user selects your plug-in's menu, HotDocs then calls:
Finally, when a user selects an entry from your plug-in's menu, HotDocs calls Command and passes it information about which library entries are selected (if any).
| Function | Description |
Command |
This function is called when a user selects one of the entries in your plug-in's library window menu. If the user has a library entry selected when this function is called, HotDocs passes information about the selected entry to this function so your plug-in can perform an action based on the selected entry as needed. |
DisplayMenuInitialize |
This function initializes your plug-in's library window menu. HotDocs calls this function each time the user accesses your plug-in's menu, which allows it to behave differently depending on which library is currently open or which items are currently selected in the library. |
GetMenuEntry |
This function retrieves the commands that will appear on your plug-in's library window menu. HotDocs calls it repeatedly until it fails, or until menuText is an empty string (""). |
GetMenuTitle |
This function retrieves the title for your plug-in's library window menu. If it fails, or if the text returned is an empty string (""), HotDocs will not display the menu. |
Initialize |
This function is called when HotDocs starts up to determine if it should load the plug-in. If the function fails, HotDocs will not load the plug-in. |
LibraryInitialized |
This function is called when the library is initialized. |
The following Visual C# example implements the ILibraryWindowMenuExtension interface to create a custom library window menu bar plug-in.
[ComVisible(true)]
[Guid("12345678-1111-2222-AAAA-DDDDDDDDDDDD")]
public class WindowMenuExt : HotDocs.ILibraryWindowMenuExtension
{
public void Command(string libraryPath, LibraryEntity caretEntry, int commandId)
{
if (commandId == cmd1)
System.Diagnostics.Process.Start("http://www.hotdocs.com");
if (commandId == cmd2)
MessageBox.Show("Menu sample w/icon selected");
}
public void DisplayMenuInitialize(string libraryPath, LibraryEntity caretEntry)
{
MessageBox.Show(caretEntry.Title);
}
public void GetMenuEntry(int menuPosition, ref string menuText, ref Icon Icon, ref bool enabled, ref bool callAgain, int commandId)
{
HotDocs.Icon icon = new Icon();
icon.LoadIcon(@"C:\images\MenuEntry.ico");
switch (menuPosition)
{
case 0:
menuText = "HotDocs Website";
enabled = true;
callAgain = true;
cmd1 = commandId;
break;
case 1:
//Add a separator
menuText = "-";
enabled = false;
break;
case 2:
menuText = "Menu Sample w/icon";
Icon = icon;
enabled = true;
callAgain = false;
cmd2 = commandId;
break;
default:
break;
}
}
public void GetMenuTitle(ref string menuTitle)
{
menuTitle = "Menu Ext Plugin";
}
public void Initialize()
{
//Do any one time initialization
}
public void LibraryInitialized()
{
MessageBox.Show("The library has been initialized");
}
[ComRegisterFunction]
public static void RegisterPlugin(Type t)
{
HotDocs.Application app = new HotDocs.Application();
app.Plugins.Register("{12345678-1111-2222-AAAA-DDDDDDDDDDDD}", "Sample Menu Plugin", 100, 1);
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
}
[ComUnregisterFunction]
public static void UnRegisterPlugin(Type t)
{
HotDocs.Application app = new HotDocs.Application();
app.Plugins.Unregister("{12345678-1111-2222-AAAA-DDDDDDDDDDDD}");
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
}
}