Engineering Requirements Management

 View Only
  • 1.  DXL Get Active Window

    Posted Wed November 30, 2022 03:42 PM

    I have developed a large scale DXL program that utilizes multiple Windows. When dealing with the callback functions for MenuBar DBE elements, I would like to know from which Window the user clicked the MenuBar because, depending on certain states of the window, the availability and behavior would be different. Since the Sensitivity and the click event callback functions take nothing but an integer, I need some sort of function that I can use to determine the Active Window. Something like current() that returns DBE. Even a function that just returns the title of the Active Window would be enough. Or a function that executes when a Window gets focus. Any one of those options would allow me to know from the Sensitivity or click event call back function which window is triggering the callback.

     

    There is nothing I can find in the DXL Reference Manual, and my search of all DXL Perms that existed as of version 9.3 (SmartDXL website has a list) has not yielded anything useful.

     

    There must be something available if multiple View Module Windows can be open at once, and the application knows which File menu was clicked, etc.

    ------------------------------
    Ryan Wood
    ------------------------------

    #Sustainability
    #EngineeringRequirementsManagement


  • 2.  RE: DXL Get Active Window

    Posted Mon December 05, 2022 10:09 AM
    In case someone comes across this thread and thinks, 'that was a while ago; surely he doesn't still need help with that.' Nope, I still need help with this. Still hoping to find a DXL native solution. For now, I am exploring the idea of having an external C# script executing in the background that sets an environment variable whenever the active window changes. DXL can then read that environment variable when it needs it.

    ------------------------------
    Ryan Wood
    ------------------------------



  • 3.  RE: DXL Get Active Window

    Posted Tue December 06, 2022 09:49 AM
    Hi Ryan,

    >>For now, I am exploring the idea of having an external C# script executing in the background that sets an environment variable

    Been a few years but I think you can define a top context global variable during DOORS startup using evalTop_ in

    C:\IBM\Programs\DOORSClient9725\lib\dxl\startup.dxl

    e.g.

    -----
    evalTop_ "string MenuWindow"

    //MenuWindow has been defined as a top context global string so it can be referenced by any other DXL program during the DOORS session

    MenuWindow = "abc"

    print MenuWindow
    ----

    This would keep the implementation inside DOORS rather than involving the operating system

    ------------------------------
    Sean F
    ------------------------------



  • 4.  RE: DXL Get Active Window

    Posted Tue December 06, 2022 11:36 AM

    Sean,

    evalTop_ allows us to declare variables and functions that are accessible by multiple different DXL programs that may be executed separately. This is not the need in this case.

    I have a single program that provides a Main Window listing any number of proposed changes to a spec. The user is able to open these proposed changes in a window that allows them to view or modify the proposal. These View/Modify windows all contain some consistent menus, including for example View, which provides View-->Base and View-->Change.

    Depending on the type of change proposal and the current state of the window, the availability and behavior of this menu will be different. A proposed deletion should only allow Base to be viewed, a proposed New should only allow Change to be viewed, and a proposed Modify should allow both to be Viewed. Depending on whether the user is currently viewing Base or Change, the check should be on one or the other when the user clicks the menu.

    Depending on whether the change is against a requirement, glossary term, figure, etc. the tool will launch a different View/Modify window since each item has different things that are needed.

    I have a method already to allow the user to open multiple View/Modify windows at once as long as they are different types, ie view/modify glossary and view/modify requirement may be opened at the same time.

    This is because they do not share the same global DB window variable. However, multiple instances of a View/Modify requirement window would share the same global DB window variable. I'm trying to get away from this construct so that the user can open more than one of the same type of window. In order to do that, I have to get rid of the global DB window variable and store a list of open windows. This is all fine, but when the user clicks on a callback function that takes neither a DB nor a DBE, I need some way of knowing from which window the callback was executed. I haven't been able to find anything that would give me this information. I considered a global variable DB activeWindow, which would be updated on function gotFocus, but I can't seem to find a way to register a callback for window got focus. The other option is to get a handle on the active DB through some function that already exists or get the name of the active window if that is available, which could give me a hook into the list of open windows I could use.

    I know that's a lot to read, and I appreciate you response. I did not know about evalTop_ and I'm certain it will be helpful to me for some reason or another in the future, but I'm still looking for a way of determining the active window.

    Respectfully,
    Ryan



    ------------------------------
    Ryan Wood
    ------------------------------



  • 5.  RE: DXL Get Active Window

    Posted Mon December 19, 2022 12:36 PM

    So, I haven't found a way to get the active window per se. However, there is a way to determine whether some DBE on a window has focus. The DXL Reference manual states that the hasFocus(DBE) function is only available for DBEs that were created as a ToolBar. However, in practice, it returns true for ANY DBE that has focus.

    In order to determine the active window without receiving a DBE in the Sensitivity function, then, I did the following:
    1. Keep a list of DxlObject Structures representing a Window. These structures contain a reference to the parent window and any children windows. Importantly for this task, though, they contain a list of the DBE items that are a part of the Dialog Box.
    2. While constructing the DB, pass each DBE to a function which adds the DBE to the list in the correct Window Structure.
    3. From the Sensitivity function, call on a function that will return the DB that contains a DBE for which the hasFocus(DBE) function returns true. There should be only one such DBE at any given time.

    Before implementing this solution, we wrote a python script that gets the active window's name and returns it to DXL using the win32SystemWait function. However, this required that each user has python installed and that they have access to the python win32 package. The solution above is preferable, but does require a good bit of work regarding the DxlObject structures and managing the lists appropriately.

    Ryan Wood



    ------------------------------
    Ryan Wood
    ------------------------------