Reflection 2014 .NET API Guide
Integrate Web and Host Data

Using this sample program, you can build a custom application that can perform the following tasks:

In addition, the sample program demonstrates the recommended way to get an Application object and keep it around. It defines the class member variable m_application , assigns an Application instance to it in OnLoad(), and then uses the variable to reference the Application instance.

To build the custom application

  1. In Reflection, create two documents: a Web page document set to and a session document.
  2. Save the documents, noting their filenames and paths, and then quit Reflection.
  3. In Visual Studio, create a new Windows Forms Application project.
  4. In Solution Explorer, add the class assemblies. (For instructions, see Create an API Project.)
  5. In Solution Explorer, rename Form1.cs to Main.cs and copy either the code from the Main sample, replacing any existing code.

    This code defines the m_application variable, as follows:

    private Attachmate.Reflection.Framework.Application m_application;

    This code also provides the easiest and most reliable way to reference a Web element — the ID:

    IWebElement searchbox = m_WebDocument.GetElementById("q")

  6. In the code:

    Locate the line that starts

    And do this

    m_terminal= (IIbmTerminal)



    Edit the path to match the location of the session document you saved in step 1.

    For example, if you created a 5250 session named test.rd5x on Windows 7, edit the path to read as follows:


    m_webControl= (IWebControl)

    Edit the path to match the location of the Web page document you saved in step 1.

  7. Copy the code from the Main Designer sample to the Main.Designer.cs tab, replacing any existing code.
  8. Copy the code from the Program sample to the Program.cs tab, replacing any existing code.
  9. Right-click the solution node ("Integration"), add a Windows Form item, and then name it ProgressBox.cs. Next, right-click ProgressBox.cs, choose View Code, and copy the code from the Progress Box sample to the ProgressBox.cs tab, replacing any existing code.
  10. Expand ProgressBox.cs, double-click ProgressBox.Designer.cs, and paste the code from the Progress Box Designer samples to the ProgressBox.Designer.cs tab, replacing any existing code.
  11. Build and run the application.

    The program starts Reflection 2014 and opens a Windows Form application interface that contains two buttons and three text boxes.   

 To run the custom application

  1. In the custom application you created, click Load Sessions.

    The host and Web page documents open in Reflection.

  2. Click Search Host Text on Web to start the Internet search using the host text.

    The application extracts text from the host session screen and places it in the Search box of the Web page document. Then, it gets the Web element for the Search Web button and clicks the button, which triggers a search and a navigation to the search results page. From the search results page, it locates the Web element for the result text, extracts the number from that text, and places it in a message box.                

    When you quit the custom application, the m_application instance is garbage collected.