2 Replies Latest reply on Mar 16, 2012 7:14 PM by fabior

    PBCommandBarPopup: Event does not start

    fabior

      Hi everyone,

       

      I am having a problem when dealing with a PBCommandBarPopup that I have inan add-in. The problem isthat I got the items/buttons, but the eventhandler seems not to be working or sth like this as nothing happens when I click inany of the itens. Here isthe code so that you can have a clue about.

       

       
      private PBObjLib.PBCommandBar cmBar;
      private PBObjLib.PBCommandBarControls cmBarControls;
      private PBObjLib.PBCommandBarPopup cmBarScrollControlBar;
      private PBObjLib.PBCommandBarButton cmBarControlLogo;
      
      private void AddScrollButtonToolBar()
      {
           this.cmBar = this.app.CommandBars.Item(AppUtil.ADDIN_NOME);
      
           if (this.cmBar == null)
           {
                this.app.CommandBars.Add(AppUtil.ADDIN_NOME, 1, false, false);
                this.cmBar = this.app.CommandBars.Item(AppUtil.ADDIN_NOME);
                this.cmBarControls = (PBObjLib.PBCommandBarControls)this.cmBar.Controls;
      
                this.cmBarControlLogo = (PBObjLib.PBCommandBarButton)this.cmBarControls.Add((object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false);
                this.cmBarControlLogo.ToolTipText = "";
                this.cmBarControlLogo.Style = pbButtonStyle.pbButtonIcon;
                this.cmBarControlLogo.LoadFace("giop_dsvazao_petrobras.bmp");
      
                // Adiciona o Scroll
                this.cmBarScrollControlBar = (PBObjLib.PBCommandBarPopup)this.cmBarControls.Add((object)PBObjLib.pbControlType.pbControlPopup, 1, null, null, false);
                this.cmBarScrollControlBar.ToolTipText = AppUtil.ADDIN_SCROLL_BAR_NOME;
                this.cmBarScrollControlBar.Caption = AppUtil.ADDIN_NOME;
                this.cmBarScrollControlBar.Enabled = true;
                this.cmBarScrollControlBar.Controls.Add((object)PBObjLib.pbControlType.pbControlButton, 1, null, null, false);
                this.cmBarScrollControlBar.Controls.Add((object)PBObjLib.pbControlType.pbControlButton, 2, null, null, false);
                this.cmBarScrollControlBar.Controls.Add((object)PBObjLib.pbControlType.pbControlButton, 3, null, null, false);
      
                // Altera propriedades dos itens de menu
                this.cmBarScrollControlBar.Controls.Item(1).ToolTipText = AppUtil.ADDIN_SCROLL_BAR_COPIAR_NOME;
                this.cmBarScrollControlBar.Controls.Item(1).Caption = AppUtil.ADDIN_SCROLL_BAR_COPIAR_CAPTION;
                this.cmBarScrollControlBar.Controls.Item(1).Enabled = true;
      
                this.cmBarScrollControlBar.Controls.Item(2).ToolTipText = AppUtil.ADDIN_SCROLL_BAR_IMPORTAR_NOME;
                this.cmBarScrollControlBar.Controls.Item(2).Caption = AppUtil.ADDIN_SCROLL_BAR_IMPORTAR_CAPTION;
                this.cmBarScrollControlBar.Controls.Item(3).Enabled = true;
      
                this.cmBarScrollControlBar.Controls.Item(3).ToolTipText = AppUtil.ADDIN_SCROLL_BAR_EXPORTAR_NOME;
                this.cmBarScrollControlBar.Controls.Item(3).Caption = AppUtil.ADDIN_SCROLL_BAR_EXPORTAR_CAPTION;
                this.cmBarScrollControlBar.Controls.Item(3).Enabled = true;
           }
      
           // Altera propriedades do Command Bar
           this.cmBar.Enabled = true;
           this.cmBar.Visible = true;
      
           // Adiciona os controles no Scroll
           this.cmBarControls = (PBObjLib.PBCommandBarControls)this.cmBar.Controls;
           this.cmBarScrollControlBar = (PBObjLib.PBCommandBarPopup)this.cmBarControls.Item(AppUtil.ADDIN_NOME);
           ((ECommandBarButtonEvents_Event)this.cmBarScrollControlBar.Controls.Item(1)).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(tagSimController.AddInCopiarClicked);
           ((ECommandBarButtonEvents_Event)this.cmBarScrollControlBar.Controls.Item(2)).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(tagSimController.AddInImportarDadosClicked);
           ((ECommandBarButtonEvents_Event)this.cmBarScrollControlBar.Controls.Item(3)).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(tagSimController.AddInExportarClicked);
      }
      

       

       

      Thanks,

       

      Fábio Reis

        • Re: PBCommandBarPopup: Event does not start
          andreas

          Hi Fabio,

           

          Could you try to debug your addin - just run the debugger and the first thing when PB shows up you should do is clicking on your buttons. This should work.

           

          To keep it working afterwards, I have done the following:

           

          1. I have added an array of your controls in the class

           
          private PBObjLib.PBCommandBarControl[] cmBarControl;
          

           2. When creating the scroll bar you will have to initialize the array:

           
          cmBarControl = new PBObjLib.PBCommandBarControl[3];
          

           3. When creating the buttons you fill the array:

           
          cmBarControl[0] = (PBObjLib.PBCommandBarControl)this.commandBarControls.Add((object)PBObjLib.pbControlType.pbControlButton, null, null, null, false);
          

           4. and finally creating the eventhandlers would be something like

           
          ((ECommandBarButtonEvents_Event)cmBarControl[0]).Click += new PBObjLib.ECommandBarButtonEvents_ClickEventHandler(this.Item1Clicked);
          

           

           

          Hope this helps.