4 Replies Latest reply on Apr 11, 2011 1:29 PM by spilon

    Resetting Processbook After hiding the toolbars


      I run the display_open VBA code that is listed below when I open processbook displays that I want to be read only and are meant for operators who do not need to change anything. This works out great but then the processbook will retain the hidden menu bars on the next time that processbook is opened, even if I just open processbook with no display. I am looking for a clean way around this. I tried the following listed in the Display_BeforeClose event but I get a bunch of duplicated menu bars which is pretty ugly:


      1) Is there something that can be done in the ini or a better solution when closing one of these displays? The ini file seemed to be the best approach if possibly.


      2) I also have one other issue, I would like to also close the browser and playback menu bars. They do not close as part of the  Application.CommandBars.Item(i).Visible = False loop. Is there a solution for that?


      3) and one more (sorry) for the main menu bar (file edit view ....), is there a way to keep just that one open and close everything else? Maybe I can close everything and reopen just the main menu bar but I do not know how to reference it.


      Thank you so much for your help on this....

      //code ran when display is clsoed that is not working to well
      Private Sub Display_BeforeClose(bCancelDefault As Boolean)
      For i = 1 To Application.CommandBars.Count
      ' need to fix this!!! it makes several menu bars duplicated!!!!!!
          Application.CommandBars.Item(i).Visible = True
       Next i
      End Sub
      //code ran when display is opened
      Private Sub Display_Open()
      For i = 1 To Application.CommandBars.Count
          Application.CommandBars.Item(i).Visible = False
       Next i
      Me.Zoom = "FitAll"
      'set it runmode
      If Not Application.RunMode Then
      Application.RunMode = True
      End If
      End Sub


        • Re: Resetting Processbook After hiding the toolbars

          Hi Mike,


          Can you elaborate which are the toolbars that are duplicated? I've tried out your code and there is an instant that a number of menu bars appears at the same time, but disappearing in the next split second. The reason is probably because there are a few different menu bars available, and only 1 should be active, hence the other menu bar auto-hide themselves. Other than that it seems to work fine for me.


          To answer your questions

          1. I am not aware of any configurations in the ini file for this. Let's see what others on the community have to say about this.
          2. The browser and playback bars are actually part of a docking window instead of toolbars, so to hide it, it would be something like:
            Dim iDockWindows As Integer
            For iDockWindows = 1 To Me.Application.DockWindows.Count
                Dim oDockWindow As PBDockWindow
                Set oDockWindow = Me.Application.DockWindows.Item(iDockWindows)
                If oDockWindow.Title = "Toolbar Manager" Then
                    oDockWindow.Visible = False
                End If
          3. Again there are a few menu bars, you can reference to, here's how to leave the default menu bar on:
            For i = 1 To Application.CommandBars.Count
               'MsgBox Application.CommandBars.Item(i).Name
               If Application.CommandBars.Item(i).Name = "Default Menu Bar" Then
               Application.CommandBars.Item(i).Visible = True
                Application.CommandBars.Item(i).Visible = False
               End If
             Next i
            The other menu bars that you can use are Book Menu Bar, Display Menu Bar, View-Only Book Menu Bar and View-Only Display Menu Bar 
            • Re: Resetting Processbook After hiding the toolbars

              Thanks Han


              It is the Default menu bar (the menu bar that has File   Edit   view ....) at the very top that gets duplicated. I have seen this behavior on at least 2 different machines running It looks like that for every command bar that is made visible again, the default menu bar is duplicated. When you tried this, was the default menu bar hidden? It has been pretty repeatable for me.


              An ini solution if it is possible I feel would be interesting and robust solution. Hiding these command bars with the addition of using the fit all is extremely powerful in providing the best presentation in many cases where editing is not needed or is desired.


              Thanks again.

                • Re: Resetting Processbook After hiding the toolbars

                  The reason there are 3 "default" menu bars is dependent on what file you have open. If you've opened a PIW file, the "Book Menu Bar" will be displayed. If a PDI file is opened, then the "Display Menu Bar" will be displayed. If no file is opened then "Default".


                  Also, there is an INI setting to put ProcessBook in a "read-only" mode.


                  Inserting ProcessBook=PRIMARY under the [StartUp] section in the procbook.ini allows users on a network to view ProcessBooks, but not change them.  The user will have access to the Standard Toolbar, including trend displays, but cannot  save an ad hoc display.


                  Using this setting along with your VBA code with additional conditions to only show or hide the Display Menu Bar should give you what you're looking for.


                  Good Luck!