7 Replies Latest reply on Apr 12, 2018 10:32 PM by arvek

    VBA: How to detect a SizeChanged event

    arvek

      Hi,

      In one of my Display's, I have set the zoom to FitAll.

       

      Is there a way to trigger the zoom again if the user changes the size of his processbook form?

       

      There is a Display_size event available, but I can't figure out what it does, and I can also not

      find any information about it.

       

      There doesn't seem to be any proper events in the Application class(??) either...

       

      Basically what I want, is something similar to the .Net's SizeChanged event.

        • Re: VBA: How to detect a SizeChanged event
          John Messinger

          Hi Arve,

           

          It sounds like the Display_Size event handler is what you're looking for. The PI ProcessBook Programmer Reference Guide describes this as follows:

          You could set the Display.Zoom property from within this event handler.

           

          John

          1 of 1 people found this helpful
          • Re: VBA: How to detect a SizeChanged event
            arvek

            John,

             

            I want all the symbols in my display to be visible all the time and also fill all the available client area in the Processbook application, regardless of the size of the processbook window. For instance, if I or one of my colleagues resize or maximize the processbook window, I would like my display to zoom to "FitAll".

             

            I set the Me.Zoom = "FitAll" in the Display_Open event, and that works as it should. But sometimes the Processbook application is not opened in a maximized state, and then when someone open the display in that book, the display would fit all symbols as it should for the current Processbook window size, but when the maximize button next to the Close button on the Processbook toolbar is clicked, the display won't be "FitAll" anymore. And this is the part where I would like Display_Size event to fire, so that I could also put the Me.Zoom = "FitAll code into that event to make sure the symbols in my display will once again make use of the whole client area in the Processbook window

            -------

            Sadly, english is not my native language, so it is a bit hard to describe. Should my issue still not be clear, I will add some images

             

            If possible, could you try for yourself if you can get that event to trigger. I am almost sure my company got the latest version of Processbook (2015 RC2 if i remember correctly), but still something of course could be broken with our software.

             

            Regards,

            Arve

              • Re: VBA: How to detect a SizeChanged event
                John Messinger

                Hi Arve,

                 

                I just tried this out on my work PC, using ProcessBook 2015 R2 SP1, and had no problems making this work as expected. My code is as follows:

                 

                Private Sub Display_Open()
                
                    ThisDisplay.Zoom = "FitAll"
                        
                End Sub
                
                
                Private Sub Display_Size(ByVal lWidth As Long, ByVal lHeight As Long, ByVal lDeltaX As Long, ByVal lDeltaY As Long)
                
                    ThisDisplay.Zoom = "FitAll"
                    
                End Sub
                

                 

                This worked for me in the following scenarios:

                1. ProcessBook application opens in maximised state, and display window opens in maximised state

                2. ProcessBook application opens in maximised state, and display window opens in non-maximised state

                3. ProcessBook application opens in non-maximised state, and display window opens in maximised state (within main application window)

                4. ProcessBook application opens in non-maximised state, and display window opens in non-maximised state

                 

                Resizing either the application window or the display window caused the Size event to fire (and my display Zoom property to be updated) as expected.

                 

                Do you see the same behaviour if you open the display on a different PC?

                 

                Cheers,

                John

              • Re: VBA: How to detect a SizeChanged event
                arvek

                Hi John,

                 

                Thanks for taking the time to do the research.

                 

                For some weird reasons, all new displays I made today triggered the Size event normally, in all the scenarios you listed, but none of my existing display, or displays made by other people, triggers the even in the same scenarios.

                 

                I don't know how to proceed with this, it's not that it's a deal breaker that I am unable adjust the zoom level, but surely it would be a nice feature to implement

                 

                - Arve

                • Re: VBA: How to detect a SizeChanged event
                  arvek

                  Ok, so I got an update on this.

                   

                  Apperantly, Display's that are embedded into a Processbook won't fire the Size event, but stand-alone Displays will. So after I saved my Displays as individual files, the events started to work. Not sure if this is a bug in Processbook or not...

                  1 of 1 people found this helpful