VFW122 Launching a VLF Window

VLF Windows Application Development

VFW122 – Launching a VLF Window

Programatically Creating and Managing Windows

Your programs can create and manage windows by calling the method avShowWindow in the Framework manager.

For example:

  • Open a whole new instance of the Framework in another window named MYWINDOW:

     #AvFrameworkManager.avShowWindow Caller(#Com_Owner) For(FRAMEWORK) WindowName(MYWINDOW)

 

  • Open the DEMONSTRATION application:

         #AvFrameworkManager.avShowWindow Caller(#Com_Owner) For(APPLICATION) ofType(DEMO) WindowName(DEMO_WINDOW)

 

  • Open an application view named HR:

         #AvFrameworkManager.avShowWindow Caller(#Com_Owner) For(VIEW) ofType(HR) WindowName(DEMO_VIEW)

 

  • Open business objects Organizations and Resources in two independent windows:

         #AvFrameworkManager.avShowWindow Caller(#Com_Owner) For(BUSINESSOBJECT) ofType(DEM_ORG) WindowName(DEMO_EMP)
         #AvFrameworkManager.avShowWindow Caller(#Com_Owner) For(BUSINESSOBJECT)
 ofType(DEM_ORG_SEC_EMP) WindowName(DEMO_SECTION)

 

Remember that the OfType(DETAILS) names you specify on calls to avShowWindow are the User Object Name / Type values specified on the Identification tab of the properties of the respective object:

Using the avShowWindow method

When the avShowWindow method is invoked, it tests whether a window with the name specified exists.

If the named window already exists, it is activated (ie: restored from being minimized, if required, and brought to the front of all the Framework windows).

If the named window does not exist, it is created.

Then in both cases:

  • The window's open information properties and object reference are updated with anything you supplied (see Window Opening Information in the Visual LANSA Frameworks guide.).
  • A switch operation is performed inside the window to any application or business you may have nominated.

In simple terms, you are saying to the Framework "Display a window with this name and pass this information into it, then cause it to switch to this application or this business object".

When you create a new window or switch an existing window it happens asynchronously to your program. So if you use avShowWindow and then immediately enumerate all open windows you will not find the window you just created (yet).

The uShowWindowCompleted Method

This method should be placed in a command handler which needs to "wake up" and perform some processing when requested by a command handler in the main VLF window:

For example a command handler in a window named EMP_WINDOW contains:

Mthroutine Name(uShowWindowCompleted) Options(*Redefine)
  #EMPNO := #Com_Owner.avCurrentWindow.OpenInfo<1>
  Fetch Fields(#XG_HEAD) From_File(PSLMST) With_Key(#EMPNO)
Endroutine

 

The method uShowWindowCompleted  is run when another command handler performs:

#AvFrameworkManager.avShowWindow WindowName(EMP_WINDOW)

 

The methods avShowWindow and uShowWindowCompleted should be considered as a "pair".

Window Names

You may have noticed from the preceding examples that windows have symbolic names. Here are some things you should know about window names:

  • The names ALL, MAIN and CURRENT are reserved.
  • When an end-user opens a window it is automatically assigned a unique name that starts with USER_. Do not rely on USER_ window names being the same from Framework signon to signon or from Framework version to version.
  • Names are not end-user visible. They are programmatic names, case insensitive and may be up to 256 characters long. Being case insensitive means they are often uppercased, so using just 'A' -> 'Z' and '0' -> '9' is advisable.
  • Window names are uniquely scoped and only addressable within a Framework process (ie: a LANSA X_RUN.EXE process). This means that if you start multiple X_RUN.EXE processes they can each contain a unique window named TESTWINDOW. An operation that involves signalling or switching window TESTWINDOW only refers to it within the current X_RUN.EXE process. No intra-process windows operations are currently provided.

Application Settings

The Properties for a Framework, an Application and a Business Object enable the designer to determine whether each object can be opened in a new window, Never, Manually, Automatically or Automatically or Manually:

Note: The Automatic setting will always open the object in a new window when it is selected in the Navigation panel. It therefore means always open this object in a new window.

The setting applies to that level only. So a setting of Never at the Framework level, means the whole framework cannot be opened in a new window, but an application or business object can be opened in a new window, if this is allowed for the object.

Objective

To extend the Employee Images for a Section command handler to display employee details by opening a new Framework window.

To meet this objective you will complete the following steps:

Step 1. Extend Pop-Up Menu in Employee Image Object

Step 2. Enhance Employee Images for Section Command Handler

Step 3. Change Employee Details Command Handler

Step 4. Ensure Details displayed for first Employee

Summary

Before You Begin

Complete exercises VFW030, VFW040, VFW042, VFW100 and VFW104 before starting this exercise.

In exercise VFW104, you implemented Sections as a business object which is visible in the Navigation panel, with a By Department filter to populate the instance list. In this exercise you will add the ability to open Employee Details in a new window from the Employee Images for a Section command handler, working with the Sections business object itself. This will enable a 'switch back' to be implemented from Employee Details to Employee Images for Section in the main VLF window.