7 Replies Latest reply on Jan 15, 2009 5:56 PM by arash.khoddamy

    Display Close Event

    arash.khoddamy

      Hi,

       

       

       

      For one of my Toolbar add-in to ProcessBook I need to count the number of open ProcessBook Dispalys. But I don’t see an "on ProcessBook close" event which is causing me problems when users close a screen.  At this point I have a way doing it so it counts properly except for when the last display is closed.  I have tried "before display close" but that does not work as the display is still open.  I was wondering if there was an events like display close.

        • Re: Display Close Event

          Hi Arash,

           


          You can hook into the "Display_Terminate" event, this occurs after "Display_BeforeClose" event.  So once a user decides "Yes" or "No" to Save Display, if the display has been modified i.e. ThisDisplay.Modified property, then the Terminate event is fired.  Obviously if the user selects Cancel the event is not fired and the display remains open.

           

          Hope this helps!

           

          RJK Solutions.

            • Re: Display Close Event
              arash.khoddamy

              Hi RJK Solutions,

               

              First let me thank you for your reply to both my posts.  I have tried the display.Terminate event before,  but that also fires before the display is closed.  In my application I have procedure that fires on display.Terminate  and  when I do an application.Display.Count and I still 1.

               

               

               

              Thanks,

               

               

               

              Arash

               

               

                • Re: Display Close Event

                  Arash...Ok well the official line from OSI is "The Terminate event occurs when all references to a display are removed from memory by setting all the variables that refer to the object to Nothing." 

                   

                  So this is the last available event in the display life cycle...you are probably counting the displays inside the event when the display will still be there despite all references being set to nothing.

                   

                  Think this is one for OSI to answer for sure...

                   

                   

                    • Re: Display Close Event

                      The fact that VBA code in ProcessBook is associated to the display (as opposed to the ProcBook or the application) can make this kind of operations a little tricky. But still, there are a few ways you can accomplish what you want.

                       

                      Whichever technique you use, you will have to make use of the ProcessBook Application object and some of its events such as DisplayActivate, DisplayDeactivate, ProcbookActivate, ProcbookDeactivate, NewDisplay and NewProcbook.

                       

                          Approach #1: Display coded to never close (bCancelDefault = True under the Display_BeforeClose event);

                       

                          Approach #2: Add-in loading at startup and not necessarily show up on a toolbar.

                       

                      I would recommend the add-in approach as it is more elegant and cleaner.

                       

                      If you have never coded a ProcessBook add-in before, you can refer to the Visual Studio Sample Templates for Creating ProcessBook Add-ins (available for both VB.NET and C#), available on the technical support website, under the "Sample Code - .NET" category, and soon to be available in the vCampus Library.

                        • Re: Display Close Event

                          Steve, I think what Arash wants confirmation on is the last event in the lifecycle of a display or an event from the ProcessBook application that truly indicates a display has been closed and that the Application Display collection count is deceased by 1.

                          According to ProcessBook documentation, Display_Terminate is the last event when all references to the display are destroyed.  Arash says that even with a single display open, then closed the display count is still 1 from within the addin during this event.

                            • Re: Display Close Event

                              Sorry for the delay answering this one... I missed it before to go and I just got back from the Holidays

                               

                              The Display_Terminate indeed is the last event in a display's lifecycle. However, the ProcessBook application itself decreases the number of displays after that event. That means calling Application.Displays.Count from within the display you're closing, will always include that very display in the number.

                               

                              That's why I suggested to move from the display level to the application level in my last post - ideally by developing a simple add-in. Hope this helps!

                                • Re: Display Close Event
                                  arash.khoddamy

                                  HI Steve,

                                   

                                  No problem I have also away.

                                   

                                  I have an add-in which is toolbar for ProcessBook in it I have put a CommandBarComboBox that list the current open ProcessBook displays.   I have connected to events that open and activate displays to count the number of displays. (this is the way I got around the counting issue) Except for the last display. When the last display closes and all display events ( before close , terminate)  still indicate one display open. And there are no other events that I can connect to.  I have tried putting in a timer to refresh the display count but that adds a flicker.  Can you give me a bit more hit as how you would solve this in the application?