Highlighted

Adding a button to the toolbar

Avatar

Guest

05-02-2009

I am having some trouble with a custom toolbar button. I add the button in a Reader plug-in with no problems:



> //Create a AVIcon object



> AVIcon myIcon = (AVCursor)LoadBitmap(gHINSTANCE, MAKEINTRESOURCE(Save_BMP));



> //Create a new button



> AVToolButton MyButton = AVToolButtonNew (ASAtomFromString("Test"), myIcon, FALSE, FALSE);

AVToolButtonSetHelpText(MyButton, "Test tooltip");



> //Retrieve the File toolbar



> const char * toolbarName= "File";

> AVToolBar ToolBar = AVAppGetToolBarByName(toolbarName);



> //Attach the button



> AVToolBarAddButton(ToolBar, MyButton, FALSE, NULL);



However, if a user has customized the toolbar eg. with e-mail and search buttons, my custom button only shows up in the first instance of Reader. If the user opens a second PDF document, the button is not visible in the new Reader window.



I have tried removing the button and adding it again, but this results in two buttons in the first instance and a single button in the second instance.



Should I add the button in another way to solve this? Using a javascript file perhaps? I have experimented with a trusted function in a .js file, but I could not figure it out - nor find a fitting example.