Forum rules DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
I am trying to add the Comments and Markup Tools Menu to a custom menu bar. I am able to move the cmd cmd.tools.markup to the custom bar, change the title, and add an icon, but the drop down does nothing if hovering over or clicking. Below is the code I'm using.
And this is what the custom bar looks like. The "Annotations" button/drop down looks like it should work with the little triangle, but then nothing happens. Could you provide an example of how to achieve this? I appreciate all your help.
Thanks Alex. I have this figured out now. I'll leave the full code on getting the menu setup like I have in the previous screenshot. Hopefully this will help someone in the future.
private void showDocViewToolbar()
{
PDFXEditor.Inst.LockCmdCustomizationEvent();
uiInst.CmdManager.LockAllPanesUpdates();
//This has to be called in order to show any menu/cmd bars
PDFXEditor.VisibleCmdPanes = (uint)PDFXEdit.PXV_VisibleCmdPanes.PXV_VisibleCmdPanes_All;
ShowAllCmds();
InitialHideMainMenus();
//only show the menu bar
PDFXEdit.IUIX_Cmd cmd;
ShowCmdBar("cmdbar.menubar", true);//show the menu bar
ShowCmdBar("cmdbar.file", false);
ShowCmdBar("cmdbar.file", false);
ShowCmdBar("cmdbar.standard", false);
ShowCmdBar("cmdbar.properties", false);
ShowCmdBar("cmdbar.commenting", false);
ShowCmdBar("cmdbar.contentEditing", false);
ShowCmdBar("cmdbar.measurement", false);
ShowCmdBar("cmdbar.view", false);
ShowCmdBar("cmdbar.form", false);
//prevents user from customizing toolbar and bringing back menu items that they shouldn't use cmd.save
cmd = GetIUIX_Cmd("cmd.view.lockUnlockAllCmdPanes");
ExecuteIUIX_Cmd(cmd.ID);
cmd = GetIUIX_Cmd("cmd.view.lockUnlockAllCmdBars");
ExecuteIUIX_Cmd(cmd.ID);
//if true then user can't use right click. is prevented in the OnEvent event
isRightClickContextMenuEnabled = false;
cmd = GetIUIX_Cmd("cmd.save");
cmd.Hidden = true;
cmd = GetIUIX_Cmd("cmd.find");
cmd.Hidden = true;
cmd = GetIUIX_Cmd("cmd.open");
cmd.Hidden = true;
cmd = GetIUIX_Cmd("cmd.newDoc");
cmd.Hidden = true;
cmd = GetIUIX_Cmd("cmd.view.toolbars");
cmd.Hidden = true;
cmd = GetIUIX_Cmd("cmd.document");
cmd.Hidden = true;
cmd = GetIUIX_Cmd("cmd.saveCopyAs");
cmd.Hidden = true;
GetIUIX_Cmd("cmd.openFrom").Hidden = true;
var rect = new tagRECT
{
top = 100,
left = 100
};
rect.bottom = rect.top + 25;
rect.right = rect.left + 100;
var cusCmdBar = uiInst.CreateCmdBar(PDFXEditor.Inst.ActiveMainView.Obj, rect, "124", "CustomBar");
var newbox = cusCmdBar.InsertNewBox("Custom");
newbox.ItemsLowerSize = UIX_CmdItemSize.UIX_CmdItemSize_Small;
newbox.ItemsIdealSize = UIX_CmdItemSize.UIX_CmdItemSize_Medium;
cmd = GetIUIX_Cmd("cmd.saveAs");
cmd.SetTitle(0, "Export...");
newbox.InsertItem(cmd, 0);
cmd = GetIUIX_Cmd("cmd.print");
newbox.InsertItem(cmd);
cmd = GetIUIX_Cmd("cmd.zoom.level.actual");
newbox.InsertItem(cmd);
cmd = GetIUIX_Cmd("cmd.zoom.level.fitWidth");
newbox.InsertItem(cmd);
cmd = GetIUIX_Cmd("cmd.zoom.level.fitPage");
newbox.InsertItem(cmd);
//create the Annotations Drop down button right after fit page
cmd = GetIUIX_Cmd("cmd.tools.markup");
//change title to Annotations instead of Comments and Markup Tools
cmd.SetTitle(0, "Annotations");
var cmd2 = GetIUIX_Cmd("cmd.tool.annot.stickyNote");
//add the sticky note icon to the new Annotations
cmd.Icon = cmd2.Icon;
//get the main cmd bar
IUIX_CmdBar cmdBar = PDFXEditor.Inst.ActiveMainFrm.View.MenuBar;
//find the index of the tools menu
int flatIndex = cmdBar.FlatFindFirstItemByCmdName("cmd.tools");
//find the cmd tools CmdItem from the tools index
IUIX_CmdItem cmdTools = cmdBar.FlatGetItem(flatIndex);
//the menu of the cmd tools item
IUIX_CmdMenu cmdToolsMenu = cmdTools.SubMenu;
//get the cmd.tools.markup menu index
int menuIndex = cmdToolsMenu.FindFirstItemByCmdName("cmd.tools.markup");
//get the CmdMenu from the CmdToolsMenu
IUIX_CmdMenu cmdToolsMarkupMenu = cmdToolsMenu[(uint)menuIndex];
//create the new cmd menu
var cmdAnnotsEditMenu = uiInst.CreateCmdMenu();
//copy all the items from the tools markup cmd menu to the new annots edit menu
cmdAnnotsEditMenu.CopyItemsFrom(cmdToolsMarkupMenu);
//insert the new cmd to the newBox
newbox.InsertItem(cmd);
//get the new annots menu item from the cmd id
var cmdAnnotsEditMenuItem = cusCmdBar.FindFirstItemByCmdID(cmd.ID);
//set the sub menu of the menu item to the annots edit menu
cmdAnnotsEditMenuItem.SubMenu = cmdAnnotsEditMenu;
PDFXEdit.IUIX_CmdBar cmdBarQuickFind = mainFrame.View.CmdBar["cmdbar.quickFind"]; //Quick Find Bar
cmdBarQuickFind.Line.InsertBar(cusCmdBar, 0);
uiInst.CmdManager.UnlockAllPanesUpdates();
PDFXEditor.Inst.UnlockCmdCustomizationEvent();
}
public PDFXEdit.IUIX_Cmd GetIUIX_Cmd(string cmd)
{
return uiInst.CmdManager.Cmds.Find(cmd);
}
public void ShowCmdBar(string cmd, bool bShow)
{
if (bShow)
{
mainFrame.View.CmdBar[cmd].Show();
}
else
{
mainFrame.View.CmdBar[cmd].Hide();
}
}
public void ShowAllCmds()
{
foreach (IUIX_Cmd cmd in uiInst.CmdManager.Cmds)
{
cmd.Hidden = false;
}
}