14 Replies Latest reply on Aug 21, 2014 6:12 PM by Gregor

    Display Shrinkage

    scm0094

      I have two ProcessBook displays (version 3.2.3.0) that I've built in which one references the other in order to share a VBA function between them.  The problem is that the referenced display persistently tries to zoom to 37%.  I have commands in the VBA in both startup and data update, but it continues to revert to 37%.  Even when it stays at 100% the zoom dropdown in the toolbar says 37% (see attached pictures).  This is extremely annoying and frustrating.  Has anyone seen this issue...and found an antidote?  Initially this was only happening to the referenced display, but now it is happening to both.  I don't have this problem with any of the other hundreds of displays I've built.  The problem only seems to exist when I reference a display from another display.

       

       

       

      3113.titled.jpg

       

       

       

      3463.titled2.jpg

        • Re: Display Shrinkage
          matthew.rivett

          Is there maybe a black item on black you can't see?  Maybe try a Ctrl-A to select all items and see.

            • Re: Display Shrinkage

              Does the VBA code contain something like .Zoom = 37 or in case Matt's suspicion is right .Zoom="Fit all"?

                • Re: Display Shrinkage
                  scm0094

                  I checked for unseen items...none.  Which I suspected since when I manually zoom to "Fit All" it zooms correctly.  There are instances of zoom = "Fit all" in the code, but I've tested with zoom = 100 (and other zoom percentages) and the same thing happens.  There are no zoom = 37 in the code.

                    • Re: Display Shrinkage

                      Hello Shawn,

                       

                      I understand the issue only occurs with the specific code in display1 when either called from display1 or display2. Other displays do not show this annoying behavior. This makes me conclude the behavior is coming from the VBA code inside display1.

                       

                      Can you try narrowing the line of code causing the issue by using breakpoints? Please post the "responsible" lines of code.

                        • Re: Display Shrinkage
                          scm0094

                          I'm 99.9% certain that it has nothing to do with the VBA code.  Recently the shrinkage activity has occurred in both display1 and display2.  At one point I was only using code that was in many other displays that I have used for many years with no issues.  It seems to be an OSISoft "feature" that occurs when you link two displays through the use of a VBA reference.

                            • Re: Display Shrinkage
                              scm0094

                              Gregor,

                               

                              I stepped through the code using debugger and the 30% is getting triggered at the initiation of Display_DataUpdate.  It triggers before the first line of code in that subroutine.  Not sure if that helps or not.

                               

                              Thanks,

                               

                              Shawn

                                • Re: Display Shrinkage
                                  scm0094

                                  Gregor,

                                   

                                  After more sleuthing I discovered that this only seems to happen when ThisDisplay.Zoom = "FitAll" is included in Display_DataUpdate of the referenced display.  My work around can be to not use that command in that subroutine.  It's still a mystery though.

                                   

                                  Shawn

                                    • Re: Display Shrinkage

                                      Hello Shawn,

                                       

                                      I've done some testing in the meantime too with a very simple VBA example trying to find a proof for your suspicion that there's a bug that would cause the behavior you observed. I can attach this example and we can use it as a starting basis if you like to investigate further into the direction of a possible bug.

                                       

                                      After reading your latest post, my impression is that you've identified the cause. I also feel that Matt was right with his suspicion. To proof this, I suggest disabling VBA code execution through ProcBook.ini file by setting MacroProtectionLevel = 2 within the [Startup] section. Afterwards open your Display2 and set the Zoom to i.e. 100% and afterwards try "Fit all symbols" through menu "View" -> "Zoom ..." Does the result match with the observation you've made before?

                                        • Re: Display Shrinkage
                                          scm0094

                                          Okay.  I changed my ProcBook.ini file using MacroProtectionLevel = 2, then I disabled the macros when the displays opened.  I then zoomed to 100% then zoomed to "Fit all symbols" using the menu.  Doing this the zoom acted correctly (not going to 30%).  One item to note...if when the displays opened I chose to enable macros, the display immediately went to 30%.

                                            • Re: Display Shrinkage

                                              Hello Shawn,

                                               

                                              Shawn Martin

                                              I changed my ProcBook.ini file using MacroProtectionLevel = 2, then I disabled the macros when the displays opened

                                               

                                              Setting MacroProtectionLevel=2 should have disabled macros. However, my feeling is we are somehow stuck, I'll contact you by email and ask you for the displays. 

                                                • Re: Display Shrinkage

                                                  Hello Shawn,

                                                   

                                                  Thank you for sending the files. After disabling some of your routines that do not work in my environment, I was able to reproduce the behavior you describe for the reference display. I found 

                                                   
                                                  ThisDisplay.Zoom = "FitAll"
                                                  

                                                  at several places within both displays. I commented all occurrences and the issue was gone. The next thing to do was to find out what occurrence is causing the behavior. My suspicion was the occurrence within function Get_Constraints in the module of the reference display. Commenting out this function caused that the reference display still zoomed to about 30% but when bringing it to front, the "FitAll" within the Display.DataUpdate handler took care for an appropriate view with the next DataUpdate event. I used try and error method to figure out that the reference display shows correct. 

                                                   

                                                  Please see if the following changes in the reference display work for you too (please note I am leaving out some of your comments): 

                                                   
                                                  Public Function Get_Constraints(intC As Integer, intM As Integer, intP As Integer) As Double
                                                      ' ThisDisplay.Zoom = "FitAll"
                                                  

                                                   

                                                   
                                                  Private Sub Display_DataUpdate()
                                                      ' ThisDisplay.Zoom = "FitAll"
                                                  

                                                  By default DataUpdate fires each 5 seconds. It shouldn't be necessary to do a "FitAll" with every DataUpdate. Also, to "recycle" code, I suggest using libraries. If you prefer using a display for this purpose, please consider using it as pure "library" display that just contains the VBA code but no symbols. The usage of "ThisDisplay" is from my point of view no clear definition of what display it refers to when called from one display but existent in the other (the reference) display.

                                                   

                                                   

                                                   

                                                   

                                                    • Re: Display Shrinkage
                                                      scm0094

                                                      Gregor,

                                                       

                                                      The "FitAll" in the DataUpdate was placed there only because of this issue.  It's not my normal coding.  You suggest using libraries.  Can you point me to somewhere that I can read about that.  I don't know anything about libraries, but it sounds intriguing.  Also, I agree with the statement about "ThisDisplay" having no clear definition in this case.  Is there a way to specify exactly which display in the code I'm referring to rather than using "ThisDisplay"?

                                                       

                                                      Thanks,

                                                       

                                                      Shawn

                                                       

                                                       

                                                        • Re: Display Shrinkage
                                                          dhollebeek

                                                          You can use the Application.Displays collection, but other than indexing it by number, I don't remember if it's indexed by path or display name.

                                                           

                                                          :D

                                                          • Re: Display Shrinkage

                                                            Hello Shawn,

                                                             

                                                            Shawn Martin

                                                            Can you point me to somewhere that I can read about that.

                                                             

                                                            ProcessBook offers Visual Basic for Application (VBA) as programming interface. The interface is what you may know from Microsoft Excel or Microsoft Word and supports object libraries (.OLB), type libraries (.TLB) and DLL's. I thought it would be possible to just create a VBA project and save the content as object or type library but this doesn't appear the case. I did some research and found that object libraries are created for COM objects and type libraries when creating an ATL project using Visual C++. I believe this is not what you want nor what you need here and hence suggest you create a ProcessBook "Library" Display with just the VBA project inside.

                                                             

                                                            To complement the information provided by David, please look at the following example on how to match up the index of open Displays with the Path information:

                                                             
                                                            Private Sub Trend1_Click(ByVal lvarX As Long, ByVal lvarY As Long)
                                                                Dim iIndex As Integer
                                                                Dim sMsg As String
                                                                For iIndex = 1 To Application.Displays.Count
                                                                    sMsg = "Display # " + Str(iIndex) + " is "
                                                                    sMsg = sMsg + Application.Displays.Item(iIndex).Path
                                                                    MsgBox sMsg
                                                                Next
                                                            End Sub
                                                            

                                                            With 

                                                             
                                                            Application.ActiveDisplay.Path
                                                            

                                                            you get the name of the Active Display and would be able to get it's index before calling a function within your "Library" display.